NullDataModel.h
Go to the documentation of this file.
1 
20 #ifndef NULLDATAMODEL_H_KN8TWG0V
21 #define NULLDATAMODEL_H_KN8TWG0V
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 class Event;
33 class Data;
34 }
35 
36 namespace uscxml {
37 
42 class NullDataModel : public DataModelImpl {
43 public:
44  NullDataModel();
45  virtual ~NullDataModel();
46  virtual std::shared_ptr<DataModelImpl> create(DataModelCallbacks* callbacks);
47 
48  virtual std::list<std::string> getNames() {
49  std::list<std::string> names;
50  names.push_back("null");
51  return names;
52  }
53 
54  virtual bool validate(const std::string& location, const std::string& schema) {
55  return true;
56  }
57  virtual bool isValidSyntax(const std::string& expr) {
58  return true; // overwrite when datamodel supports it
59  }
60  virtual void setEvent(const Event& event) {}
61 
62  size_t replaceExpressions(std::string& content) {
63  return 0;
64  }
65 
66  // foreach
67  virtual uint32_t getLength(const std::string& expr) {
68  return 0;
69  }
70  virtual void setForeach(const std::string& item,
71  const std::string& array,
72  const std::string& index,
73  uint32_t iteration) {}
74 
75  virtual Data getAsData(const std::string& content);
76 
77  virtual Data evalAsData(const std::string& content) {
78  return getAsData(content);
79  }
80  virtual std::string evalAsString(const std::string& expr) {
81  return expr;
82  }
83 
84  virtual bool evalAsBool(const XERCESC_NS::DOMElement* scriptNode,
85  const std::string& expr);
86  virtual bool evalAsBool(const std::string& expr) {
87  return evalAsBool(NULL, expr);
88  }
89 
90  virtual bool isDeclared(const std::string& expr) {
91  return true;
92  }
93 
94  virtual void assign(const std::string& location, const Data& data, const std::map<std::string, std::string>& attr) {}
95  virtual void init(const std::string& location, const Data& data, const std::map<std::string, std::string>& attr) {}
96 
97  virtual void setCallbacks(DataModelCallbacks* callbacks) {
98  _callbacks = callbacks;
99  }
100 
101  virtual void addExtension(DataModelExtension* ext) {}
102 
103 protected:
104 
105 };
106 
107 #ifdef BUILD_AS_PLUGINS
108 PLUMA_INHERIT_PROVIDER(NullDataModel, DataModelImpl)
109 #endif
110 
111 }
112 
113 #endif /* end of include guard: NULLDATAMODEL_H_KN8TWG0V */
NULL data-model.
Definition: NullDataModel.h:42
virtual bool evalAsBool(const XERCESC_NS::DOMElement *scriptNode, const std::string &expr)
The boolean expression language consists of the In predicate only.
Definition: NullDataModel.cpp:65
Definition: Breakpoint.cpp:26
virtual void assign(const std::string &location, const Data &data, const std::map< std::string, std::string > &attr)
Assign a data object to a location in the data-model.
Definition: NullDataModel.h:94
virtual bool isDeclared(const std::string &expr)
Determine whether a given variable / location is declared.
Definition: NullDataModel.h:90
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: NullDataModel.h:70
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: NullDataModel.h:57
virtual uint32_t getLength(const std::string &expr)
Evaluate the given expression as something iterable and return its length.
Definition: NullDataModel.h:67
Definition: Event.h:94
virtual std::shared_ptr< DataModelImpl > create(DataModelCallbacks *callbacks)
The Factory wants to instantiate a new instance.
Definition: NullDataModel.cpp:42
virtual Data getAsData(const std::string &content)
Return a string as an unevaluated Data object.
Definition: NullDataModel.cpp:51
virtual void addExtension(DataModelExtension *ext)
Register an extension to get data into and out of the data-model.
Definition: NullDataModel.h:101
Callbacks available for every data-model.
Definition: DataModelImpl.h:47
virtual Data evalAsData(const std::string &content)
Return a string as an evaluated Data object.
Definition: NullDataModel.h:77
virtual std::list< std::string > getNames()
Return a list of names to be matched by the datamodel attribute in SCXML.
Definition: NullDataModel.h:48
virtual void init(const std::string &location, const Data &data, const std::map< std::string, std::string > &attr)
Initialize a variable / location in the data-model with a given data object.
Definition: NullDataModel.h:95
virtual bool evalAsBool(const std::string &expr)
Evaluate a given expression as a boolean.
Definition: NullDataModel.h:86
Definition: Data.h:44
virtual void setEvent(const Event &event)
Set the given event as _event in the data-model's global scope.
Definition: NullDataModel.h:60