OpenDaVINCI  4.15.3
connection/Client.h
Go to the documentation of this file.
1 
20 #ifndef OPENDAVINCI_DMCP_CONNECTION_CLIENT_H_
21 #define OPENDAVINCI_DMCP_CONNECTION_CLIENT_H_
22 
23 #include <vector>
24 
32 #include "opendavinci/generated/odcore/data/dmcp/ModuleDescriptor.h"
33 #include "opendavinci/generated/odcore/data/dmcp/ModuleExitCodeMessage.h"
34 #include "opendavinci/generated/odcore/data/dmcp/ModuleStateMessage.h"
35 #include "opendavinci/generated/odcore/data/dmcp/PulseMessage.h"
36 #include "opendavinci/generated/odcore/data/dmcp/RuntimeStatistic.h"
37 #include "opendavinci/generated/odcore/data/dmcp/ServerInformation.h"
38 
39 namespace odcore { namespace data { class Configuration; } }
40 namespace odcore { namespace data { class Container; } }
41 namespace odcore { namespace dmcp { class SupercomponentStateListener; } }
42 
43 namespace odcore {
44  namespace dmcp {
45  namespace connection {
46 
47  using namespace std;
48 
51  {
52  private:
58  Client(const Client &);
59 
65  Client& operator=(const Client &);
66 
67  public:
68  Client(const odcore::data::dmcp::ModuleDescriptor &moduleDescriptor,
69  const odcore::data::dmcp::ServerInformation &serverInformation);
70 
71  virtual ~Client();
72 
73  void initialize();
74 
75  void sendModuleExitCode(const odcore::data::dmcp::ModuleExitCodeMessage::ModuleExitCode &me);
76  void sendModuleState(const odcore::data::dmcp::ModuleStateMessage::ModuleState &me);
77  void sendStatistics(const odcore::data::dmcp::RuntimeStatistic &rs);
78 
79  odcore::base::KeyValueConfiguration getConfiguration();
80 
81  const odcore::data::dmcp::PulseMessage getPulseMessage();
82 
86  void sendPulseAck();
87 
94  void sendPulseAckContainers(const vector<odcore::data::Container> &listOfContainers);
95 
96  void setSupercomponentStateListener(SupercomponentStateListener* listener);
97 
98  bool isConnected();
99 
100  protected:
101  void sendConfigurationRequest();
102  virtual void nextContainer(odcore::data::Container &c);
103  virtual void handleConnectionError();
104 
105  void handleConfiguration(odcore::data::Configuration &configuration);
106  void waitForConfiguration();
107  bool isConfigured();
108 
109  private:
110  odcore::data::dmcp::ModuleDescriptor m_moduleDescriptor;
111  odcore::data::dmcp::ServerInformation m_serverInformation;
112 
113  odcore::io::Connection m_connection;
114 
115  odcore::base::Mutex m_configurationMutex;
116  odcore::base::KeyValueConfiguration m_configuration;
117 
118  bool m_configured;
119  odcore::base::Mutex m_configuredMutex;
120  odcore::base::Condition m_configurationRequestCondition;
121 
122  odcore::base::Mutex m_listenerMutex;
123  SupercomponentStateListener* m_listener;
124 
125  odcore::base::Condition m_pulseCondition;
126  odcore::base::Mutex m_pulseMessageMutex;
127  odcore::data::dmcp::PulseMessage m_pulseMessage;
128  };
129  }
130  }
131 } // odcore::dmcp
132 
133 #endif /*OPENDAVINCI_DMCP_CONNECTION_CLIENT_H_*/
Definition: base/Condition.h:64
Definition: ContainerListener.h:35
Definition: base/Mutex.h:49
Definition: Container.h:40
Definition: ConnectionErrorListener.h:30
#define OPENDAVINCI_API
Definition: opendavinci.h:67
Definition: Connection.h:43
Definition: connection/Client.h:49
Definition: SuperComponentStateListener.h:30
Definition: KeyValueConfiguration.h:58