ChartToPromela.h
Go to the documentation of this file.
1 
20 #ifndef CHARTTOPROMELA_H_RP48RFDJ
21 #define CHARTTOPROMELA_H_RP48RFDJ
22 
23 #include "Transformer.h"
24 #include "ChartToC.h"
25 #include "uscxml/util/DOM.h"
26 
27 #include "promela/PromelaInlines.h"
29 
30 #include <ostream>
31 
32 namespace uscxml {
33 
34 class USCXML_API ChartToPromela : public ChartToC {
35 public:
36  virtual ~ChartToPromela();
37  static Transformer transform(const Interpreter& other);
38 
39  void writeTo(std::ostream& stream);
40 
41 protected:
42  ChartToPromela(const Interpreter& other) : ChartToC(other) {
43  _prefix = "U" + _md5.substr(0, 8) + "_";
44  }
45 
46  void writeTransitions(std::ostream& stream);
47  void writeStates(std::ostream& stream);
48 
49  void writeCommonTypeDefs(std::ostream& stream);
50  void writeCommonVariables(std::ostream& stream);
51  void writeTypeDefs(std::ostream& stream);
52  void writeVariables(std::ostream& stream);
53 
54 // void writeTypeDefs(std::ostream& stream);
55 // void writeTypes(std::ostream& stream);
56  void writeMacros(std::ostream& stream);
57  void writeFSM(std::ostream& stream);
58  void writeFSMDequeueEvent(std::ostream& stream);
59 // void writeFSMRescheduleMachines(std::ostream& stream);
60 // void writeFSMMacrostep(std::ostream& stream);
61 // void writeFSMDequeueInternalOrSpontaneousEvent(std::ostream& stream);
62  void writeFSMSelectTransitions(std::ostream& stream);
63  void writeFSMRememberHistory(std::ostream& stream);
64  void writeFSMEstablishEntrySet(std::ostream& stream);
65  void writeFSMExitStates(std::ostream& stream);
66  void writeFSMTakeTransitions(std::ostream& stream);
67  void writeFSMEnterStates(std::ostream& stream);
68  void writeFSMTerminateMachine(std::ostream& stream);
69 
70  void writeExecContent(std::ostream& stream, const XERCESC_NS::DOMNode* node, size_t indent = 0);
71  void writeRaiseDoneDate(std::ostream& stream, const XERCESC_NS::DOMElement* donedata, size_t indent = 0);
72 
73  void writeStrings(std::ostream& stream);
74 
75  void writeCancelEvents(std::ostream& stream, size_t indent = 0);
76  void writeScheduleMachines(std::ostream& stream, size_t indent = 0);
77  void writeDetermineShortestDelay(std::ostream& stream, size_t indent = 0);
78  void writeRescheduleProcess(std::ostream& stream, size_t indent = 0);
79  void writeInsertWithDelay(std::ostream& stream, size_t indent = 0);
80  void writeAdvanceTime(std::ostream& stream, size_t indent = 0);
81  void writeRemovePendingEventsFromInvoker(std::ostream& stream, size_t indent = 0);
82 
83  void prepare();
84 
85  void writeBitClearMacro(std::ostream& stream);
86  void writeBitHasAndMacro(std::ostream& stream);
87  void writeBitHasAnyMacro(std::ostream& stream);
88  void writeBitOrMacro(std::ostream& stream);
89  void writeBitCopyMacro(std::ostream& stream);
90  void writeBitAndMacro(std::ostream& stream);
91  void writeBitAndNotMacro(std::ostream& stream);
92 
93  void printBitArray(std::ostream& stream,
94  const std::string& array,
95  size_t length,
96  size_t indent = 0);
97 
98  PromelaCodeAnalyzer* _analyzer = NULL;
99 
100  ChartToPromela* _parentTopMost = NULL;
101  ChartToPromela* _parent = NULL;
102  std::string _invokerid;
103 
104  size_t _internalQueueLength = 7;
105  size_t _externalQueueLength = 7;
106  bool _allowEventInterleaving = false;
107 
108  std::map<std::string, XERCESC_NS::DOMElement* > _machinesPerId;
109  std::map<std::string, XERCESC_NS::DOMElement* >* _machinesAllPerId = NULL;
110  std::map<XERCESC_NS::DOMElement*, ChartToPromela*> _machinesNested;
111  std::map<XERCESC_NS::DOMElement*, ChartToPromela*>* _machinesAll = NULL;
112 
113  std::set<std::string> _dataModelVars;
114  std::list<std::string> _varInitializers; // pending initializations for arrays
115 
116  std::string beautifyIndentation(const std::string& code, size_t indent = 0);
117  void writeIfBlock(std::ostream& stream, std::list<XERCESC_NS::DOMElement*>& condChain, size_t indent = 0);
118 
119  std::string dataToAssignments(const std::string& prefix, const Data& data);
120  std::string sanitizeCode(const std::string& code);
121  std::string declForRange(const std::string& identifier, long minValue, long maxValue, bool nativeOnly = false);
122 
123  friend class PromelaCodeAnalyzer;
124 };
125 
126 }
127 
128 #endif /* end of include guard: CHARTTOPROMELA_H_RP48RFDJ */
Definition: Breakpoint.cpp:26
Definition: PromelaCodeAnalyzer.h:33
Central class to interpret and process SCXML documents.
Definition: Interpreter.h:79
Definition: ChartToC.h:33
Definition: Transformer.h:67
Definition: ChartToPromela.h:34
Definition: Data.h:44