diff options
Diffstat (limited to 'src/uscxml/plugins/invoker/heartbeat')
-rw-r--r-- | src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.cpp | 80 | ||||
-rw-r--r-- | src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.h | 16 |
2 files changed, 48 insertions, 48 deletions
diff --git a/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.cpp b/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.cpp index 65eed78..a983d58 100644 --- a/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.cpp +++ b/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.cpp @@ -36,58 +36,58 @@ void HeartbeatInvoker::send(const SendRequest& req) { } void HeartbeatInvoker::cancel(const std::string sendId) { - HeartbeatDispatcher::getInstance()->cancelEvent(toStr(this)); + HeartbeatDispatcher::getInstance()->cancelEvent(toStr(this)); } void HeartbeatInvoker::sendToParent(const SendRequest& req) { } void HeartbeatInvoker::invoke(const InvokeRequest& req) { - _invokeId = req.invokeid; - _event.invokeid = _invokeId; - std::string intervalStr; - double interval = 0; - unsigned long intervalMs = 0; - InvokeRequest::params_t::const_iterator paramIter = req.params.begin(); - while(paramIter != req.params.end()) { - if (boost::iequals(paramIter->first, "interval")) { - intervalStr = paramIter->second; - NumAttr intervalAttr(paramIter->second); - interval = strTo<double>(intervalAttr.value); - if (false) { - } else if (boost::iequals(intervalAttr.unit, "s")) { - intervalMs = interval * 1000; - } else if (boost::iequals(intervalAttr.unit, "ms")) { - intervalMs = interval; - } else { - intervalMs = interval; - } - } - if (boost::iequals(paramIter->first, "eventname")) { - _event.name = paramIter->second; - } - paramIter++; - } - if (_event.name.length() == 0) - _event.name = std::string("heartbeat." + intervalStr); - - if (intervalMs > 0) { - HeartbeatDispatcher::getInstance()->addEvent(toStr(this), HeartbeatInvoker::dispatch, intervalMs, this, true); - } + _invokeId = req.invokeid; + _event.invokeid = _invokeId; + std::string intervalStr; + double interval = 0; + unsigned long intervalMs = 0; + InvokeRequest::params_t::const_iterator paramIter = req.params.begin(); + while(paramIter != req.params.end()) { + if (boost::iequals(paramIter->first, "interval")) { + intervalStr = paramIter->second; + NumAttr intervalAttr(paramIter->second); + interval = strTo<double>(intervalAttr.value); + if (false) { + } else if (boost::iequals(intervalAttr.unit, "s")) { + intervalMs = interval * 1000; + } else if (boost::iequals(intervalAttr.unit, "ms")) { + intervalMs = interval; + } else { + intervalMs = interval; + } + } + if (boost::iequals(paramIter->first, "eventname")) { + _event.name = paramIter->second; + } + paramIter++; + } + if (_event.name.length() == 0) + _event.name = std::string("heartbeat." + intervalStr); + + if (intervalMs > 0) { + HeartbeatDispatcher::getInstance()->addEvent(toStr(this), HeartbeatInvoker::dispatch, intervalMs, this, true); + } } void HeartbeatInvoker::dispatch(void* instance, std::string name) { - HeartbeatInvoker* invoker = (HeartbeatInvoker*)instance; - invoker->_interpreter->receive(invoker->_event); + HeartbeatInvoker* invoker = (HeartbeatInvoker*)instance; + invoker->_interpreter->receive(invoker->_event); } - + HeartbeatDispatcher* HeartbeatDispatcher::_instance = NULL; HeartbeatDispatcher* HeartbeatDispatcher::getInstance() { - if (_instance == NULL) { - _instance = new HeartbeatDispatcher(); - _instance->start(); - } - return _instance; + if (_instance == NULL) { + _instance = new HeartbeatDispatcher(); + _instance->start(); + } + return _instance; } HeartbeatDispatcher::HeartbeatDispatcher() {} diff --git a/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.h b/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.h index 4b230c1..a7f3cbd 100644 --- a/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.h +++ b/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.h @@ -28,22 +28,22 @@ public: virtual void invoke(const InvokeRequest& req); virtual void sendToParent(const SendRequest& req); - static void dispatch(void* instance, std::string name); - + static void dispatch(void* instance, std::string name); + protected: std::string _invokeId; - Event _event; - + Event _event; + }; class HeartbeatDispatcher : public DelayedEventQueue { public: - static HeartbeatDispatcher* getInstance(); + static HeartbeatDispatcher* getInstance(); protected: - static HeartbeatDispatcher* _instance; - HeartbeatDispatcher(); + static HeartbeatDispatcher* _instance; + HeartbeatDispatcher(); }; - + #ifdef BUILD_AS_PLUGINS PLUMA_INHERIT_PROVIDER(HeartbeatInvoker, InvokerImpl); #endif |