diff options
author | 2015-11-19 12:35:16 +0200 | |
---|---|---|
committer | 2015-11-19 12:35:16 +0200 | |
commit | a7317d45787669af71ca8c65fd1e51f8a47d2c1e (patch) | |
tree | 2ba3d71c3b9e9815f5b9d6bcc63fe496e19ce8b3 /src/publisher | |
parent | d9ed62e91c83039521b817779b4bc0197cc8151a (diff) |
async events (DP to CP)
Diffstat (limited to 'src/publisher')
-rw-r--r-- | src/publisher/trex_publisher.cpp | 6 | ||||
-rw-r--r-- | src/publisher/trex_publisher.h | 36 |
2 files changed, 8 insertions, 34 deletions
diff --git a/src/publisher/trex_publisher.cpp b/src/publisher/trex_publisher.cpp index 49602708..1afb558a 100644 --- a/src/publisher/trex_publisher.cpp +++ b/src/publisher/trex_publisher.cpp @@ -81,14 +81,14 @@ TrexPublisher::publish_json(const std::string &s){ } void -TrexPublisher::publish_event(TrexPublisherEvent *ev) { +TrexPublisher::publish_event(event_type_e type, const Json::Value &data) { Json::FastWriter writer; Json::Value value; std::string s; value["name"] = "event"; - value["type"] = ev->get_type(); - ev->to_json(value["data"]); + value["type"] = type; + value["data"] = data; s = writer.write(value); publish_json(s); diff --git a/src/publisher/trex_publisher.h b/src/publisher/trex_publisher.h index 7c3fff92..07d06678 100644 --- a/src/publisher/trex_publisher.h +++ b/src/publisher/trex_publisher.h @@ -25,36 +25,6 @@ limitations under the License. #include <string> #include <json/json.h> -/** - * base event type - * - */ -class TrexPublisherEvent { -public: - virtual void to_json(Json::Value &json) = 0; - virtual uint8_t get_type() = 0; - -protected: - enum { - EVENT_PORT_STOPPED = 1 - }; - -}; - -/** - * port stopped transmitting - * - */ -class TrexEventPortStopped : public TrexPublisherEvent { -public: - TrexEventPortStopped(uint8_t port_id); - virtual void to_json(Json::Value &json); - virtual uint8_t get_type() { - return (EVENT_PORT_STOPPED); - } -}; - - class TrexPublisher { public: @@ -68,7 +38,11 @@ public: void Delete(); void publish_json(const std::string &s); - void publish_event(TrexPublisherEvent *ev); + enum event_type_e { + EVENT_PORT_STOPPED = 1 + }; + + void publish_event(event_type_e type, const Json::Value &data); private: void show_zmq_last_error(const std::string &err); |