FastMicroStep.h
Go to the documentation of this file.
1 
20 #ifndef FASTMICROSTEP_H_065FE1F7
21 #define FASTMICROSTEP_H_065FE1F7
22 
23 //#define USCXML_VERBOSE 1
24 
25 #include "uscxml/config.h"
26 #include "uscxml/Common.h"
27 #include "uscxml/util/DOM.h" // X
28 
29 #include <vector>
30 #include <map>
31 #include <set>
32 #include "MicroStepImpl.h"
33 
34 #include <boost/dynamic_bitset.hpp>
35 
36 namespace uscxml {
37 
42 class FastMicroStep : public MicroStepImpl {
43 public:
45  virtual ~FastMicroStep();
46  virtual std::shared_ptr<MicroStepImpl> create(MicroStepCallbacks* callbacks);
47 
48  virtual InterpreterState step(size_t blockMs);
49  virtual void reset();
50  virtual bool isInState(const std::string& stateId);
51  virtual std::list<XERCESC_NS::DOMElement*> getConfiguration();
52  void markAsCancelled();
53 
54 protected:
55  class Transition {
56  public:
57  Transition() : element(NULL), source(0), onTrans(NULL), type(0) {}
58 
59  XERCESC_NS::DOMElement* element;
60  boost::dynamic_bitset<> conflicts;
61  boost::dynamic_bitset<> exitSet;
62 
63  uint32_t source;
64  boost::dynamic_bitset<> target;
65 
66  XERCESC_NS::DOMElement* onTrans;
67 
68  std::string event;
69  std::string cond;
70 
71  unsigned char type;
72 
73  };
74 
75  class State {
76  public:
77  State() : element(NULL), parent(0), documentOrder(0), doneData(NULL), type(0) {}
78 
79  XERCESC_NS::DOMElement* element;
80  boost::dynamic_bitset<> completion;
81  boost::dynamic_bitset<> children;
82  boost::dynamic_bitset<> ancestors;
83  uint32_t parent;
84  uint32_t documentOrder;
85 
86  std::list<XERCESC_NS::DOMElement*> data;
87  std::list<XERCESC_NS::DOMElement*> invoke;
88  std::list<XERCESC_NS::DOMElement*> onEntry;
89  std::list<XERCESC_NS::DOMElement*> onExit;
90  XERCESC_NS::DOMElement* doneData;
91 
92  unsigned char type;
93  };
94 
96  public:
97  std::map<const XERCESC_NS::DOMElement*, std::list<XERCESC_NS::DOMElement*> > exitSet;
98  };
99 
100  virtual void init(XERCESC_NS::DOMElement* scxml);
101 
102  std::list<XERCESC_NS::DOMElement*> getCompletion(const XERCESC_NS::DOMElement* state);
103 
104  unsigned char _flags;
105  std::map<std::string, int> _stateIds;
106 
107  std::vector<State*> _states;
108  std::vector<Transition*> _transitions;
109  std::list<XERCESC_NS::DOMElement*> _globalScripts;
110 
111  boost::dynamic_bitset<> _configuration;
112  boost::dynamic_bitset<> _invocations;
113  boost::dynamic_bitset<> _history;
114  boost::dynamic_bitset<> _initializedData;
115 
116  std::set<boost::dynamic_bitset<> > _microstepConfigurations;
117 
118  Binding _binding;
119  XERCESC_NS::DOMElement* _scxml;
120  X _xmlPrefix;
121  X _xmlNS;
122 
123  bool _isInitialized;
124  bool _isCancelled;
125  Event _event; // we do not care about the event's representation
126 
127 private:
128  std::list<XERCESC_NS::DOMElement*> getHistoryCompletion(const XERCESC_NS::DOMElement* state);
129  void resortStates(XERCESC_NS::DOMElement* node, const X& xmlPrefix);
130 
131  bool conflictsCached(const XERCESC_NS::DOMElement* t1, const XERCESC_NS::DOMElement* t2, const XERCESC_NS::DOMElement* root);
132 
133  std::list<XERCESC_NS::DOMElement*> getExitSetCached(const XERCESC_NS::DOMElement* transition,
134  const XERCESC_NS::DOMElement* root);
135 
136  CachedPredicates _cache;
137 
138 #ifdef USCXML_VERBOSE
139  void printStateNames(const boost::dynamic_bitset<>& bitset);
140 #endif
141 
142 };
143 
144 }
145 
146 #endif /* end of include guard: FASTMICROSTEP_H_065FE1F7 */
147 
Definition: FastMicroStep.h:42
Definition: MicroStepImpl.h:69
Definition: Breakpoint.cpp:26
Definition: MicroStepImpl.h:40
Definition: Event.h:84
virtual void reset()
Reset state machine.
Definition: FastMicroStep.cpp:962
virtual InterpreterState step(size_t blockMs)
Definition: FastMicroStep.cpp:446
Definition: FastMicroStep.h:55
virtual void init(XERCESC_NS::DOMElement *scxml)
Definition: FastMicroStep.cpp:187
Definition: FastMicroStep.h:75
Definition: FastMicroStep.h:95
Definition: DOM.h:110