PromelaDataModel.h
Go to the documentation of this file.
1 
20 #ifndef PROMELADATAMODEL_H_4VG0TDMU
21 #define PROMELADATAMODEL_H_4VG0TDMU
22 
23 #include "uscxml/config.h"
25 #include <list>
26 
27 #ifdef BUILD_AS_PLUGINS
28 #include "uscxml/plugins/Plugins.h"
29 #endif
30 
31 namespace uscxml {
32 
34 public:
36  virtual ~PromelaDataModel();
37  virtual std::shared_ptr<DataModelImpl> create(DataModelCallbacks* callbacks);
38 
39  virtual std::list<std::string> getNames() {
40  std::list<std::string> names;
41  names.push_back("promela");
42  return names;
43  }
44 
45  virtual void addExtension(DataModelExtension* ext);
46 
47  virtual bool isValidSyntax(const std::string& expr);
48 
49  virtual void setEvent(const Event& event);
50 
51  // foreach
52  virtual uint32_t getLength(const std::string& expr);
53  virtual void setForeach(const std::string& item,
54  const std::string& array,
55  const std::string& index,
56  uint32_t iteration);
57 
58  virtual bool evalAsBool(const std::string& expr);
59  virtual Data evalAsData(const std::string& expr);
60  virtual Data getAsData(const std::string& content);
61 
62  virtual bool isDeclared(const std::string& expr);
63 
64  virtual void assign(const std::string& location,
65  const Data& data,
66  const std::map<std::string, std::string>& attr = std::map<std::string, std::string>());
67  virtual void init(const std::string& location,
68  const Data& data,
69  const std::map<std::string, std::string>& attr = std::map<std::string, std::string>());
70 
71 protected:
72 
73  int dataToInt(const Data& data);
74  bool dataToBool(const Data& data);
75 
76  void evaluateDecl(void* ast);
77  Data evaluateExpr(void* ast);
78  void evaluateStmnt(void* ast);
79 
80  void evaluateDecl(const std::string& expr);
81  Data evaluateExpr(const std::string& expr);
82  void evaluateStmnt(const std::string& expr);
83 
84  void setVariable(void* ast, const Data& value);
85  Data getVariable(void* ast);
86 
87  void adaptType(Data& data);
88 
89  int _lastMType;
90 
91  Event _event;
92  std::string _name;
93  std::string _sessionId;
94 
95  Data _variables;
96 
97 };
98 
99 #ifdef BUILD_AS_PLUGINS
100 PLUMA_INHERIT_PROVIDER(PromelaDataModel, DataModelImpl)
101 #endif
102 
103 }
104 
105 #endif /* end of include guard: PROMELADATAMODEL_H_4VG0TDMU */
virtual std::shared_ptr< DataModelImpl > create(DataModelCallbacks *callbacks)
The Factory wants to instantiate a new instance.
Definition: PromelaDataModel.cpp:59
virtual std::list< std::string > getNames()
Return a list of names to be matched by the datamodel attribute in SCXML.
Definition: PromelaDataModel.h:39
Definition: Breakpoint.cpp:26
virtual Data evalAsData(const std::string &expr)
Return a string as an evaluated Data object.
Definition: PromelaDataModel.cpp:262
virtual void setEvent(const Event &event)
Set the given event as _event in the data-model's global scope.
Definition: PromelaDataModel.cpp:91
Definition: DataModelImpl.h:61
Abstract base class for all data-model implementations.
Definition: DataModelImpl.h:77
virtual bool isValidSyntax(const std::string &expr)
Determine whether a given string constitutes valid syntax in the data-model's language.
Definition: PromelaDataModel.cpp:191
Definition: PromelaDataModel.h:33
virtual bool evalAsBool(const std::string &expr)
Evaluate a given expression as a boolean.
Definition: PromelaDataModel.cpp:250
virtual uint32_t getLength(const std::string &expr)
Evaluate the given expression as something iterable and return its length.
Definition: PromelaDataModel.cpp:201
virtual void setForeach(const std::string &item, const std::string &array, const std::string &index, uint32_t iteration)
Set a given item to the object at a given index for one iteration.
Definition: PromelaDataModel.cpp:213
virtual bool isDeclared(const std::string &expr)
Determine whether a given variable / location is declared.
Definition: PromelaDataModel.cpp:736
virtual Data getAsData(const std::string &content)
Return a string as an unevaluated Data object.
Definition: PromelaDataModel.cpp:267
Definition: Event.h:94
virtual void addExtension(DataModelExtension *ext)
Register an extension to get data into and out of the data-model.
Definition: PromelaDataModel.cpp:765
Callbacks available for every data-model.
Definition: DataModelImpl.h:47
virtual void init(const std::string &location, const Data &data, const std::map< std::string, std::string > &attr=std::map< std::string, std::string >())
Initialize a variable / location in the data-model with a given data object.
Definition: PromelaDataModel.cpp:709
Definition: Data.h:44
virtual void assign(const std::string &location, const Data &data, const std::map< std::string, std::string > &attr=std::map< std::string, std::string >())
Assign a data object to a location in the data-model.
Definition: PromelaDataModel.cpp:700