rad  3.0.0
Helper.h
Go to the documentation of this file.
1 /*
2  * scampl4cpp/engine
3  *
4  * Copyright by European Southern Observatory, 2012
5  * All rights reserved
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20  * 02111-1307 USA.
21  */
22 
23 /*
24  * $Id: Helper.h 1139 2016-07-20 14:57:28Z landolfa $
25  */
26 
27 #ifndef SCXML4CPP_HELPER_H
28 #define SCXML4CPP_HELPER_H
29 
30 #ifndef __cplusplus
31 #error This is a C++ include file and cannot be used from plain C
32 #endif
33 
34 #include <list>
35 #include <set>
36 #include <vector>
37 #include <string>
38 
39 namespace scxml4cpp {
40 
41 class Transition;
42 class StateMachine;
43 class State;
44 class Action;
45 class Activity;
46 class Event;
47 
48 class Helper {
49  public:
50  Helper();
51  ~Helper();
52 
53  const std::string printStateType(State* s);
54  const std::string printTransition(Transition* t);
55  const std::string printTransitions(std::list<Transition*>& transitions);
56  const std::string printTargetState(Transition* transitions);
57  const std::string printTargetStates(std::list<Transition*>& transitions);
58  const std::string printActions(std::list<Action*>& actions);
59  const std::string printActivities(std::list<Activity*>& activities);
60  const std::string printStates(State* s);
61  const std::string printStateMachine(StateMachine&);
62 
63  const std::string formatStatus(std::set<State*>& status, const bool usefullyqualified = false);
64 
65  bool compareStateDocOrder(State* s1, State* s2);
66  void sortAtomicStates(std::set<State*>& status, std::vector<State*>& sortedStatus);
67 
68  bool isInState(const std::set<State*>& status, const std::list<std::string>& stateNames);
69 
70  int countParents(State*);
71  bool isDescendant(State*, State*);
72 
73  std::set<State*> getAncestors(std::list<State*>& states);
74  std::list<State*> getAncestorsList(std::set<State*>& states);
75  std::set<State*> getAncestors(State*);
76  std::list<State*> getAncestorsList(State*);
77  std::list<State*> getProperAncestors(State*, State*);
78 
80  bool eventMatch(const Event&, const Event&);
81 
82  std::list<State*> getAtomicStates(std::set<State*>& states);
83  std::list<State*> getAtomicStates(std::list<State*>& states);
84 
85  bool isPreempted(State*, std::list<Transition*>& transitions);
86 
87  private:
88  Helper(const Helper&);
89  Helper& operator=(const Helper&);
90 };
91 
92 } // namespace scxml4cpp
93 
94 #endif // SCXML4CPP_HELPER_H
scxml4cpp::Helper::getAtomicStates
std::list< State * > getAtomicStates(std::set< State * > &states)
Definition: Helper.cpp:577
scxml4cpp
Definition: Action.h:36
scxml4cpp::Helper::formatStatus
const std::string formatStatus(std::set< State * > &status, const bool usefullyqualified=false)
Definition: Helper.cpp:277
scxml4cpp::Transition
Definition: Transition.h:55
scxml4cpp::Helper::sortAtomicStates
void sortAtomicStates(std::set< State * > &status, std::vector< State * > &sortedStatus)
Definition: Helper.cpp:366
scxml4cpp::Helper::printActions
const std::string printActions(std::list< Action * > &actions)
Definition: Helper.cpp:172
scxml4cpp::Helper::getAncestorsList
std::list< State * > getAncestorsList(std::set< State * > &states)
Definition: Helper.cpp:494
scxml4cpp::Helper::printStateType
const std::string printStateType(State *s)
Definition: Helper.cpp:47
scxml4cpp::Helper::compareStateDocOrder
bool compareStateDocOrder(State *s1, State *s2)
Definition: Helper.cpp:324
scxml4cpp::Helper::eventMatch
bool eventMatch(const Event &, const Event &)
Definition: Helper.cpp:564
scxml4cpp::Helper::printTargetState
const std::string printTargetState(Transition *transitions)
Definition: Helper.cpp:145
scxml4cpp::Helper::isPreempted
bool isPreempted(State *, std::list< Transition * > &transitions)
Definition: Helper.cpp:607
scxml4cpp::StateMachine
Definition: StateMachine.h:45
scxml4cpp::Helper::printActivities
const std::string printActivities(std::list< Activity * > &activities)
Definition: Helper.cpp:184
scxml4cpp::State
Definition: State.h:48
scxml4cpp::Helper::countParents
int countParents(State *)
Definition: Helper.cpp:447
scxml4cpp::Helper
Definition: Helper.h:48
scxml4cpp::Helper::printStates
const std::string printStates(State *s)
Definition: Helper.cpp:196
scxml4cpp::Helper::printStateMachine
const std::string printStateMachine(StateMachine &)
Definition: Helper.cpp:247
scxml4cpp::Helper::printTransition
const std::string printTransition(Transition *t)
Definition: Helper.cpp:73
scxml4cpp::Helper::getAncestors
std::set< State * > getAncestors(std::list< State * > &states)
Definition: Helper.cpp:477
scxml4cpp::Helper::printTransitions
const std::string printTransitions(std::list< Transition * > &transitions)
Definition: Helper.cpp:133
scxml4cpp::Helper::Helper
Helper()
Definition: Helper.cpp:43
scxml4cpp::Event
Definition: Event.h:39
scxml4cpp::Helper::printTargetStates
const std::string printTargetStates(std::list< Transition * > &transitions)
Definition: Helper.cpp:160
scxml4cpp::Helper::findLeastCommonAncestor
State * findLeastCommonAncestor(State *, State *)
Definition: Helper.cpp:538
scxml4cpp::Helper::~Helper
~Helper()
Definition: Helper.cpp:45
scxml4cpp::Helper::isInState
bool isInState(const std::set< State * > &status, const std::list< std::string > &stateNames)
Definition: Helper.cpp:400
scxml4cpp::Helper::getProperAncestors
std::list< State * > getProperAncestors(State *, State *)
Definition: Helper.cpp:458
scxml4cpp::Helper::isDescendant
bool isDescendant(State *, State *)
Definition: Helper.cpp:421