BeeeOn Gateway  v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
GWMessage.h
1 #pragma once
2 
3 #include <string>
4 
5 #include <Poco/SharedPtr.h>
6 #include <Poco/JSON/Object.h>
7 
8 #include "gwmessage/GWMessageType.h"
9 #include "model/GlobalID.h"
10 
11 namespace BeeeOn {
12 
21 class GWMessage {
22 public:
23  typedef Poco::SharedPtr<GWMessage> Ptr;
24 
25  virtual ~GWMessage();
26 
31  void setID(const GlobalID &id);
32 
37  GlobalID id() const;
38 
39 protected:
45  GWMessage(const GWMessageType::Raw &type);
46 
50  GWMessage(const Poco::JSON::Object::Ptr object);
51 
52 public:
56  GWMessageType type() const;
57 
61  std::string toString() const;
62 
66  std::string toBriefString() const;
67 
75  static GWMessage::Ptr fromJSON(const std::string &json);
76 
84  static GWMessage::Ptr fromJSON(Poco::JSON::Object::Ptr object);
85 
86 protected:
87  Poco::JSON::Object::Ptr json() const;
88 
89 private:
90  void setType(const GWMessageType &type);
91 
92 private:
93  Poco::JSON::Object::Ptr m_json;
94 };
95 
96 }
Definition: GlobalID.h:10
std::string toString() const
Returns the string representation of the message.
Definition: GWMessage.cpp:60
The GWMessage is abstract class representing messages (including their contents), that are being sent...
Definition: GWMessage.h:21
GWMessageType type() const
Returns the type of the message.
Definition: GWMessage.cpp:55
GWMessage(const GWMessageType::Raw &type)
Constructs a GWMessage depending on the given type.
Definition: GWMessage.cpp:30
std::string toBriefString() const
Definition: GWMessage.cpp:65
Definition: Enum.h:106
static GWMessage::Ptr fromJSON(const std::string &json)
Factory method for creating subclasses of the GWMessage from the json string.
Definition: GWMessage.cpp:71
void setID(const GlobalID &id)
Set unique identifier intended to match request message with its response.
Definition: GWMessage.cpp:50
GlobalID id() const
Return unique identifier intended to match request message with its response.
Definition: GWMessage.cpp:45