DataModelImpl.h
Go to the documentation of this file.
1 
20 #ifndef DATAMODELIMPL_H_5A33C087
21 #define DATAMODELIMPL_H_5A33C087
22 
23 #include "uscxml/Common.h"
24 #include "uscxml/plugins/Invoker.h"
27 
28 namespace XERCESC_NS {
29 class DOMDocument;
30 class DOMNode;
31 }
32 
33 #include <list>
34 #include <string>
35 #include <memory>
36 
37 namespace uscxml {
38 
39 class InterpreterImpl;
40 class DataModelImpl;
41 
47 class USCXML_API DataModelCallbacks {
48 public:
49  virtual ~DataModelCallbacks() {}
50  virtual const std::string& getName() = 0;
51  virtual const std::string& getSessionId() = 0;
52  virtual const std::map<std::string, IOProcessor>& getIOProcessors() = 0;
53  virtual bool isInState(const std::string& stateId) = 0;
54  virtual XERCESC_NS::DOMDocument* getDocument() const = 0;
55  virtual const std::map<std::string, Invoker>& getInvokers() = 0;
56  virtual Logger getLogger() = 0;
57 };
58 
59 class USCXML_API DataModelExtension {
60 public:
61  DataModelExtension() : dm(NULL) {}
62  virtual ~DataModelExtension() {}
63  virtual std::string provides() = 0;
64  virtual Data invoke(const std::string& member, const Data& params) = 0;
65  virtual Data getValueOf(const std::string& member) = 0;
66  virtual void setValueOf(const std::string& member, const Data& data) = 0;
67  DataModelImpl* dm;
68 };
69 
75 class USCXML_API DataModelImpl {
76 public:
77  virtual ~DataModelImpl() {}
78 
88  virtual std::shared_ptr<DataModelImpl> create(DataModelCallbacks* callbacks) = 0;
89 
93  virtual std::list<std::string> getNames() = 0;
94 
101  virtual bool isValidSyntax(const std::string& expr) {
102  return true; // overwrite when datamodel supports it
103  }
104 
109  virtual void setEvent(const Event& event) = 0;
110 
118  size_t replaceExpressions(std::string& content);
119 
125  virtual uint32_t getLength(const std::string& expr) = 0;
126 
134  virtual void setForeach(const std::string& item,
135  const std::string& array,
136  const std::string& index,
137  uint32_t iteration) = 0;
138 
144  virtual Data getAsData(const std::string& content) = 0;
145 
151  virtual Data evalAsData(const std::string& content) = 0;
152 
159  virtual bool evalAsBool(const std::string& expr) = 0;
160 
166  virtual bool isDeclared(const std::string& expr) = 0;
167 
186  virtual void assign(const std::string& location, const Data& data) = 0;
187 
196  virtual void init(const std::string& location, const Data& data) = 0;
197 
202  virtual void addExtension(DataModelExtension* ext);
203 
209  virtual std::string andExpressions(std::list<std::string>) {
210  return "";
211  }
212 
213 protected:
214  DataModelCallbacks* _callbacks;
215 };
216 
217 }
218 
219 #endif /* end of include guard: DATAMODELIMPL_H_5A33C087 */
virtual std::string andExpressions(std::list< std::string >)
Concat the given terms into a conjunctive form.
Definition: DataModelImpl.h:209
Definition: Breakpoint.cpp:26
virtual ~DataModelCallbacks()
silence virtual destructor warning from swig
Definition: DataModelImpl.h:49
Definition: DataModelImpl.h:59
Abstract base class for all data-model implementations.
Definition: DataModelImpl.h:75
Definition: Event.h:84
Definition: Breakpoint.h:30
Callbacks available for every data-model.
Definition: DataModelImpl.h:47
virtual bool isValidSyntax(const std::string &expr)
Determine whether a given string constitutes valid syntax in the data-model's language.
Definition: DataModelImpl.h:101
Definition: Logging.h:69
Definition: Data.h:43