diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-06-10 22:47:14 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-06-10 22:47:14 (GMT) |
commit | 6f56474450b7c54f2c95b5dea6a7a42623141649 (patch) | |
tree | 420c52085d8cf778360c09baf9722b21d01259da /src/uscxml/Factory.h | |
parent | a154682fc1b25581742d38dd5fe9aa06ede167b7 (diff) | |
download | uscxml-6f56474450b7c54f2c95b5dea6a7a42623141649.zip uscxml-6f56474450b7c54f2c95b5dea6a7a42623141649.tar.gz uscxml-6f56474450b7c54f2c95b5dea6a7a42623141649.tar.bz2 |
W3C MMI Architecture framework
Diffstat (limited to 'src/uscxml/Factory.h')
-rw-r--r-- | src/uscxml/Factory.h | 108 |
1 files changed, 65 insertions, 43 deletions
diff --git a/src/uscxml/Factory.h b/src/uscxml/Factory.h index 59835b3..d92d105 100644 --- a/src/uscxml/Factory.h +++ b/src/uscxml/Factory.h @@ -103,11 +103,8 @@ protected: }; -class IOProcessorImpl { +class EventHandlerImpl { public: - IOProcessorImpl() {}; - virtual ~IOProcessorImpl() {}; - virtual boost::shared_ptr<IOProcessorImpl> create(InterpreterImpl* interpreter) = 0; virtual std::set<std::string> getNames() = 0; virtual void setInterpreter(InterpreterImpl* interpreter) { @@ -119,48 +116,31 @@ public: void setType(const std::string& type) { _type = type; } - + virtual Data getDataModelVariables() = 0; virtual void send(const SendRequest& req) = 0; - + virtual void runOnMainThread() {}; - void returnEvent(Event& event); - + protected: InterpreterImpl* _interpreter; std::string _invokeId; std::string _type; + }; -class IOProcessor { +class EventHandler { public: - IOProcessor() : _impl() {} - IOProcessor(boost::shared_ptr<IOProcessorImpl> const impl) : _impl(impl) { } - IOProcessor(const IOProcessor& other) : _impl(other._impl) { } - virtual ~IOProcessor() {}; - - operator bool() const { - return _impl; - } - bool operator< (const IOProcessor& other) const { - return _impl < other._impl; - } - bool operator==(const IOProcessor& other) const { - return _impl == other._impl; - } - bool operator!=(const IOProcessor& other) const { - return _impl != other._impl; - } - IOProcessor& operator= (const IOProcessor& other) { - _impl = other._impl; - return *this; - } - + EventHandler() : _impl() {} + EventHandler(boost::shared_ptr<EventHandlerImpl> const impl) : _impl(impl) { } + EventHandler(const EventHandler& other) : _impl(other._impl) { } + virtual ~EventHandler() {}; + virtual std::set<std::string> getNames() { return _impl->getNames(); } - + virtual Data getDataModelVariables() const { return _impl->getDataModelVariables(); }; @@ -170,7 +150,7 @@ public: virtual void runOnMainThread() { return _impl->runOnMainThread(); } - + void setInterpreter(InterpreterImpl* interpreter) { _impl->setInterpreter(interpreter); } @@ -182,21 +162,58 @@ public: } protected: + boost::shared_ptr<EventHandlerImpl> _impl; + friend class InterpreterImpl; +}; + +class IOProcessorImpl : public EventHandlerImpl { +public: + IOProcessorImpl() {}; + virtual ~IOProcessorImpl() {}; + virtual boost::shared_ptr<IOProcessorImpl> create(InterpreterImpl* interpreter) = 0; +}; + +class IOProcessor : public EventHandler { +public: + IOProcessor() : _impl() {} + IOProcessor(boost::shared_ptr<IOProcessorImpl> const impl) : EventHandler(impl), _impl(impl) { } + IOProcessor(const IOProcessor& other) : EventHandler(other._impl), _impl(other._impl) { } + virtual ~IOProcessor() {}; + + operator bool() const { + return _impl; + } + bool operator< (const IOProcessor& other) const { + return _impl < other._impl; + } + bool operator==(const IOProcessor& other) const { + return _impl == other._impl; + } + bool operator!=(const IOProcessor& other) const { + return _impl != other._impl; + } + IOProcessor& operator= (const IOProcessor& other) { + _impl = other._impl; + EventHandler::_impl = _impl; + return *this; + } + +protected: boost::shared_ptr<IOProcessorImpl> _impl; friend class InterpreterImpl; }; -class InvokerImpl : public IOProcessorImpl { +class InvokerImpl : public EventHandlerImpl { public: virtual void invoke(const InvokeRequest& req) = 0; - virtual boost::shared_ptr<IOProcessorImpl> create(InterpreterImpl* interpreter) = 0; + virtual boost::shared_ptr<InvokerImpl> create(InterpreterImpl* interpreter) = 0; }; -class Invoker : public IOProcessor { +class Invoker : public EventHandler { public: Invoker() : _impl() {} - Invoker(boost::shared_ptr<InvokerImpl> const impl) : IOProcessor(impl), _impl(impl) { } - Invoker(const Invoker& other) : IOProcessor(other._impl), _impl(other._impl) { } + Invoker(boost::shared_ptr<InvokerImpl> const impl) : EventHandler(impl), _impl(impl) { } + Invoker(const Invoker& other) : EventHandler(other._impl), _impl(other._impl) { } virtual ~Invoker() {}; operator bool() const { @@ -213,7 +230,7 @@ public: } Invoker& operator= (const Invoker& other) { _impl = other._impl; - IOProcessor::_impl = _impl; + EventHandler::_impl = _impl; return *this; } @@ -352,16 +369,20 @@ protected: class Factory { public: + Factory(Factory* parentFactory); + void registerIOProcessor(IOProcessorImpl* ioProcessor); void registerDataModel(DataModelImpl* dataModel); void registerInvoker(InvokerImpl* invoker); void registerExecutableContent(ExecutableContentImpl* executableContent); - static boost::shared_ptr<DataModelImpl> createDataModel(const std::string& type, InterpreterImpl* interpreter); - static boost::shared_ptr<IOProcessorImpl> createIOProcessor(const std::string& type, InterpreterImpl* interpreter); - static boost::shared_ptr<InvokerImpl> createInvoker(const std::string& type, InterpreterImpl* interpreter); - static boost::shared_ptr<ExecutableContentImpl> createExecutableContent(const std::string& localName, const std::string& nameSpace, InterpreterImpl* interpreter); + boost::shared_ptr<DataModelImpl> createDataModel(const std::string& type, InterpreterImpl* interpreter); + boost::shared_ptr<IOProcessorImpl> createIOProcessor(const std::string& type, InterpreterImpl* interpreter); + boost::shared_ptr<InvokerImpl> createInvoker(const std::string& type, InterpreterImpl* interpreter); + boost::shared_ptr<ExecutableContentImpl> createExecutableContent(const std::string& localName, const std::string& nameSpace, InterpreterImpl* interpreter); + std::map<std::string, IOProcessorImpl*> getIOProcessors(); + static Factory* getInstance(); std::map<std::string, DataModelImpl*> _dataModels; @@ -381,6 +402,7 @@ protected: Factory(); ~Factory(); + Factory* _parentFactory; static Factory* _instance; }; |