hce-node application  1.4.3
HCE Hierarchical Cluster Engine node application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
CustomMessage.hpp
Go to the documentation of this file.
1 
14 #ifndef CUSTOM_MESSAGE_HPP
15 #define CUSTOM_MESSAGE_HPP
16 
17 #include <sstream>
18 
19 #include "MessagesCollection.hpp"
20 
21 namespace HCE
22 {
23 //-----------------------------------------------------------------------------
25 {
26 public:
27  struct MsgConst
28  {
29  MsgConst(void) {}
30  MsgConst(char space_, char point_, char delimiter_) : space(space_), point(point_), delimiter(delimiter_) {}
31 
32  char space = ' ';
33  char point = '.';
34  char delimiter = ':';
35  };
36 public:
37  explicit CustomMessage(MessagesCollection& collection);
38  CustomMessage(const CustomMessage& rhs);
40  virtual ~CustomMessage(void);
41 
44 
45  void setMsgConst(const MsgConst& msgConst);
46  const MsgConst& getMsgConst(void) const {return msgConst;}
47 
48  std::string operator()(unsigned int type);
49 
50  template<class T>
51  std::string operator()(unsigned int type, const T& t)
52  {
53  std::stringstream outMsg;
54  outMsg << t;
55  return makeMessage(type, outMsg.str());
56  }
57 
58  const MessagesCollection getMessagesCollection(void) const {return collection;}
59 private:
60  std::string makeMessage(unsigned int type);
61  std::string makeMessage(unsigned int type, const std::string& arg);
62 
63  MsgConst msgConst;
64  MessagesCollection collection;
65 };
66 //-----------------------------------------------------------------------------
67 //-----------------------------------------------------------------------------
68 } // end namespace HCE
69 
70 #endif // CUSTOM_MESSAGE_HPP