hce-node application  1.4.3
HCE Hierarchical Cluster Engine node application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
JsonMessageCover.hpp
Go to the documentation of this file.
1 
14 #ifndef JSON_MESSAGE_COVER_HPP
15 #define JSON_MESSAGE_COVER_HPP
16 
17 #include "JsonSerializable.hpp"
18 #include "MessageType.hpp"
19 
20 namespace HCE
21 {
22 //-----------------------------------------------------------------------------
23 namespace jsonMessageCoverConst
24 {
25  const std::string messageType = "type";
26  const std::string messageBody = "data";
27  const std::string messageTTL = "ttl";
28  const unsigned int defaultTTLValue = 1;
29 }
30 //-----------------------------------------------------------------------------
32 {
33 public:
34  enum ErrorCode
35  {
39  };
40 public:
41  explicit JsonMessageCover(const std::string& json="");
42 
44  const std::string& messageBody_,
46 
47  JsonMessageCover(unsigned int messageType_,
48  const std::string& messageBody_,
50 
51  virtual ~JsonMessageCover(void) {};
52 
53  bool serialize(std::string& json);
54  bool unserialize(const std::string& json);
55 
56  void setType(unsigned int messageType_) {messageType=static_cast<types::MessageType>(messageType_);}
57  void setType(types::MessageType messageType_) {messageType=messageType_;}
58  types::MessageType getType(void) const {return messageType;}
59 
60  void setData(const std::string& messageBody_) {messageBody=messageBody_;}
61  std::string getData(void) const {return messageBody;}
62 
63  void setTTL(unsigned int ttl) {messageTTL=ttl;}
64  unsigned int getTTL(void) const {return messageTTL;}
65 private:
66  types::MessageType messageType;
67  std::string messageBody;
68  unsigned int messageTTL;
69 
70 private:
71  friend std::istream& operator>>(std::istream& is, HCE::JsonMessageCover& jsonHandler);
72  friend std::ostream& operator<<(std::ostream& os, const HCE::JsonMessageCover& jsonHandler);
73  typedef HCE::IJsonSerializable inherited;
74 };
75 //-----------------------------------------------------------------------------
76 //-----------------------------------------------------------------------------
77 } // end namespace HCE
78 
79 #endif // JSON_MESSAGE_COVER_HPP