coral
A C++ library for distributed co-simulation
provider.hpp
Go to the documentation of this file.
1 
10 #ifndef CORAL_PROVIDER_PROVIDER_HPP_INCLUDED
11 #define CORAL_PROVIDER_PROVIDER_HPP_INCLUDED
12 
13 #include <exception>
14 #include <functional>
15 #include <memory>
16 #include <string>
17 #include <thread>
18 #include <vector>
19 
20 #include <coral/config.h>
22 
23 
24 // Forward declaration to avoid dependency on ZMQ headers
25 namespace zmq { class socket_t; }
26 
27 
28 namespace coral
29 {
30 namespace provider
31 {
32 
33 
36 {
37 public:
63  const std::string& slaveProviderID,
65  const coral::net::ip::Address& networkInterface,
66  coral::net::ip::Port discoveryPort,
67  std::function<void(std::exception_ptr)> exceptionHandler = nullptr);
68 
69  SlaveProvider(const SlaveProvider&) = delete;
70  SlaveProvider& operator=(const SlaveProvider&) = delete;
71 
72  CORAL_DEFINE_DEFAULT_MOVE(SlaveProvider, m_killSocket, m_thread);
73 
81  ~SlaveProvider() CORAL_NOEXCEPT;
82 
90  void Stop();
91 
92 private:
93  std::unique_ptr<zmq::socket_t> m_killSocket;
94  std::thread m_thread;
95 };
96 
97 
98 }} // namespace
99 #endif // header guard
An object which represents an internet port number.
Definition: net.hpp:156
Defines the coral::provider::SlaveCreator interface and related functionality.
STL class.
An object which identifies an internet host or network interface as either an IPv4 address or a textu...
Definition: net.hpp:80
A slave provider that runs in a background thread.
Definition: provider.hpp:35
Definition: variable_io.hpp:28
STL class.
STL class.
Definition: variable_io.hpp:25
STL class.