$darkmode
simulator.hpp File Reference
#include <memory>
#include <string>
#include <type_traits>
#include <cloe/model.hpp>
Include dependency graph for simulator.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  cloe::Simulator
 
class  cloe::SimulatorFactory
 

Macros

#define DEFINE_SIMULATOR_FACTORY(xFactoryType, xConfigType, xName, xDescription)
 
#define DEFINE_SIMULATOR_FACTORY_MAKE(xFactoryType, xSimulatorType)
 

Detailed Description

See also
cloe/model.hpp

This file provides the base classes for simulator models.

Macro Definition Documentation

◆ DEFINE_SIMULATOR_FACTORY

#define DEFINE_SIMULATOR_FACTORY (   xFactoryType,
  xConfigType,
  xName,
  xDescription 
)
Value:
class xFactoryType : public ::cloe::SimulatorFactory { \
public: \
xFactoryType() : ::cloe::SimulatorFactory(xName, xDescription) {} \
std::unique_ptr<::cloe::SimulatorFactory> clone() const override { \
return std::make_unique<std::decay<decltype(*this)>::type>(*this); \
} \
std::unique_ptr<::cloe::Simulator> make(const ::fable::Conf&) const override; \
\
protected: \
::cloe::Schema schema_impl() override { return config_.schema(); } \
\
private: \
xConfigType config_; \
};
Definition: simulator.hpp:199
virtual std::unique_ptr< Simulator > make(const fable::Conf &c) const =0
virtual std::unique_ptr< SimulatorFactory > clone() const =0
virtual Schema schema_impl()
Definition: confable.cpp:84
Definition: schema.hpp:173

This macro defines a SimulatorFactory named xFactoryType and with the configuration xConfigType. It should be used within the desired namespace.

The make method needs to be implemented:

std::unique_ptr<Simulator> xFactoryType::make(const Conf& c) {
// implementation
}

The DEFINE_SIMULATOR_FACTORY_MAKE macro can also be used to use the default implementation.

◆ DEFINE_SIMULATOR_FACTORY_MAKE

#define DEFINE_SIMULATOR_FACTORY_MAKE (   xFactoryType,
  xSimulatorType 
)
Value:
std::unique_ptr<::cloe::Simulator> xFactoryType::make(const ::fable::Conf& c) const { \
decltype(config_) conf{config_}; \
if (!c->is_null()) { \
conf.from_conf(c); \
} \
return std::make_unique<xSimulatorType>(this->name(), conf); \
}

This macro defines the xFactoryType::make method.

For this to work, the xSimulatorType must have a constructor with the following signature (see DEFINE_SIMULATOR_FACTORY macro):

xSimulatorType(const std::string&, const xConfigType&)