From a7317d45787669af71ca8c65fd1e51f8a47d2c1e Mon Sep 17 00:00:00 2001 From: imarom Date: Thu, 19 Nov 2015 12:35:16 +0200 Subject: async events (DP to CP) --- src/publisher/trex_publisher.cpp | 6 +++--- src/publisher/trex_publisher.h | 36 +++++------------------------------- 2 files changed, 8 insertions(+), 34 deletions(-) (limited to 'src/publisher') 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 #include -/** - * 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); -- cgit 1.2.3-korg