DDS  ver. 1.6
dds-intercom-lib/src/AgentConnectionManager.h
Go to the documentation of this file.
1 // Copyright 2014 GSI, Inc. All rights reserved.
2 //
3 //
4 //
5 #ifndef __DDS__API__AgentConnectionManager__
6 #define __DDS__API__AgentConnectionManager__
7 // DDS
8 #include "AgentChannel.h"
9 // BOOST
10 #include <boost/asio.hpp>
11 #include <boost/thread/thread.hpp>
12 #include <condition_variable>
13 
14 namespace dds
15 {
16  namespace internal_api
17  {
18  // struct SSyncHelper;
19 
20  class CAgentConnectionManager : public std::enable_shared_from_this<CAgentConnectionManager>
21  {
22  public:
23  typedef std::shared_ptr<CAgentConnectionManager> ptr_t;
24 
26  virtual ~CAgentConnectionManager();
27 
28  public:
29  void start();
30  void stop();
31  bool stopped()
32  {
33  return m_service.stopped();
34  }
35  void sendCustomCmd(const protocol_api::SCustomCmdCmd& _command);
36 
37  public:
38  void waitCondition();
39  void stopCondition();
40 
41  private:
44  CAgentChannel::weakConnectionPtr_t getAgentChannel()
45  {
46  return m_channel;
47  }
48 
49  private:
50  boost::asio::io_service m_service;
51  // Don't use m_channel directly, only via getAgentChannel
52  // In case if channel is destoryed, there still could be user calling update key
53  // TODO: need to find a way to hide m_channel from direct access
55  bool m_bStarted;
56  boost::thread_group m_workerThreads;
57 
63  std::mutex m_waitMutex;
64  std::condition_variable m_waitCondition;
65  };
66  }
67 }
68 
69 #endif /* defined(__DDS__API__AgentConnectionManager__) */
std::shared_ptr< CAgentChannel > connectionPtr_t
Definition: BaseChannelImpl.h:192
void waitCondition()
Definition: dds-intercom-lib/src/AgentConnectionManager.cpp:176
virtual ~CAgentConnectionManager()
Definition: dds-intercom-lib/src/AgentConnectionManager.cpp:40
CAgentConnectionManager()
Definition: dds-intercom-lib/src/AgentConnectionManager.cpp:35
std::shared_ptr< SEmptyCmd > ptr_t
Definition: CommandAttachmentImpl.h:65
void stopCondition()
Definition: dds-intercom-lib/src/AgentConnectionManager.cpp:182
std::weak_ptr< CAgentChannel > weakConnectionPtr_t
Definition: BaseChannelImpl.h:193
void sendCustomCmd(const protocol_api::SCustomCmdCmd &_command)
Definition: dds-intercom-lib/src/AgentConnectionManager.cpp:157
void stop()
Definition: dds-intercom-lib/src/AgentConnectionManager.cpp:124
bool stopped()
Definition: dds-intercom-lib/src/AgentConnectionManager.h:31
Definition: dds-intercom-lib/src/AgentConnectionManager.h:20
Definition: dds-agent/src/AgentConnectionManager.h:16
Definition: CustomCmdCmd.h:14
std::shared_ptr< CAgentConnectionManager > ptr_t
Definition: dds-intercom-lib/src/AgentConnectionManager.h:23
void start()
Definition: dds-intercom-lib/src/AgentConnectionManager.cpp:45