From 4c0bc407dcdc40580845ea393d651bd31a4e128f Mon Sep 17 00:00:00 2001 From: Vasily Davydov Date: Thu, 18 May 2023 23:16:25 +0300 Subject: [PATCH] event: [#46] prepare event to deprecate map usage --- source/shoh/src/threads/common/Event.h | 35 +++++++++++++++++++++----- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/source/shoh/src/threads/common/Event.h b/source/shoh/src/threads/common/Event.h index 34a242a..35b347d 100644 --- a/source/shoh/src/threads/common/Event.h +++ b/source/shoh/src/threads/common/Event.h @@ -12,7 +12,7 @@ #include typedef short int EventRawData; -const EventRawData ERROR_RETURN = -999; +const EventRawData ERROR_RETURN = -999; // Soon to be depercated class Event { @@ -31,14 +31,14 @@ public: { EventRawData rd; EventType et; - } EventPair; + } EventPair; // Soon to be depercated - Event(Event::EventType type, EventRawData data) + Event(Event::EventType type, EventRawData data) // Soon to be depercated { events.insert({type, data}); } - void inline addData(Event::EventType type, EventRawData data) + void inline addData(Event::EventType type, EventRawData data) // Soon to be depercated { const auto pos = events.find(type); // No duplicates @@ -46,7 +46,7 @@ public: events.insert({type, data}); } - EventRawData getDataOf(Event::EventType e) const + EventRawData getDataOf(Event::EventType e) const // Soon to be depercated { const auto pos = events.find(e); if (pos == events.end()) @@ -54,13 +54,36 @@ public: return pos->second; } - void inline setDataOf(Event::EventType e, EventRawData data) + void inline setDataOf(Event::EventType e, EventRawData data) // Soon to be depercated { events[e] = data; } +/* Event(Event::EventType type, EventRawData data) + { + setEvent(type, data); + } */ + + void setEvent(Event::EventType type, EventRawData data) + { + _type = type; + _data = data; + } + + Event::EventType inline getType() const + { + return _type; + } + + EventRawData inline getData() const + { + return _data; + } + private: std::map events; + Event::EventType _type; + EventRawData _data; };