rad  4.0.0
Helper.h
Go to the documentation of this file.
1 
10 /*
11  * scampl4cpp/engine
12  *
13  * Copyright by European Southern Observatory, 2012
14  * All rights reserved
15  *
16  * This library is free software; you can redistribute it and/or
17  * modify it under the terms of the GNU Lesser General Public
18  * License as published by the Free Software Foundation; either
19  * version 2.1 of the License, or (at your option) any later version.
20  *
21  * This library is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24  * Lesser General Public License for more details.
25  *
26  * You should have received a copy of the GNU Lesser General Public
27  * License along with this library; if not, write to the Free Software
28  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
29  * 02111-1307 USA.
30  */
31 
32 #ifndef SCXML4CPP_HELPER_H
33 #define SCXML4CPP_HELPER_H
34 
35 #ifndef __cplusplus
36 #error This is a C++ include file and cannot be used from plain C
37 #endif
38 
39 #include <list>
40 #include <set>
41 #include <vector>
42 #include <string>
43 
44 namespace scxml4cpp {
45 
46 class Transition;
47 class StateMachine;
48 class State;
49 class Action;
50 class Activity;
51 class Event;
52 
57 class Helper {
58  public:
62  Helper();
63 
67  ~Helper();
68 
72  const std::string printStateType(State* s);
73 
77  const std::string printTransition(Transition* t);
78 
82  const std::string printTransitions(std::list<Transition*>& transitions);
83 
87  const std::string printTargetState(Transition* transitions);
88 
92  const std::string printTargetStates(std::list<Transition*>& transitions);
93 
97  const std::string printActions(std::list<Action*>& actions);
98 
102  const std::string printActivities(std::list<Activity*>& activities);
103 
107  const std::string printStates(State* s);
108 
109 
113  const std::string printStateMachine(StateMachine&);
114 
115 
127  const std::string formatStatus(std::set<State*>& status, const bool usefullyqualified = false);
128 
136  const std::string formatStatus(std::list<State*>& status, const bool usefullyqualified = false);
137 
146  bool compareStateDocOrder(State* s1, State* s2);
147 
154  void sortAtomicStates(std::set<State*>& status, std::vector<State*>& sortedStatus);
155 
162  bool isInState(const std::set<State*>& status, const std::list<std::string>& stateNames);
163 
170  bool isInState(const std::list<State*>& status, const std::list<std::string>& stateNames);
171 
179  int countParents(State* s);
180 
190  bool isDescendant(State* s, State* p);
191 
198  std::set<State*> getAncestors(std::list<State*>& states);
199 
206  std::set<State*> getAncestors(State* state);
207 
214  std::list<State*> getAncestorsList(std::set<State*>& states);
215 
222  std::list<State*> getAncestorsList(State*);
223 
230  std::list<State*> getAncestorsList(std::list<State*>& states);
231 
239  std::list<State*> getProperAncestors(State* state, State* upperBound);
240 
251 
260  bool eventMatch(const Event& e1, const Event& e2);
261 
268  std::list<State*> getAtomicStates(std::set<State*>& states);
269 
276  std::list<State*> getAtomicStates(std::list<State*>& states);
277 
293  bool isPreempted(State* s, std::list<Transition*>& transitions);
294 
295  private:
296  Helper(const Helper&);
297  Helper& operator=(const Helper&);
298 };
299 
300 } // namespace scxml4cpp
301 
302 #endif // SCXML4CPP_HELPER_H
scxml4cpp::Helper::getAtomicStates
std::list< State * > getAtomicStates(std::set< State * > &states)
Definition: Helper.cpp:689
scxml4cpp
Definition: Action.h:40
scxml4cpp::Helper::formatStatus
const std::string formatStatus(std::set< State * > &status, const bool usefullyqualified=false)
Definition: Helper.cpp:282
scxml4cpp::Transition
Definition: Transition.h:68
scxml4cpp::Helper::sortAtomicStates
void sortAtomicStates(std::set< State * > &status, std::vector< State * > &sortedStatus)
Definition: Helper.cpp:418
scxml4cpp::Helper::printActions
const std::string printActions(std::list< Action * > &actions)
Definition: Helper.cpp:177
scxml4cpp::Helper::getAncestorsList
std::list< State * > getAncestorsList(std::set< State * > &states)
Definition: Helper.cpp:606
scxml4cpp::Helper::printStateType
const std::string printStateType(State *s)
Definition: Helper.cpp:52
scxml4cpp::Helper::countParents
int countParents(State *s)
Definition: Helper.cpp:542
scxml4cpp::Helper::compareStateDocOrder
bool compareStateDocOrder(State *s1, State *s2)
Definition: Helper.cpp:360
scxml4cpp::Helper::printTargetState
const std::string printTargetState(Transition *transitions)
Definition: Helper.cpp:150
scxml4cpp::StateMachine
Definition: StateMachine.h:64
scxml4cpp::Helper::printActivities
const std::string printActivities(std::list< Activity * > &activities)
Definition: Helper.cpp:189
scxml4cpp::State
Definition: State.h:60
scxml4cpp::Helper::getProperAncestors
std::list< State * > getProperAncestors(State *state, State *upperBound)
Definition: Helper.cpp:553
scxml4cpp::Helper
Definition: Helper.h:57
scxml4cpp::Helper::printStates
const std::string printStates(State *s)
Definition: Helper.cpp:201
scxml4cpp::Helper::printStateMachine
const std::string printStateMachine(StateMachine &)
Definition: Helper.cpp:252
scxml4cpp::Helper::printTransition
const std::string printTransition(Transition *t)
Definition: Helper.cpp:78
scxml4cpp::Helper::getAncestors
std::set< State * > getAncestors(std::list< State * > &states)
Definition: Helper.cpp:572
scxml4cpp::Helper::printTransitions
const std::string printTransitions(std::list< Transition * > &transitions)
Definition: Helper.cpp:138
scxml4cpp::Helper::Helper
Helper()
Definition: Helper.cpp:48
scxml4cpp::Event
Definition: Event.h:66
scxml4cpp::Helper::printTargetStates
const std::string printTargetStates(std::list< Transition * > &transitions)
Definition: Helper.cpp:165
scxml4cpp::Helper::isPreempted
bool isPreempted(State *s, std::list< Transition * > &transitions)
Definition: Helper.cpp:719
scxml4cpp::Helper::~Helper
~Helper()
Definition: Helper.cpp:50
scxml4cpp::Helper::isInState
bool isInState(const std::set< State * > &status, const std::list< std::string > &stateNames)
Definition: Helper.cpp:452
scxml4cpp::Helper::isDescendant
bool isDescendant(State *s, State *p)
Definition: Helper.cpp:503
scxml4cpp::Helper::eventMatch
bool eventMatch(const Event &e1, const Event &e2)
Definition: Helper.cpp:676
scxml4cpp::Helper::findLeastCommonAncestor
State * findLeastCommonAncestor(State *s1, State *s2)
Definition: Helper.cpp:650