coral
A C++ library for distributed co-simulation
execution_manager.hpp
Go to the documentation of this file.
1 
10 #ifndef CORAL_BUS_EXECUTION_MANAGER_HPP
11 #define CORAL_BUS_EXECUTION_MANAGER_HPP
12 
13 #include <chrono>
14 #include <functional>
15 #include <memory>
16 #include <system_error>
17 #include <utility>
18 #include <vector>
19 
20 #include "boost/noncopyable.hpp"
21 
22 #include "coral/config.h"
24 #include "coral/model.hpp"
25 #include "coral/net.hpp"
26 
29 #include "coral/net/reactor.hpp"
30 
31 
32 namespace coral
33 {
35 namespace bus
36 {
37 
38 
43 struct AddedSlave
44 {
47 
50 
52  AddedSlave() CORAL_NOEXCEPT { }
53 
56  : locator{std::move(locator_)}, name(std::move(name_))
57  { }
58 };
59 
65 {
66  coral::model::SlaveID slaveID;
68 
69  SlaveConfig() CORAL_NOEXCEPT { }
71  coral::model::SlaveID slaveID_,
73  : slaveID{slaveID_}
74  , variableSettings(variableSettings_)
75  { }
76 };
77 
78 
80 
81 
83 class ExecutionManager : boost::noncopyable
84 {
85 public:
97  coral::net::Reactor& reactor,
98  const std::string& executionName,
99  const coral::master::ExecutionOptions& options = coral::master::ExecutionOptions{});
100 
101  ~ExecutionManager();
102 
105 
109 
133  void Reconstitute(
134  const std::vector<AddedSlave>& slavesToAdd,
135  std::chrono::milliseconds commTimeout,
136  ReconstituteHandler onComplete,
138 
141 
145 
168  void Reconfigure(
169  const std::vector<SlaveConfig>& slaveConfigs,
170  std::chrono::milliseconds commTimeout,
171  ReconfigureHandler onComplete,
173 
176 
180 
182  void Step(
185  StepHandler onComplete,
186  SlaveStepHandler onSlaveStepComplete = nullptr);
187 
190 
197 
199  void AcceptStep(
201  AcceptStepHandler onComplete,
202  SlaveAcceptStepHandler onSlaveAcceptStepComplete = nullptr);
203 
205  void Terminate();
206 
208  const std::string& SlaveName(coral::model::SlaveID id) const;
209 
210 private:
212 };
213 
214 
215 }} // namespace
216 #endif // header guard
Defines the coral::bus::SlaveSetup class.
std::function< void(const std::error_code &)> StepHandler
Completion handler type for the Step() function.
Definition: execution_manager.hpp:175
std::string name
A name for the slave, unique in the execution.
Definition: execution_manager.hpp:49
Manages and coordinates all participants in an execution.
Definition: execution_manager.hpp:83
Contains the coral::net::Reactor class and related functionality.
Main module header for coral::net.
AddedSlave(coral::net::SlaveLocator locator_, std::string name_)
Constructor which sets the locator and name fields.
Definition: execution_manager.hpp:55
std::function< void(const std::error_code &)> ReconfigureHandler
Completion handler type for Reconfigure().
Definition: execution_manager.hpp:140
AddedSlave() CORAL_NOEXCEPT
Default constructor.
Definition: execution_manager.hpp:52
Configuration options for an execution.
Defines the coral::bus::SlaveController class.
STL class.
std::function< void(const std::error_code &)> AcceptStepHandler
Completion handler type for the AcceptStep() function.
Definition: execution_manager.hpp:189
coral::net::SlaveLocator locator
The slave&#39;s network location.
Definition: execution_manager.hpp:46
std::function< void(const std::error_code &, coral::model::SlaveID, std::size_t)> SlaveReconfigureHandler
Per-slave completion handler type for Reconfigure()
Definition: execution_manager.hpp:144
Definition: variable_io.hpp:28
std::function< void(const std::error_code &, coral::model::SlaveID)> SlaveAcceptStepHandler
Completion handler type for the AcceptStep() function of individual slaves.
Definition: execution_manager.hpp:196
std::function< void(const std::error_code &)> ReconstituteHandler
Completion handler type for Reconstitute().
Definition: execution_manager.hpp:104
T move(T...args)
std::function< void(const std::error_code &, coral::model::SlaveID)> SlaveStepHandler
Completion handler type for the Step() function of individual slaves.
Definition: execution_manager.hpp:179
double TimeDuration
The type used to specify (simulation) time durations.
Definition: model.hpp:56
STL class.
Used in ExecutionManager::Reconfigure() to specify variable value and connection changes.
Definition: execution_manager.hpp:64
An implementation of the reactor pattern.
Definition: reactor.hpp:41
Implementation class for coral::bus::ExecutionManager.
Definition: execution_manager_private.hpp:50
Used in ExecutionManager::Reconstitute() to specify a slave which should be added to the simulation...
Definition: execution_manager.hpp:43
std::function< void(const std::error_code &, coral::model::SlaveID, std::size_t)> SlaveReconstituteHandler
Per-slave completion handler type for Reconstitute()
Definition: execution_manager.hpp:108
Class which represents the network location(s) of a slave.
Definition: net.hpp:292
Main module header for coral::model.