RTC Toolkit  1.0.0
modelManipulator.hpp
Go to the documentation of this file.
1 
12 #ifndef RTCTK_COMPONENTFRAMEWORK_MODELMANIPULATOR_HPP
13 #define RTCTK_COMPONENTFRAMEWORK_MODELMANIPULATOR_HPP
14 
16 
17 #include <string>
18 
19 namespace rtctk::componentFramework {
20 
25 public:
33  explicit ModelManipulator(StateMachine& sm);
34 
43  std::string GetParentId(std::string const& id);
44 
55  void AddState(StateType type,
56  std::string const& id,
57  std::string const& parent_id = "",
58  std::string const& activity_id = "",
59  std::string const& entry_action_id = "",
60  std::string const& exit_action_id = "");
61 
68  void DelState(std::string const& id);
69 
79  void RepState(std::string const& id, std::string const& new_id);
80 
88  void ModStateId(std::string const& state_id, std::string const& new_state_id);
89 
97  void ModStateType(std::string const& state_id, StateType new_state_type);
105  void ModStateParent(std::string const& state_id, std::string const& new_parent_id);
106 
114  void ModStateDoActivity(std::string const& state_id, std::string const& new_activity_id);
115 
123  void ModStateEntryAction(std::string const& state_id, std::string const& new_entry_action_id);
124 
132  void ModStateExitAction(std::string const& state_id, std::string const& new_exit_action_id);
133 
146  void ExtStateToParallel(std::string const& id);
147 
159  void AddTrans(std::string const& source_id,
160  std::string const& target_id,
161  std::string const& event_id = "",
162  std::string const& guard_id = "",
163  std::string const& action_id = "");
164 
175  void DelTrans(std::string const& source_id,
176  std::string const& target_id,
177  std::string const& event_id = "",
178  std::string const& guard_id = "");
179 
191  void ModTransTarget(std::string const& source_id,
192  std::string const& target_id,
193  std::string const& event_id,
194  std::string const& guard_id,
195  std::string const& new_target_id);
196 
208  void ModTransSource(std::string const& source_id,
209  std::string const& target_id,
210  std::string const& event_id,
211  std::string const& guard_id,
212  std::string const& new_source_id);
213 
225  void ModTransEvent(std::string const& source_id,
226  std::string const& target_id,
227  std::string const& event_id,
228  std::string const& guard_id,
229  std::string const& new_event_id);
230 
242  void ModTransGuard(std::string const& source_id,
243  std::string const& target_id,
244  std::string const& event_id,
245  std::string const& guard_id,
246  std::string const& new_guard_id);
247 
259  void ModTransAction(std::string const& source_id,
260  std::string const& target_id,
261  std::string const& event_id,
262  std::string const& guard_id,
263  std::string const& new_action_id);
264 
265 private:
266  State* GetStatePtr(std::string const& state_id);
267 
268  State* FindState(std::string const& state_id);
269 
270  Transition* FindTransition(std::string const& source_id,
271  std::string const& target_id,
272  std::string const& event_id,
273  std::string const& guard_id);
274 
275  void DelStateRecursive(State* state);
276 
277  StateMachine& m_sm;
278 };
279 
280 } // namespace rtctk::componentFramework
281 
282 #endif
rtctk::componentFramework::ModelManipulator::ModelManipulator
ModelManipulator(StateMachine &sm)
Constructor.
Definition: modelManipulator.cpp:22
rtctk::componentFramework::ModelManipulator::ModStateExitAction
void ModStateExitAction(std::string const &state_id, std::string const &new_exit_action_id)
Modifies the exit-action of a state.
Definition: modelManipulator.cpp:176
rtctk::componentFramework::ModelManipulator::ModTransTarget
void ModTransTarget(std::string const &source_id, std::string const &target_id, std::string const &event_id, std::string const &guard_id, std::string const &new_target_id)
Modifies the target state of a transition.
Definition: modelManipulator.cpp:268
rtctk::componentFramework::ModelManipulator::ModStateEntryAction
void ModStateEntryAction(std::string const &state_id, std::string const &new_entry_action_id)
Modifies the entry-action of a state.
Definition: modelManipulator.cpp:170
rtctk::componentFramework::ModelManipulator::ModTransGuard
void ModTransGuard(std::string const &source_id, std::string const &target_id, std::string const &event_id, std::string const &guard_id, std::string const &new_guard_id)
Modifies the guard of a transition.
Definition: modelManipulator.cpp:295
rtctk::componentFramework::ModelManipulator::ModTransSource
void ModTransSource(std::string const &source_id, std::string const &target_id, std::string const &event_id, std::string const &guard_id, std::string const &new_source_id)
Modifies the source state of a transition.
Definition: modelManipulator.cpp:277
rtctk::componentFramework::ModelManipulator::AddTrans
void AddTrans(std::string const &source_id, std::string const &target_id, std::string const &event_id="", std::string const &guard_id="", std::string const &action_id="")
Adds a new transition.
Definition: modelManipulator.cpp:227
rtctk::componentFramework::StateMachine
Definition: model.hpp:53
model.hpp
In-memory representation of the state machine model.
rtctk::componentFramework::ModelManipulator::ModStateType
void ModStateType(std::string const &state_id, StateType new_state_type)
Modifies type of state.
Definition: modelManipulator.cpp:122
rtctk::componentFramework
Definition: commandReplier.cpp:20
rtctk::componentFramework::ModelManipulator::ExtStateToParallel
void ExtStateToParallel(std::string const &id)
Parallel Extension.
Definition: modelManipulator.cpp:183
rtctk::componentFramework::ModelManipulator::ModStateParent
void ModStateParent(std::string const &state_id, std::string const &new_parent_id)
Re-parents a state.
Definition: modelManipulator.cpp:148
rtctk::componentFramework::ModelManipulator
Class that provides methods to manipulate the state machine model.
Definition: modelManipulator.hpp:24
rtctk::componentFramework::ModelManipulator::RepState
void RepState(std::string const &id, std::string const &new_id)
Replaces a state with another state.
Definition: modelManipulator.cpp:57
rtctk::componentFramework::State
Definition: model.hpp:30
rtctk::componentFramework::ModelManipulator::ModStateId
void ModStateId(std::string const &state_id, std::string const &new_state_id)
Renames a state.
Definition: modelManipulator.cpp:117
rtctk::componentFramework::StateType
StateType
Definition: model.hpp:21
rtctk::componentFramework::Transition
Definition: model.hpp:44
rtctk::componentFramework::ModelManipulator::AddState
void AddState(StateType type, std::string const &id, std::string const &parent_id="", std::string const &activity_id="", std::string const &entry_action_id="", std::string const &exit_action_id="")
Adds a new state.
Definition: modelManipulator.cpp:29
rtctk::componentFramework::ModelManipulator::DelState
void DelState(std::string const &id)
Deletes an existing state including all of its children and transitions.
Definition: modelManipulator.cpp:82
rtctk::componentFramework::ModelManipulator::ModStateDoActivity
void ModStateDoActivity(std::string const &state_id, std::string const &new_activity_id)
Modifies the do-activity of a state.
Definition: modelManipulator.cpp:165
rtctk::componentFramework::ModelManipulator::ModTransAction
void ModTransAction(std::string const &source_id, std::string const &target_id, std::string const &event_id, std::string const &guard_id, std::string const &new_action_id)
Modifies the action of a transition.
Definition: modelManipulator.cpp:304
rtctk::componentFramework::ModelManipulator::ModTransEvent
void ModTransEvent(std::string const &source_id, std::string const &target_id, std::string const &event_id, std::string const &guard_id, std::string const &new_event_id)
Modifies the trigger of a transition.
Definition: modelManipulator.cpp:286
rtctk::componentFramework::ModelManipulator::GetParentId
std::string GetParentId(std::string const &id)
Gets the name of the parent state.
Definition: modelManipulator.cpp:25
rtctk::componentFramework::ModelManipulator::DelTrans
void DelTrans(std::string const &source_id, std::string const &target_id, std::string const &event_id="", std::string const &guard_id="")
Deletes an existing transition.
Definition: modelManipulator.cpp:249