DDS  ver. 3.5.3.8.g5fe284b
ToolsProtocol.h
Go to the documentation of this file.
1 // Copyright 2019 GSI, Inc. All rights reserved.
2 //
3 //
4 //
5 
6 #ifndef DDS_TOOLSPROTOCOL_H
7 #define DDS_TOOLSPROTOCOL_H
8 
9 // STD
10 #include <chrono>
11 #include <ostream>
12 #include <string>
14 #include <boost/property_tree/ptree.hpp>
15 // DDS
16 #include "Intercom.h"
17 #include "ToolsProtocolCore.h"
18 
19 namespace dds
20 {
21  namespace tools_api
22  {
24  DDS_TOOLS_DECLARE_DATA_CLASS(SBaseResponseData, SDoneResponseData, "done")
25 
26 
27  struct SMessageResponseData : SBaseResponseData<SMessageResponseData>
28  {
29  std::string m_msg;
31 
32  private:
33  friend SBaseData<SMessageResponseData>;
34  friend SBaseResponseData<SMessageResponseData>;
35  void _fromPT(const boost::property_tree::ptree& _pt);
36  void _toPT(boost::property_tree::ptree& _pt) const;
37  static constexpr const char* _protocolTag = "message";
38 
39  public:
41  bool operator==(const SMessageResponseData& _val) const;
43  friend std::ostream& operator<<(std::ostream& _os, const SMessageResponseData& _data);
44  };
45 
47  struct SProgressResponseData : SBaseResponseData<SProgressResponseData>
48  {
49  uint32_t m_completed = 0;
50  uint32_t m_total = 0;
51  uint32_t m_errors = 0;
52  uint32_t m_time = 0;
53  uint16_t m_srcCommand = 0;
54 
57  uint16_t _srcCmd, uint32_t _completed, uint32_t _total, uint32_t _errors, uint32_t _time = 0);
58 
59  private:
62  void _fromPT(const boost::property_tree::ptree& _pt);
63  void _toPT(boost::property_tree::ptree& _pt) const;
64  static constexpr const char* _protocolTag = "progress";
65 
66  public:
68  bool operator==(const SProgressResponseData& _val) const;
70  friend std::ostream& operator<<(std::ostream& _os, const SProgressResponseData& _data);
71  };
72 
74  struct SSubmitRequestData : SBaseRequestData<SSubmitRequestData>
75  {
76  std::string m_rms;
77  uint32_t m_instances = 0;
78  uint32_t m_slots = 0;
79  std::string m_config;
80  std::string m_pluginPath;
81 
82  private:
84  void _fromPT(const boost::property_tree::ptree& _pt);
85  void _toPT(boost::property_tree::ptree& _pt) const;
86  static constexpr const char* _protocolTag = "submit";
87 
88  public:
90  bool operator==(const SSubmitRequestData& _val) const;
92  friend std::ostream& operator<<(std::ostream& _os, const SSubmitRequestData& _data);
93  };
94 
97 
99  struct STopologyRequestData : SBaseResponseData<STopologyRequestData>
100  {
101  enum class EUpdateType : uint8_t
102  {
103  UPDATE = 0,
104  ACTIVATE,
105  STOP
106  };
108  std::string m_topologyFile;
109  bool m_disableValidation = false;
110 
111  private:
113  void _fromPT(const boost::property_tree::ptree& _pt);
114  void _toPT(boost::property_tree::ptree& _pt) const;
115  static constexpr const char* _protocolTag = "topology";
116 
117  public:
119  bool operator==(const STopologyRequestData& _val) const;
121  friend std::ostream& operator<<(std::ostream& _os, const STopologyRequestData& _data);
122  };
123 
126 
128  DDS_TOOLS_DECLARE_DATA_CLASS(SBaseRequestData, SGetLogRequestData, "getlog")
129 
130 
131  using SGetLogRequest = SBaseRequestImpl<SGetLogRequestData, SEmptyResponseData>;
132 
135  {
136  pid_t m_pid = 0;
137  std::string m_activeTopologyName;
138  std::string m_activeTopologyPath;
139 
140  private:
143  void _fromPT(const boost::property_tree::ptree& _pt);
144  void _toPT(boost::property_tree::ptree& _pt) const;
145  static constexpr const char* _protocolTag = "commanderInfo";
146 
147  public:
149  bool operator==(const SCommanderInfoResponseData& _val) const;
151  friend std::ostream& operator<<(std::ostream& _os, const SCommanderInfoResponseData& _data);
152  };
153 
155  DDS_TOOLS_DECLARE_DATA_CLASS(SBaseRequestData, SCommanderInfoRequestData, "commanderInfo")
156 
157 
158  using SCommanderInfoRequest = SBaseRequestImpl<SCommanderInfoRequestData, SCommanderInfoResponseData>;
159 
162  {
163  uint32_t m_index{ 0 };
164  uint64_t m_agentID{ 0 };
165  std::chrono::milliseconds m_startUpTime{ std::chrono::milliseconds(0) };
166  std::string m_username;
167  std::string m_host;
168  std::string m_DDSPath;
169  uint32_t m_agentPid{ 0 };
170  uint32_t m_nSlots{ 0 };
171 
172  private:
175  void _fromPT(const boost::property_tree::ptree& _pt);
176  void _toPT(boost::property_tree::ptree& _pt) const;
177  static constexpr const char* _protocolTag = "agentInfo";
178 
179  public:
181  bool operator==(const SAgentInfoResponseData& _val) const;
183  friend std::ostream& operator<<(std::ostream& _os, const SAgentInfoResponseData& _data);
184  };
185 
187  DDS_TOOLS_DECLARE_DATA_CLASS(SBaseRequestData, SAgentInfoRequestData, "agentInfo")
188 
189 
190  using SAgentInfoRequest = SBaseRequestImpl<SAgentInfoRequestData, SAgentInfoResponseData>;
191 
194  {
195  uint32_t m_activeSlotsCount = 0;
196  uint32_t m_idleSlotsCount = 0;
197  uint32_t m_executingSlotsCount = 0;
198 
199  private:
202  void _fromPT(const boost::property_tree::ptree& _pt);
203  void _toPT(boost::property_tree::ptree& _pt) const;
204  static constexpr const char* _protocolTag = "agentCount";
205 
206  public:
208  bool operator==(const SAgentCountResponseData& _val) const;
210  friend std::ostream& operator<<(std::ostream& _os, const SAgentCountResponseData& _data);
211  };
212 
214  DDS_TOOLS_DECLARE_DATA_CLASS(SBaseRequestData, SAgentCountRequestData, "agentCount")
215 
216 
217  using SAgentCountRequest = SBaseRequestImpl<SAgentCountRequestData, SAgentCountResponseData>;
218 
219  } // namespace tools_api
220 } // namespace dds
221 
222 #endif /* DDS_TOOLSPROTOCOL_H */
std::string m_rms
RMS.
Definition: ToolsProtocol.h:76
EUpdateType m_updateType
Topology update type: Update, Activate, Stop.
Definition: ToolsProtocol.h:107
uint16_t m_srcCommand
Reserved for internal use.
Definition: ToolsProtocol.h:53
bool operator==(const STopologyRequestData &_val) const
Equality operator.
Definition: ToolsProtocol.cpp:211
uint32_t m_slots
Definition: ToolsProtocol.h:78
std::string m_DDSPath
DDS path.
Definition: ToolsProtocol.h:168
friend std::ostream & operator<<(std::ostream &_os, const STopologyRequestData &_data)
Ostream operator.
Definition: ToolsProtocol.cpp:224
SProgressResponseData()
Definition: ToolsProtocol.cpp:28
friend std::ostream & operator<<(std::ostream &_os, const SProgressResponseData &_data)
Ostream operator.
Definition: ToolsProtocol.cpp:73
Definition: ToolsProtocolCore.h:192
EUpdateType
Definition: ToolsProtocol.h:101
std::string m_activeTopologyPath
Filepath of active topology, empty if none is active.
Definition: ToolsProtocol.h:138
Definition: ToolsProtocolCore.h:188
std::string m_host
Hostname.
Definition: ToolsProtocol.h:167
Structure holds information of agentCount response.
Definition: ToolsProtocol.h:193
Structure holds information of commanderInfo response.
Definition: ToolsProtocol.h:134
uint32_t m_time
Definition: ToolsProtocol.h:52
Structure holds information of a submit request.
Definition: ToolsProtocol.h:74
Definition: AgentConnectionManager.h:13
std::string m_activeTopologyName
Name of active topology, empty if none is active.
Definition: ToolsProtocol.h:137
Definition: ToolsProtocolCore.h:224
bool operator==(const SProgressResponseData &_val) const
Equality operator.
Definition: ToolsProtocol.cpp:60
Structure holds information of a done response.
Definition: ToolsProtocol.h:47
std::string m_config
< Number of task slots.
Definition: ToolsProtocol.h:79
uint32_t m_errors
Definition: ToolsProtocol.h:51
friend std::ostream & operator<<(std::ostream &_os, const SSubmitRequestData &_data)
Ostream operator.
Definition: ToolsProtocol.cpp:181
std::string m_pluginPath
Optional. A plug-in's directory search path.
Definition: ToolsProtocol.h:80
Structure holds information of agentInfo response.
Definition: ToolsProtocol.h:161
uint32_t m_instances
Number of instances.
Definition: ToolsProtocol.h:77
EMsgSeverity
Enumeration with message severity.
Definition: Intercom.h:126
bool operator==(const SChannelInfo< T > &lhs, const SChannelInfo< T > &rhs)
Definition: ChannelInfo.h:32
Structure holds information of topology request.
Definition: ToolsProtocol.h:99
Definition: ToolsProtocolCore.h:183
bool operator==(const SSubmitRequestData &_val) const
Equality operator.
Definition: ToolsProtocol.cpp:168
uint32_t m_total
Definition: ToolsProtocol.h:50
uint32_t m_completed
Definition: ToolsProtocol.h:49
std::string m_username
Username.
Definition: ToolsProtocol.h:166
bool m_disableValidation
A flag to disiable topology validation before processing it.
Definition: ToolsProtocol.h:109
std::string m_topologyFile
A topology file to process.
Definition: ToolsProtocol.h:108
std::ostream & operator<<(std::ostream &_os, const SProgressResponseData &_data)
Definition: ToolsProtocol.cpp:73
DDS_TOOLS_DECLARE_DATA_CLASS(SBaseRequestData, SGetLogRequestData, "getlog") using SGetLogRequest
Structure holds information of a getlog request.