Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
action.h
1/*
2** Copyright 2007-2024, RTE (https://www.rte-france.com)
3** See AUTHORS.txt
4** SPDX-License-Identifier: MPL-2.0
5** This file is part of Antares-Simulator,
6** Adequacy and Performance assessment for interconnected energy networks.
7**
8** Antares_Simulator is free software: you can redistribute it and/or modify
9** it under the terms of the Mozilla Public Licence 2.0 as published by
10** the Mozilla Foundation, either version 2 of the License, or
11** (at your option) any later version.
12**
13** Antares_Simulator is distributed in the hope that it will be useful,
14** but WITHOUT ANY WARRANTY; without even the implied warranty of
15** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16** Mozilla Public Licence 2.0 for more details.
17**
18** You should have received a copy of the Mozilla Public Licence 2.0
19** along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
20*/
21#ifndef __ANTARES_LIBS_STUDY_ACTION_ACTION_H__
22#define __ANTARES_LIBS_STUDY_ACTION_ACTION_H__
23
24#include <yuni/yuni.h>
25#include <yuni/core/tree/treeN.h>
26#include <yuni/core/string.h>
27#include "fwd.h"
28#include <antares/study/study.h>
29#include <vector>
30
31namespace Antares
32{
33namespace Action
34{
35class Context;
36
37class IAction : public Yuni::Core::TreeN<IAction>
38{
39public:
41 using AncestorType = Yuni::Core::TreeN<IAction>;
43 using Ptr = AncestorType::Ptr;
45 using ThreadingPolicy = AncestorType::ThreadingPolicy;
46
48 using Vector = std::vector<Ptr>;
49
51 using iterator = AncestorType::iterator;
52
53public:
55
56
59 IAction();
61 virtual ~IAction();
63
67 Yuni::String caption() const;
68
72 Yuni::String message() const;
73
77 bool prepare(Context& ctx);
78
82 void registerViews(Context& ctx);
83
84 void datagridCaption(Yuni::String& title);
85
89 bool prepareRootNode(Context& ctx);
90
94 bool perform(Context& ctx, bool recursive = true);
95
99 void dump() const;
100
104 virtual bool bold() const;
105
109 virtual bool autoExpand() const;
110
114 virtual bool canDoSomething() const;
115
116 virtual bool allowUpdate() const;
117 virtual bool allowSkip() const;
118 virtual bool allowOverwrite() const;
119 virtual bool shouldPrepareRootNode() const;
120
122 virtual bool visible() const;
123
125
126
127 Behavior behavior() const;
129 void behavior(Behavior newBehavior);
131
133 bool prepareStack(Vector& vector);
134
136
137 State state() const;
139
141
142 virtual void behaviorToText(Behavior behavior, Yuni::String& out);
144
148 void createPostActions(const IAction::Ptr& node);
149
150protected:
152 virtual bool prepareWL(Context& ctx) = 0;
154 virtual void prepareSkipWL(Context&)
155 {
156 }
158 virtual bool performWL(Context& ctx) = 0;
161 {
162 }
164 virtual void createPostActionsWL(const IAction::Ptr& node);
165
166protected:
169
170private:
171 void internalDump(Yuni::String& tmp, uint level) const;
172
173}; // class IAction
174
175} // namespace Action
176} // namespace Antares
177
178#include "context.h"
179#include "action.hxx"
180
181#endif // __ANTARES_LIBS_STUDY_ACTION_ACTION_H__
Definition context.h:38
Definition action.h:38
virtual void createPostActionsWL(const IAction::Ptr &node)
Create post actions (if any)
Definition action.hxx:84
std::vector< Ptr > Vector
Vector.
Definition action.h:48
bool perform(Context &ctx, bool recursive=true)
Perform the action.
Definition action.cpp:131
virtual bool bold() const
Get if the action should be represented with a bold font.
Definition action.hxx:28
IAction()
Default constructor.
Definition action.cpp:31
AncestorType::Ptr Ptr
The most suitable smart ptr for the class.
Definition action.h:43
bool prepare(Context &ctx)
Make preparations for the execution.
Definition action.cpp:94
Behavior behavior() const
Get the behavior.
Definition action.hxx:38
AncestorType::iterator iterator
iterator
Definition action.h:51
virtual void prepareSkipWL(Context &)
Prepare the execution (when the behavior says that the action should be skipped)
Definition action.h:154
virtual void registerViewsWL(Context &)
Register all views.
Definition action.h:160
virtual ~IAction()
Destructor.
Definition action.cpp:35
bool prepareRootNode(Context &ctx)
Look for the root node and make preparations for the execution.
Definition action.cpp:121
void dump() const
Dump the tree from this node to the stdcout.
Definition action.cpp:57
Yuni::Core::TreeN< IAction > AncestorType
The ancestor.
Definition action.h:41
ActionInformations pInfos
All data related to the action.
Definition action.h:168
virtual bool autoExpand() const
Auto-expand.
Definition action.hxx:33
void registerViews(Context &ctx)
Register if possible the action into the appropriate view.
Definition action.cpp:113
bool prepareStack(Vector &vector)
Prepare the whole list of actions to execute in the given order.
Definition action.cpp:158
virtual bool prepareWL(Context &ctx)=0
Prepare the execution.
virtual bool visible() const
Get if the action should be visible to the user.
Definition action.hxx:79
Yuni::String message() const
Get the message of the action.
Definition action.cpp:45
virtual bool performWL(Context &ctx)=0
Perform the action.
AncestorType::ThreadingPolicy ThreadingPolicy
The threading policy.
Definition action.h:45
Yuni::String caption() const
Get the caption of the action.
Definition action.cpp:39
void createPostActions(const IAction::Ptr &node)
Create post actions if required.
Definition action.cpp:178