hce-node application  1.4.3
HCE Hierarchical Cluster Engine node application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
CustomMessage.cpp
Go to the documentation of this file.
1 #include <sstream>
2 
3 #include "CustomMessage.hpp"
4 
5 namespace HCE
6 {
7 //-----------------------------------------------------------------------------
9 : msgConst(), collection(collection_)
10 {
11 }
12 //-----------------------------------------------------------------------------
14 : msgConst(), collection()
15 {
16  (*this) = rhs;
17 }
18 //-----------------------------------------------------------------------------
20 : msgConst(), collection()
21 {
22  (*this) = std::forward<CustomMessage>(rhs);
23 }
24 //-----------------------------------------------------------------------------
26 {
27 }
28 //-----------------------------------------------------------------------------
30 {
31  if (this != &rhs)
32  {
33  setMsgConst(rhs.getMsgConst());
34  collection = rhs.getMessagesCollection();
35  }
36  return *this;
37 }
38 //-----------------------------------------------------------------------------
40 {
41  if (this != &rhs)
42  {
43  setMsgConst(std::move(rhs.getMsgConst()));
44  collection = std::move(rhs.getMessagesCollection());
45  }
46  return *this;
47 }
48 //-----------------------------------------------------------------------------
49 void CustomMessage::setMsgConst(const MsgConst& msgConst_)
50 {
51  msgConst.space = msgConst_.space;
52  msgConst.point = msgConst_.point;
53  msgConst.delimiter = msgConst_.delimiter;
54 }
55 //-----------------------------------------------------------------------------
56 std::string CustomMessage::makeMessage(unsigned int type)
57 {
58  std::ostringstream outMsg;
59  outMsg << collection.getMessage(type) << msgConst.point << msgConst.space;
60  return outMsg.str();
61 }
62 //-----------------------------------------------------------------------------
63 std::string CustomMessage::makeMessage(unsigned int type, const std::string& arg)
64 {
65  std::ostringstream outMsg;
66  outMsg << collection.getMessage(type);
67  if (!outMsg.str().empty() && !arg.empty())
68  outMsg << msgConst.delimiter << msgConst.space << arg << msgConst.space;
69  return outMsg.str();
70 }
71 //-----------------------------------------------------------------------------
72 std::string CustomMessage::operator()(unsigned int type)
73 {
74  return makeMessage(type);
75 }
76 //-----------------------------------------------------------------------------
77 //-----------------------------------------------------------------------------
78 
79 } // end namespace HCE