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 #ifndef NO_XERCESC
55  virtual XERCESC_NS::DOMDocument* getDocument() const = 0;
56 #endif
57  virtual const std::map<std::string, Invoker>& getInvokers() = 0;
58  virtual Logger getLogger() = 0;
59 };
60 
61 class USCXML_API DataModelExtension {
62 public:
63  DataModelExtension() : dm(NULL) {}
64  virtual ~DataModelExtension() {}
65  virtual std::string provides() = 0;
66  virtual Data invoke(const std::string& member, const Data& params) = 0;
67  virtual Data getValueOf(const std::string& member) = 0;
68  virtual void setValueOf(const std::string& member, const Data& data) = 0;
69  DataModelImpl* dm;
70 };
71 
77 class USCXML_API DataModelImpl {
78 public:
79  virtual ~DataModelImpl() {}
80 
90  virtual std::shared_ptr<DataModelImpl> create(DataModelCallbacks* callbacks) = 0;
91 
95  virtual std::list<std::string> getNames() = 0;
96 
103  virtual bool isValidSyntax(const std::string& expr) {
104  return true; // overwrite when datamodel supports it
105  }
106 
111  virtual void setEvent(const Event& event) = 0;
112 
120  size_t replaceExpressions(std::string& content);
121 
127  virtual uint32_t getLength(const std::string& expr) = 0;
128 
136  virtual void setForeach(const std::string& item,
137  const std::string& array,
138  const std::string& index,
139  uint32_t iteration) = 0;
140 
146  virtual Data getAsData(const std::string& content) = 0;
147 
153  virtual Data evalAsData(const std::string& content) = 0;
154 
161  virtual bool evalAsBool(const std::string& expr) = 0;
162 
168  virtual bool isDeclared(const std::string& expr) = 0;
169 
189  virtual void assign(const std::string& location,
190  const Data& data,
191  const std::map<std::string, std::string>& attr = std::map<std::string, std::string>()) = 0;
192 
202  virtual void init(const std::string& location,
203  const Data& data,
204  const std::map<std::string, std::string>& attr = std::map<std::string, std::string>()) = 0;
205 
210  virtual void addExtension(DataModelExtension* ext);
211 
212 protected:
213  DataModelCallbacks* _callbacks;
214 };
215 
216 }
217 
218 #endif /* end of include guard: DATAMODELIMPL_H_5A33C087 */
Definition: Breakpoint.cpp:26
virtual ~DataModelCallbacks()
silence virtual destructor warning from swig
Definition: DataModelImpl.h:49
Definition: DataModelImpl.h:61
Abstract base class for all data-model implementations.
Definition: DataModelImpl.h:77
Definition: Event.h:94
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:103
Definition: Logging.h:69
Definition: Data.h:44