C89DataModel.h
Go to the documentation of this file.
1 
20 #ifndef C89DATAMODEL_H_A0FF45FA
21 #define C89DATAMODEL_H_A0FF45FA
22 
24 #include <list>
25 
26 #define UNIX_HOST
27 #define PICOC_STACK_SIZE (128*1024) /* space for the the stack */
28 
29 extern "C" {
30 #include "picoc.h"
31 #undef min
32 }
33 
34 #ifdef BUILD_AS_PLUGINS
35 #include "uscxml/plugins/Plugins.h"
36 #endif
37 
38 
39 namespace uscxml {
40 class Event;
41 class Data;
42 }
43 
44 namespace uscxml {
45 
51 class C89DataModel : public DataModelImpl {
52 public:
53  C89DataModel();
54  virtual ~C89DataModel();
55  virtual std::shared_ptr<DataModelImpl> create(DataModelCallbacks* callbacks);
56 
57  virtual void addExtension(DataModelExtension* ext);
58 
59  virtual std::list<std::string> getNames() {
60  std::list<std::string> names;
61  names.push_back("c89");
62  names.push_back("ansi-c");
63  return names;
64  }
65 
66  virtual bool isValidSyntax(const std::string& expr);
67 
68  virtual void setEvent(const Event& event);
69 
70  // foreach
71  virtual uint32_t getLength(const std::string& expr);
72  virtual void setForeach(const std::string& item,
73  const std::string& array,
74  const std::string& index,
75  uint32_t iteration);
76 
77  virtual bool evalAsBool(const std::string& expr);
78  virtual Data evalAsData(const std::string& expr);
79  virtual Data getAsData(const std::string& content);
80 
81  virtual bool isDeclared(const std::string& expr);
82 
83  virtual void assign(const std::string& location, const Data& data);
84  virtual void init(const std::string& location, const Data& data);
85 
86  virtual std::string andExpressions(std::list<std::string>);
87 
88 protected:
89  Picoc _pc;
90 };
91 
92 #ifdef BUILD_AS_PLUGINS
93 PLUMA_INHERIT_PROVIDER(C89DataModel, DataModelImpl);
94 #endif
95 
96 }
97 
98 #endif /* end of include guard: C89DATAMODEL_H_A0FF45FA */
virtual bool evalAsBool(const std::string &expr)
Evaluate a given expression as a boolean.
Definition: C89DataModel.cpp:83
virtual std::shared_ptr< DataModelImpl > create(DataModelCallbacks *callbacks)
The Factory wants to instantiate a new instance.
Definition: C89DataModel.cpp:35
Definition: Breakpoint.cpp:26
virtual Data getAsData(const std::string &content)
Return a string as an unevaluated Data object.
Definition: C89DataModel.cpp:87
virtual uint32_t getLength(const std::string &expr)
Evaluate the given expression as something iterable and return its length.
Definition: C89DataModel.cpp:62
C89 (ANSI-C) data-model.
Definition: C89DataModel.h:51
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: C89DataModel.cpp:66
virtual void setEvent(const Event &event)
Set the given event as _event in the data-model's global scope.
Definition: C89DataModel.cpp:50
virtual void addExtension(DataModelExtension *ext)
Register an extension to get data into and out of the data-model.
Definition: C89DataModel.cpp:46
virtual std::list< std::string > getNames()
Return a list of names to be matched by the datamodel attribute in SCXML.
Definition: C89DataModel.h:59
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: C89DataModel.cpp:58
Definition: Event.h:94
Callbacks available for every data-model.
Definition: DataModelImpl.h:47
virtual bool isDeclared(const std::string &expr)
Determine whether a given variable / location is declared.
Definition: C89DataModel.cpp:72
Definition: Data.h:44
virtual Data evalAsData(const std::string &expr)
Return a string as an evaluated Data object.
Definition: C89DataModel.cpp:53