hce-node application  1.4.3
HCE Hierarchical Cluster Engine node application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
SphinxOutputJsonMessage.hpp
Go to the documentation of this file.
1 
14 #ifndef SPHINX_OUTPUT_JSON_MESSAGE_HPP
15 #define SPHINX_OUTPUT_JSON_MESSAGE_HPP
16 
17 #include <iostream>
18 
19 #include "JsonSerializable.hpp"
20 
21 namespace HCE
22 {
23 namespace sphinx
24 {
25 //-----------------------------------------------------------------------------
26 namespace output_json_message_const
27 {
28  const std::string errorCode = "error_code";
29  const std::string errorMessage = "error_message";
30  const std::string data = "data";
31  const std::string time = "time";
32 }
33 //-----------------------------------------------------------------------------
35 {
36 public:
37  explicit SphinxOutputJsonMessage(const std::string& json="");
39  virtual ~SphinxOutputJsonMessage(void) {};
40 
41  bool serialize(std::string& json);
42  bool unserialize(const std::string& json);
43 
44  void setErrorCode(unsigned int errorCode_) {errorCode=errorCode_;}
45  unsigned int getErrorCode(void) const {return errorCode;}
46 
47  void setErrorMessage(const std::string& errorMessage_) {errorMessage=errorMessage_;}
48  std::string getErrorMessage(void) const {return errorMessage;}
49 
50  void setData(const std::string& data_) {data=data_;}
51  std::string getData(void) const {return data;}
52 
53  void setTime(unsigned int time_) {time=time_;}
54  unsigned int getTime(void) const {return time;}
55 
56  void clear(void);
58 private:
59  unsigned int errorCode; // error code: 0 - successful, otherwise return really internal code of errors
60  std::string errorMessage; // message about error if need or empty
61  std::string data; // json object
62  unsigned int time; // value in msec !!!
63 
64 private:
65  friend std::istream& operator>>(std::istream& is, SphinxOutputJsonMessage& jsonHandler);
66  friend std::ostream& operator<<(std::ostream& os, const SphinxOutputJsonMessage& jsonHandler);
67  typedef IJsonSerializable inherited;
68 };
69 //-----------------------------------------------------------------------------
70 //-----------------------------------------------------------------------------
71 } // end namespace sphinx
72 } // end namespace HCE
73 
74 #endif // SPHINX_OUTPUT_JSON_MESSAGE_HPP