DDS  ver. 3.4
StatChannel.h
Go to the documentation of this file.
1 // Copyright 2014 GSI, Inc. All rights reserved.
2 //
3 //
4 //
5 
6 #ifndef __DDS__StatChannel__
7 #define __DDS__StatChannel__
8 // DDS
9 #include "ClientChannelImpl.h"
10 #include "Options.h"
11 
12 namespace dds
13 {
14  namespace stat_cmd
15  {
16  class CStatChannel : public protocol_api::CClientChannelImpl<CStatChannel>
17  {
18  CStatChannel(boost::asio::io_context& _service, uint64_t _protocolHeaderID = 0)
19  : CClientChannelImpl<CStatChannel>(_service, protocol_api::EChannelType::UI, _protocolHeaderID)
20  {
21  registerHandler<protocol_api::EChannelEvents::OnHandshakeOK>(
22  [this](const protocol_api::SSenderInfo& _sender) {
23  if (m_options.m_bEnable)
24  {
25  pushMsg<protocol_api::cmdENABLE_STAT>();
26  }
27  else if (m_options.m_bDisable)
28  {
29  pushMsg<protocol_api::cmdDISABLE_STAT>();
30  }
31  else if (m_options.m_bGet)
32  {
33  pushMsg<protocol_api::cmdGET_STAT>();
34  }
35  });
36 
37  registerHandler<protocol_api::EChannelEvents::OnConnected>(
38  [](const protocol_api::SSenderInfo& _sender) {
39  LOG(MiscCommon::info) << "Connected to the commander server";
40  });
41 
42  registerHandler<protocol_api::EChannelEvents::OnFailedToConnect>(
43  [](const protocol_api::SSenderInfo& _sender) {
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)
54 
55  void setOptions(const SOptions& _options)
56  {
57  m_options = _options;
58  }
59 
60  private:
61  // Message Handlers
63  const protocol_api::SSenderInfo& _sender);
64 
65  private:
66  SOptions m_options;
67  };
68  } // namespace stat_cmd
69 } // namespace dds
70 #endif
Definition: def.h:156
Definition: BaseEventHandlersImpl.h:48
bool m_bGet
Definition: dds-stat/src/Options.h:36
#define MESSAGE_HANDLER(msg, func)
Definition: BaseChannelImpl.h:112
#define REGISTER_DEFAULT_REMOTE_ID_STRING
Definition: BaseChannelImpl.h:190
BEGIN_MSG_MAP(CStatChannel) MESSAGE_HANDLER(cmdSIMPLE_MSG
Definition: StatChannel.h:16
Definition: ProtocolDef.h:19
std::shared_ptr< SEmptyCmd > ptr_t
Definition: CommandAttachmentImpl.h:64
#define LOG(severity)
Definition: Logger.h:56
Definition: ProtocolCommands.h:33
dds-commander's container of options
Definition: dds-stat/src/Options.h:25
Definition: AgentConnectionManager.h:13
bool m_bDisable
Definition: dds-stat/src/Options.h:35
on_cmdSIMPLE_MSG END_MSG_MAP() void setOptions(const SOptions &_options)
Definition: StatChannel.h:53
Definition: BaseChannelImpl.h:40
Definition: def.h:150
bool m_bEnable
Definition: dds-stat/src/Options.h:34