DDS  ver. 1.6
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)
20  : CClientChannelImpl<CInfoChannel>(_service, protocol_api::EChannelType::UI)
21  , m_nCounter(0)
22  {
24  // ask the server what we wnated to ask :)
25  if (m_options.m_bNeedCommanderPid || m_options.m_bNeedDDSStatus)
26  pushMsg<protocol_api::cmdGED_PID>();
27  else if (m_options.m_bNeedAgentsNumber || m_options.m_bNeedAgentsList)
28  pushMsg<protocol_api::cmdGET_AGENTS_INFO>();
29  else if (m_options.m_bNeedPropList)
30  pushMsg<protocol_api::cmdGET_PROP_LIST>();
31  else if (m_options.m_bNeedPropValues)
32  {
33  protocol_api::SGetPropValuesCmd cmd;
34  cmd.m_sPropertyID = m_options.m_propertyID;
35  pushMsg<protocol_api::cmdGET_PROP_VALUES>(cmd);
36  }
37  });
38 
40  LOG(MiscCommon::info) << "Connected to the commander server";
41  });
42 
44  LOG(MiscCommon::log_stderr) << "Failed to connect to commander server.";
45  });
46  }
47 
49 
50  public:
52  MESSAGE_HANDLER(cmdSIMPLE_MSG, on_cmdSIMPLE_MSG)
53  MESSAGE_HANDLER(cmdREPLY_PID, on_cmdREPLY_PID)
54  MESSAGE_HANDLER(cmdREPLY_AGENTS_INFO, on_cmdREPLY_AGENTS_INFO)
56 
57  void setOptions(const SOptions& _options)
58  {
59  m_options = _options;
60  }
61 
62  private:
63  // Message Handlers
66  bool on_cmdREPLY_AGENTS_INFO(
68 
69  private:
70  SOptions m_options;
71  std::mutex m_mutexCounter;
72  size_t m_nCounter;
73  };
74  }
75 }
76 #endif
Definition: def.h:156
on_cmdSIMPLE_MSG MESSAGE_HANDLER(cmdREPLY_PID, on_cmdREPLY_PID) MESSAGE_HANDLER(cmdREPLY_AGENTS_INFO
Definition: ChannelEventsImpl.h:19
#define REGISTER_DEFAULT_REMOTE_ID_STRING
Definition: BaseChannelImpl.h:133
Definition: ProtocolCommands.h:47
dds-commander&#39;s container of options
Definition: dds-info/src/Options.h:25
Definition: BaseChannelImpl.h:148
std::shared_ptr< SEmptyCmd > ptr_t
Definition: CommandAttachmentImpl.h:65
bool m_bNeedAgentsList
Definition: dds-info/src/Options.h:41
#define LOG(severity)
Definition: Logger.h:54
BEGIN_MSG_MAP(CInfoChannel) MESSAGE_HANDLER(cmdSIMPLE_MSG
Definition: ProtocolCommands.h:32
on_cmdSIMPLE_MSG on_cmdREPLY_AGENTS_INFO END_MSG_MAP() void setOptions(const SOptions &_options)
Definition: InfoChannel.h:55
Definition: ChannelEventsImpl.h:21
Definition: dds-agent/src/AgentConnectionManager.h:16
bool m_bNeedPropValues
Definition: dds-info/src/Options.h:43
connection_t subscribeOnEvent(EChannelEvents _type, typename signal_t::slot_function_type _subscriber)
Definition: ChannelEventsImpl.h:45
bool m_bNeedAgentsNumber
Definition: dds-info/src/Options.h:40
bool m_bNeedDDSStatus
Definition: dds-info/src/Options.h:39
bool m_bNeedPropList
Definition: dds-info/src/Options.h:42
Definition: InfoChannel.h:17
Definition: BaseChannelImpl.h:40
Definition: ProtocolCommands.h:38
bool m_bNeedCommanderPid
Definition: dds-info/src/Options.h:38
Definition: def.h:150
Definition: ChannelEventsImpl.h:18