diff options
author | Stefan Radomski <github@mintwerk.de> | 2017-06-08 09:52:27 (GMT) |
---|---|---|
committer | Stefan Radomski <github@mintwerk.de> | 2017-06-08 09:52:27 (GMT) |
commit | e9b78b546baf50149d121c96df823d44a709a97c (patch) | |
tree | 22fd3f72bf2a43ee78ca5e4fd27e1c130b3e5dc0 /src/uscxml/messages | |
parent | cdc9c7da381aa296dc48c2494adcf9ca941d0851 (diff) | |
download | uscxml-e9b78b546baf50149d121c96df823d44a709a97c.zip uscxml-e9b78b546baf50149d121c96df823d44a709a97c.tar.gz uscxml-e9b78b546baf50149d121c96df823d44a709a97c.tar.bz2 |
Performance improvements
Diffstat (limited to 'src/uscxml/messages')
-rw-r--r-- | src/uscxml/messages/Event.cpp | 6 | ||||
-rw-r--r-- | src/uscxml/messages/Event.h | 16 |
2 files changed, 19 insertions, 3 deletions
diff --git a/src/uscxml/messages/Event.cpp b/src/uscxml/messages/Event.cpp index 5b933dc..a7863c5 100644 --- a/src/uscxml/messages/Event.cpp +++ b/src/uscxml/messages/Event.cpp @@ -21,6 +21,12 @@ namespace uscxml { +Event::Event() : eventType(INTERNAL), hideSendId(false) { +} + +Event::Event(const std::string& name, Type type) : name(name), eventType(type), hideSendId(false) { +} + Event Event::fromData(const Data& data) { Event e; if (data.hasKey("data")) diff --git a/src/uscxml/messages/Event.h b/src/uscxml/messages/Event.h index f40a672..c4d818b 100644 --- a/src/uscxml/messages/Event.h +++ b/src/uscxml/messages/Event.h @@ -107,8 +107,8 @@ public: PLATFORM = 3 }; - Event() : eventType(INTERNAL), hideSendId(false), uuid(UUID::getUUID()) {} - explicit Event(const std::string& name, Type type = INTERNAL) : name(name), eventType(type), hideSendId(false) {} + Event(); + explicit Event(const std::string& name, Type type = INTERNAL); static Event fromData(const Data& data); bool operator< (const Event& other) const { @@ -197,6 +197,14 @@ public: return false; } + const std::string& getUUID() const { + // this is expensive - lazy initialization + if (uuid.length() == 0) { + uuid = UUID::getUUID(); + } + return uuid; + } + std::string raw; std::string name; Type eventType; @@ -208,7 +216,9 @@ public: Data data; std::map<std::string, Data> namelist; std::multimap<std::string, Data> params; - std::string uuid; // the sendid is not necessarily unique! + +private: + mutable std::string uuid; // the sendid is not necessarily unique! friend USCXML_API std::ostream& operator<< (std::ostream& os, const Event& event); }; |