coral
A C++ library for distributed co-simulation
instance.hpp
Go to the documentation of this file.
1 
10 #ifndef CORAL_SLAVE_INSTANCE_HPP
11 #define CORAL_SLAVE_INSTANCE_HPP
12 
13 #include <string>
14 #include <coral/model.hpp>
15 
16 namespace coral
17 {
18 namespace slave
19 {
20 
21 
42 class Instance
43 {
44 public:
47 
76  virtual void Setup(
77  const std::string& slaveName,
78  const std::string& executionName,
79  coral::model::TimePoint startTime,
80  coral::model::TimePoint stopTime,
81  bool adaptiveStepSize,
82  double relativeTolerance) = 0;
83 
88  virtual void StartSimulation() = 0;
89 
91  virtual void EndSimulation() = 0;
92 
111  virtual bool DoStep(
112  coral::model::TimePoint currentT,
113  coral::model::TimeDuration deltaT) = 0;
114 
119  virtual double GetRealVariable(coral::model::VariableID variable) const = 0;
120 
125  virtual int GetIntegerVariable(coral::model::VariableID variable) const = 0;
126 
131  virtual bool GetBooleanVariable(coral::model::VariableID variable) const = 0;
132 
137  virtual std::string GetStringVariable(coral::model::VariableID variable) const = 0;
138 
148  virtual bool SetRealVariable(coral::model::VariableID variable, double value) = 0;
149 
159  virtual bool SetIntegerVariable(coral::model::VariableID variable, int value) = 0;
160 
170  virtual bool SetBooleanVariable(coral::model::VariableID variable, bool value) = 0;
171 
181  virtual bool SetStringVariable(coral::model::VariableID variable, const std::string& value) = 0;
182 
183  // Because it's an interface:
184  virtual ~Instance() { }
185 };
186 
187 
188 }}
189 #endif // header guard
virtual std::string GetStringVariable(coral::model::VariableID variable) const =0
Returns the value of a string variable.
virtual bool SetRealVariable(coral::model::VariableID variable, double value)=0
Sets the value of a real variable.
virtual coral::model::SlaveTypeDescription TypeDescription() const =0
Returns an object that describes the slave type.
virtual bool DoStep(coral::model::TimePoint currentT, coral::model::TimeDuration deltaT)=0
Performs model calculations for the time step which starts at the time point currentT and has a durat...
virtual int GetIntegerVariable(coral::model::VariableID variable) const =0
Returns the value of an integer variable.
virtual bool SetIntegerVariable(coral::model::VariableID variable, int value)=0
Sets the value of an integer variable.
STL class.
virtual void EndSimulation()=0
Informs the slave that the simulation run has ended.
A description of a slave type.
Definition: model.hpp:148
Definition: variable_io.hpp:28
double TimeDuration
The type used to specify (simulation) time durations.
Definition: model.hpp:56
virtual bool SetBooleanVariable(coral::model::VariableID variable, bool value)=0
Sets the value of a boolean variable.
virtual double GetRealVariable(coral::model::VariableID variable) const =0
Returns the value of a real variable.
virtual bool SetStringVariable(coral::model::VariableID variable, const std::string &value)=0
Sets the value of a string variable.
virtual void StartSimulation()=0
Informs the slave that the initialisation stage ends and the simulation begins.
Main module header for coral::model.
virtual bool GetBooleanVariable(coral::model::VariableID variable) const =0
Returns the value of a boolean variable.
An interface for classes that represent slave instances.
Definition: instance.hpp:42
double TimePoint
The type used to specify (simulation) time points.
Definition: model.hpp:42
virtual void Setup(const std::string &slaveName, const std::string &executionName, coral::model::TimePoint startTime, coral::model::TimePoint stopTime, bool adaptiveStepSize, double relativeTolerance)=0
Instructs the slave to perform pre-simulation setup and enter initialisation mode.