summaryrefslogtreecommitdiffstats
path: root/src/uscxml/Factory.h
diff options
context:
space:
mode:
authorStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2012-12-20 21:34:09 (GMT)
committerStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2012-12-20 21:34:09 (GMT)
commit498f6f80e9ca01236ca1491596875ab7eb4cd8c3 (patch)
treee627ae19475bb93a98dfa50db1950f6e3403f569 /src/uscxml/Factory.h
parentd779abe6ff76a78f92d229fcf1f006f5cf1f9295 (diff)
downloaduscxml-498f6f80e9ca01236ca1491596875ab7eb4cd8c3.zip
uscxml-498f6f80e9ca01236ca1491596875ab7eb4cd8c3.tar.gz
uscxml-498f6f80e9ca01236ca1491596875ab7eb4cd8c3.tar.bz2
Refactoring finished
Support datamodels, invokers and ioprocessors as plugins Comply to HTTP1.1 by sending host header field Started prolog datamodel
Diffstat (limited to 'src/uscxml/Factory.h')
-rw-r--r--src/uscxml/Factory.h189
1 files changed, 97 insertions, 92 deletions
diff --git a/src/uscxml/Factory.h b/src/uscxml/Factory.h
index fcd907e..6385ba7 100644
--- a/src/uscxml/Factory.h
+++ b/src/uscxml/Factory.h
@@ -11,101 +11,106 @@
#include <set>
namespace uscxml {
-
- // see http://stackoverflow.com/questions/228005/alternative-to-itoa-for-converting-integer-to-string-c
- template <typename T> std::string toStr(T tmp) {
- std::ostringstream out;
- out << tmp;
- return out.str();
- }
-
- template <typename T> T strTo(std::string tmp) {
- T output;
- std::istringstream in(tmp);
- in >> output;
- return output;
- }
-
- class Interpreter;
-
- class ExecutableContent {
- public:
- ExecutableContent() {};
- virtual ExecutableContent* create(Interpreter* interpreter) = 0;
- };
-
- class IOProcessor {
- public:
- IOProcessor() {};
- virtual ~IOProcessor() {};
- virtual IOProcessor* create(Interpreter* interpreter) = 0;
- virtual std::set<std::string> getNames() = 0;
-
- virtual void setInterpreter(Interpreter* interpreter) { _interpreter = interpreter; }
- virtual Data getDataModelVariables() = 0;
- virtual void send(SendRequest& req) = 0;
- protected:
- Interpreter* _interpreter;
- };
-
- class Invoker : public IOProcessor {
- public:
- virtual void invoke(InvokeRequest& req) = 0;
- virtual void sendToParent(SendRequest& req) = 0;
- };
-
- class DataModel {
- public:
- virtual ~DataModel() {}
- virtual DataModel* create(Interpreter* interpreter) = 0;
- virtual std::set<std::string> getNames() = 0;
-
- virtual bool validate(const std::string& location, const std::string& schema) = 0;
- virtual void setEvent(const Event& event) = 0;
- virtual Data getStringAsData(const std::string& content) = 0;
-
- // foreach
- virtual uint32_t getLength(const std::string& expr) = 0;
- virtual void pushContext() = 0;
- virtual void popContext() = 0;
-
- virtual void eval(const std::string& expr) = 0;
- virtual std::string evalAsString(const std::string& expr) = 0;
- virtual bool evalAsBool(const std::string& expr) = 0;
- virtual void assign(const std::string& location, const std::string& expr) = 0;
- virtual void assign(const std::string& location, const Data& data) = 0;
- };
-
- class Factory {
- public:
- void registerIOProcessor(IOProcessor* ioProcessor);
- void registerDataModel(DataModel* dataModel);
- void registerInvoker(Invoker* invoker);
- void registerExecutableContent(const std::string tag, ExecutableContent* executableContent);
-
- static DataModel* getDataModel(const std::string type, Interpreter* interpreter);
- static IOProcessor* getIOProcessor(const std::string type, Interpreter* interpreter);
- static ExecutableContent* getExecutableContent(const std::string tag, Interpreter* interpreter);
- static Invoker* getInvoker(const std::string type, Interpreter* interpreter);
-
- static Factory* getInstance();
-
- std::map<std::string, DataModel*> _dataModels;
- std::map<std::string, IOProcessor*> _ioProcessors;
- std::map<std::string, Invoker*> _invokers;
- std::map<std::string, ExecutableContent*> _executableContent;
-
- static std::string pluginPath;
-
- protected:
+
+// see http://stackoverflow.com/questions/228005/alternative-to-itoa-for-converting-integer-to-string-c
+template <typename T> std::string toStr(T tmp) {
+ std::ostringstream out;
+ out << tmp;
+ return out.str();
+}
+
+template <typename T> T strTo(std::string tmp) {
+ T output;
+ std::istringstream in(tmp);
+ in >> output;
+ return output;
+}
+
+class Interpreter;
+
+class ExecutableContent {
+public:
+ ExecutableContent() {};
+ virtual ExecutableContent* create(Interpreter* interpreter) = 0;
+};
+
+class IOProcessor {
+public:
+ IOProcessor() {};
+ virtual ~IOProcessor() {};
+ virtual IOProcessor* create(Interpreter* interpreter) = 0;
+ virtual std::set<std::string> getNames() = 0;
+
+ virtual void setInterpreter(Interpreter* interpreter) {
+ _interpreter = interpreter;
+ }
+ virtual Data getDataModelVariables() = 0;
+ virtual void send(SendRequest& req) = 0;
+protected:
+ Interpreter* _interpreter;
+};
+
+class Invoker : public IOProcessor {
+public:
+ virtual void invoke(InvokeRequest& req) = 0;
+ virtual void sendToParent(SendRequest& req) = 0;
+};
+
+class DataModel {
+public:
+ virtual ~DataModel() {}
+ virtual DataModel* create(Interpreter* interpreter) = 0;
+ virtual std::set<std::string> getNames() = 0;
+
+ virtual bool validate(const std::string& location, const std::string& schema) = 0;
+ virtual void setEvent(const Event& event) = 0;
+ virtual Data getStringAsData(const std::string& content) = 0;
+
+ virtual void registerIOProcessor(const std::string& name, IOProcessor* ioprocessor) = 0;
+
+ // foreach
+ virtual uint32_t getLength(const std::string& expr) = 0;
+ virtual void pushContext() = 0;
+ virtual void popContext() = 0;
+
+ virtual void eval(const std::string& expr) = 0;
+ virtual std::string evalAsString(const std::string& expr) = 0;
+ virtual bool evalAsBool(const std::string& expr) = 0;
+ virtual void assign(const std::string& location, const std::string& expr) = 0;
+ virtual void assign(const std::string& location, const Data& data) = 0;
+};
+
+class Factory {
+public:
+ void registerIOProcessor(IOProcessor* ioProcessor);
+ void registerDataModel(DataModel* dataModel);
+ void registerInvoker(Invoker* invoker);
+ void registerExecutableContent(const std::string tag, ExecutableContent* executableContent);
+
+ static DataModel* getDataModel(const std::string type, Interpreter* interpreter);
+ static IOProcessor* getIOProcessor(const std::string type, Interpreter* interpreter);
+ static ExecutableContent* getExecutableContent(const std::string tag, Interpreter* interpreter);
+ static Invoker* getInvoker(const std::string type, Interpreter* interpreter);
+
+ static Factory* getInstance();
+
+ std::map<std::string, DataModel*> _dataModels;
+ std::map<std::string, IOProcessor*> _ioProcessors;
+ std::map<std::string, Invoker*> _invokers;
+ std::map<std::string, ExecutableContent*> _executableContent;
+
+ static std::string pluginPath;
+
+protected:
#ifdef BUILD_AS_PLUGINS
- pluma::Pluma pluma;
+ pluma::Pluma pluma;
#endif
-
- Factory();
- static Factory* _instance;
- };
+ Factory();
+ ~Factory();
+ static Factory* _instance;
+
+};
}