DDS  ver. 2.0
InfoChannel.h
Go to the documentation of this file.
1 // Copyright 2014 GSI, Inc. All rights reserved.
2 //
3 //
4 //
5 
6 #ifndef __DDS__InfoChannel__
7 #define __DDS__InfoChannel__
8 // DDS
9 #include "ClientChannelImpl.h"
10 #include "GetPropValuesCmd.h"
11 #include "Options.h"
12 
13 namespace dds
14 {
15  namespace info_cmd
16  {
17  class CInfoChannel : public protocol_api::CClientChannelImpl<CInfoChannel>
18  {
19  CInfoChannel(boost::asio::io_service& _service, uint64_t _protocolHeaderID = 0)
20  : CClientChannelImpl<CInfoChannel>(_service, protocol_api::EChannelType::UI, _protocolHeaderID)
21  , m_nCounter(0)
22  {
23  registerHandler<protocol_api::EChannelEvents::OnHandshakeOK>(
24  [this](const protocol_api::SSenderInfo& _sender) {
25  // ask the server what we wnated to ask :)
26  if (m_options.m_bNeedCommanderPid || m_options.m_bNeedDDSStatus)
27  pushMsg<protocol_api::cmdGED_PID>();
28  else if (m_options.m_bNeedAgentsNumber || m_options.m_bNeedAgentsList)
29  pushMsg<protocol_api::cmdGET_AGENTS_INFO>();
30  else if (m_options.m_bNeedPropList)
31  pushMsg<protocol_api::cmdGET_PROP_LIST>();
32  else if (m_options.m_bNeedPropValues)
33  {
35  cmd.m_sPropertyID = m_options.m_propertyID;
36  pushMsg<protocol_api::cmdGET_PROP_VALUES>(cmd);
37  }
38  });
39 
40  registerHandler<protocol_api::EChannelEvents::OnConnected>(
41  [](const protocol_api::SSenderInfo& _sender) {
42  LOG(MiscCommon::info) << "Connected to the commander server";
43  });
44 
45  registerHandler<protocol_api::EChannelEvents::OnFailedToConnect>(
46  [](const protocol_api::SSenderInfo& _sender) {
47  LOG(MiscCommon::log_stderr) << "Failed to connect to commander server.";
48  });
49  }
50 
52 
53  public:
55  MESSAGE_HANDLER(cmdSIMPLE_MSG, on_cmdSIMPLE_MSG)
56  MESSAGE_HANDLER(cmdREPLY_PID, on_cmdREPLY_PID)
57  MESSAGE_HANDLER(cmdREPLY_AGENTS_INFO, on_cmdREPLY_AGENTS_INFO)
59 
60  void setOptions(const SOptions& _options)
61  {
62  m_options = _options;
63  }
64 
65  private:
66  // Message Handlers
68  const protocol_api::SSenderInfo& _sender);
70  const protocol_api::SSenderInfo& _sender);
71  bool on_cmdREPLY_AGENTS_INFO(
73  const protocol_api::SSenderInfo& _sender);
74 
75  private:
76  SOptions m_options;
77  std::mutex m_mutexCounter;
78  size_t m_nCounter;
79  };
80  }
81 }
82 #endif
Definition: def.h:156
Definition: BaseEventHandlersImpl.h:48
on_cmdSIMPLE_MSG MESSAGE_HANDLER(cmdREPLY_PID, on_cmdREPLY_PID) MESSAGE_HANDLER(cmdREPLY_AGENTS_INFO
#define REGISTER_DEFAULT_REMOTE_ID_STRING
Definition: BaseChannelImpl.h:171
Definition: ProtocolCommands.h:48
dds-commander&#39;s container of options
Definition: dds-info/src/Options.h:25
Definition: ProtocolDef.h:19
std::shared_ptr< SEmptyCmd > ptr_t
Definition: CommandAttachmentImpl.h:66
bool m_bNeedAgentsList
Definition: dds-info/src/Options.h:42
#define LOG(severity)
Definition: Logger.h:54
BEGIN_MSG_MAP(CInfoChannel) MESSAGE_HANDLER(cmdSIMPLE_MSG
Definition: ProtocolCommands.h:33
on_cmdSIMPLE_MSG on_cmdREPLY_AGENTS_INFO END_MSG_MAP() void setOptions(const SOptions &_options)
Definition: InfoChannel.h:58
Definition: dds-agent/src/AgentConnectionManager.h:18
Definition: GetPropValuesCmd.h:16
bool m_bNeedPropValues
Definition: dds-info/src/Options.h:44
bool m_bNeedAgentsNumber
Definition: dds-info/src/Options.h:41
bool m_bNeedDDSStatus
Definition: dds-info/src/Options.h:40
bool m_bNeedPropList
Definition: dds-info/src/Options.h:43
std::string m_sPropertyID
Definition: GetPropValuesCmd.h:24
std::string m_propertyID
Definition: dds-info/src/Options.h:45
Definition: InfoChannel.h:17
Definition: BaseChannelImpl.h:41
Definition: ProtocolCommands.h:39
bool m_bNeedCommanderPid
Definition: dds-info/src/Options.h:39
Definition: def.h:150