PromelaInlines.h
Go to the documentation of this file.
1 
20 #ifndef PROMELAINLINES_H_29BF8EF3
21 #define PROMELAINLINES_H_29BF8EF3
22 
23 #include "uscxml/config.h"
24 #include "uscxml/Common.h"
25 #include "uscxml/messages/Data.h"
26 #include "uscxml/util/DOM.h"
27 
28 #include <xercesc/dom/DOM.hpp>
29 #include <list>
30 #include <string>
31 
32 namespace uscxml {
33 
34 class USCXML_API PromelaInline {
35 public:
36  enum PromelaInlineType {
37  PROMELA_NIL = 0x0000,
38  PROMELA_LTL = 0x0001,
39  PROMELA_CODE = 0x0002,
40  PROMELA_EVENT_ALL_BUT = 0x0004,
41  PROMELA_EVENT_ONLY = 0x0008,
42  PROMELA_PROGRESS_LABEL = 0x0010,
43  PROMELA_ACCEPT_LABEL = 0x0020,
44  PROMELA_END_LABEL = 0x0040
45  };
46 
47  PromelaInline(const XERCESC_NS::DOMNode* node);
48  virtual ~PromelaInline() {}
49 
50  operator bool() {
51  return (type != PROMELA_NIL);
52  }
53 
54  std::list<PromelaInline*> children;
55  PromelaInline* prevSibling;
56  PromelaInline* nextSibling;
57 
58  virtual void dump();
59 
60  virtual bool relatesTo(const XERCESC_NS::DOMNode* node) {
61  return container == node;
62  }
63 
64  size_t level;
65  std::string content;
66  const XERCESC_NS::DOMElement* container;
67  PromelaInlineType type;
68 
69 protected:
70  PromelaInline() : prevSibling(NULL), nextSibling(NULL), type(PROMELA_NIL) {};
71 };
72 
73 
74 class USCXML_API PromelaEventSource : public PromelaInline {
75 public:
76  PromelaEventSource(const PromelaInline& pmlInline) {
77  type = pmlInline.type;
78  container = pmlInline.container;
79  content = pmlInline.content;
80  events = Data::fromJSON(pmlInline.content);
81  }
82 
83  virtual bool relatesTo(const XERCESC_NS::DOMNode* node) {
84  return container == node || DOMUtils::isDescendant(node, container);
85  }
86 
87  Data events;
88 };
89 
90 
91 class USCXML_API PromelaInlines {
92 public:
93 
94  PromelaInlines(const XERCESC_NS::DOMNode* node);
95  PromelaInlines() {}
96 
97  virtual ~PromelaInlines();
98 
99  std::list<PromelaInline*> getRelatedTo(const XERCESC_NS::DOMNode* node, PromelaInline::PromelaInlineType type);
100  std::list<PromelaInline*> getAllOfType(uint32_t type);
101 
102  std::map<const XERCESC_NS::DOMNode*, std::list<PromelaInline*> > inlines;
103  std::list<PromelaInline*> allInlines;
104 
105  static std::list<std::string> getStringLiterals(const Data& data);
106  static std::list<std::string> getEventNames(const Data& data);
107 
108 
109 };
110 
111 }
112 
113 #endif /* end of include guard: PROMELAINLINES_H_29BF8EF3 */
Definition: Breakpoint.cpp:26
Definition: PromelaInlines.h:91
Definition: PromelaInlines.h:74
Definition: PromelaInlines.h:34
Definition: Data.h:43