$darkmode
cloe::Stack Class Reference
Inheritance diagram for cloe::Stack:
Collaboration diagram for cloe::Stack:

Public Member Functions

 Stack (const Stack &other)
 
 Stack (Stack &&other)
 
Stackoperator= (Stack other)
 
Logger logger () const
 
void set_conf_reader (ConfReader fn)
 
void apply_plugin_conf (const PluginConf &c)
 
void insert_plugin (const PluginConf &c)
 
void insert_plugin (std::shared_ptr< Plugin > p, const PluginConf &c={})
 
bool has_plugin_with_name (const std::string &key) const
 
bool has_plugin_with_path (const std::string &path) const
 
std::shared_ptr< Pluginget_plugin_with_name (const std::string &key) const
 
std::shared_ptr< Pluginget_plugin_with_path (const std::string &key) const
 
std::shared_ptr< Pluginget_plugin_or_load (const std::string &key_or_path) const
 
const std::map< std::string, std::shared_ptr< Plugin > > & get_all_plugins () const
 
std::vector< DefaultConfget_simulator_defaults (std::string binding, std::string name) const
 
std::vector< DefaultConfget_controller_defaults (std::string binding, std::string name) const
 
std::vector< DefaultConfget_vehicle_defaults (std::string name) const
 
std::vector< DefaultConfget_component_defaults (std::string binding, std::string name) const
 
void validate_self () const
 
bool is_valid () const
 
void check_consistency () const
 
void check_defaults () const
 
bool is_complete () const
 
void check_completeness () const
 
void initialize ()
 
Json active_config () const
 
Json input_config () const
 
bool validate (const Conf &c, std::optional< SchemaError > &err) const override
 
void validate_or_throw (const Conf &c) const override
 
void to_json (Json &j) const override
 
void from_conf (const Conf &c) override
 
void reset_schema () override
 
 CONFABLE_SCHEMA (Stack)
 
- Public Member Functions inherited from fable::Confable
 Confable (const Confable &) noexcept
 
 Confable (Confable &&) noexcept=default
 
Confableoperator= (const Confable &other) noexcept
 
Confableoperator= (Confable &&other) noexcept
 
Schemaschema ()
 
const Schemaschema () const
 
virtual void to_json (Json &j) const
 
Json to_json () const
 

Public Attributes

std::string version
 
EngineConf engine
 
ServerConf server
 
std::vector< IncludeConfinclude
 
std::vector< LoggingConflogging
 
std::vector< PluginConfplugins
 
std::vector< DefaultConfsimulator_defaults
 
std::vector< SimulatorConfsimulators
 
std::vector< DefaultConfcontroller_defaults
 
std::vector< ControllerConfcontrollers
 
std::vector< DefaultConfcomponent_defaults
 
std::vector< VehicleConfvehicles
 
std::vector< TriggerConftriggers
 
SimulationConf simulation
 

Protected Member Functions

void from_conf (const Conf &c, size_t depth)
 
- Protected Member Functions inherited from fable::Confable
virtual Schema schema_impl ()
 

Friends

void swap (Stack &left, Stack &right)
 

Member Function Documentation

◆ active_config()

Json cloe::Stack::active_config ( ) const

Return the current active configuration as JSON.

Here is the call graph for this function:

◆ apply_plugin_conf()

void cloe::Stack::apply_plugin_conf ( const PluginConf c)

Try to load and register one or more plugins based on the PluginConf.

◆ check_completeness()

void cloe::Stack::check_completeness ( ) const

Throw a StackIncompleteError if configuration is not complete.

◆ check_consistency()

void cloe::Stack::check_consistency ( ) const

Check whether all identifier relationships are valid.

There is a single namespace for all identifiers used in a stack file:

  • simulators
  • vehicles
  • components
  • controllers

This also checks (best-effort) whether references that are made are valid.

Check that the given name does not exist yet.

Here is the caller graph for this function:

◆ check_defaults()

void cloe::Stack::check_defaults ( ) const

Check whether all default configurations are correct.

Here is the caller graph for this function:

◆ from_conf() [1/2]

void cloe::Stack::from_conf ( const Conf c)
inlineoverridevirtual

Deserialize a Confable from a Conf.

Unless you have special needs, it is recommended to implement

Schema schema_impl()

and use the default implementation of this.

Reimplemented from fable::Confable.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ from_conf() [2/2]

void cloe::Stack::from_conf ( const Conf c,
size_t  depth 
)
protected

Recursively load and apply the configuration, taking maximum depth into account.

◆ get_all_plugins()

const std::map<std::string, std::shared_ptr<Plugin> >& cloe::Stack::get_all_plugins ( ) const
inline

Return all loaded plugins, regardless of type.

Here is the caller graph for this function:

◆ get_plugin_or_load()

std::shared_ptr< Plugin > cloe::Stack::get_plugin_or_load ( const std::string &  key_or_path) const

Return the loaded plugin or load it temporarily.

Here is the call graph for this function:

◆ get_plugin_with_name()

std::shared_ptr< Plugin > cloe::Stack::get_plugin_with_name ( const std::string &  key) const

Return the loaded plugin with the following name.

  • If more than one such plugin exists, std::out_of_range is thrown.
Here is the caller graph for this function:

◆ get_plugin_with_path()

std::shared_ptr< Plugin > cloe::Stack::get_plugin_with_path ( const std::string &  key) const

Return the loaded plugin located at a path in the filesystem.

  • If no such plugin exists, std::out_of_range is thrown.
Here is the caller graph for this function:

◆ has_plugin_with_name()

bool cloe::Stack::has_plugin_with_name ( const std::string &  key) const

Return true if there is a plugin with this name.

Here is the caller graph for this function:

◆ has_plugin_with_path()

bool cloe::Stack::has_plugin_with_path ( const std::string &  path) const

Return if there is a plugin with this path.

Here is the caller graph for this function:

◆ initialize()

void cloe::Stack::initialize ( )
inline

Initialize is only necessary if you want default plugins to be loaded without reading a configuration file.

Here is the call graph for this function:

◆ input_config()

Json cloe::Stack::input_config ( ) const

Return a list of JSON input configurations.

◆ insert_plugin() [1/2]

void cloe::Stack::insert_plugin ( const PluginConf c)

Try to load and register a plugin based on the PluginConf.

Note: Unless you know what you are doing, and have read the source code of this function, you should probably use apply_plugin_conf().

Here is the call graph for this function:

◆ insert_plugin() [2/2]

void cloe::Stack::insert_plugin ( std::shared_ptr< Plugin p,
const PluginConf c = {} 
)

Register a plugin with the stack.

This method is useful when you have a plugin that is already loaded, such as those that are compiled in the engine itself.

Here is the call graph for this function:

◆ is_complete()

bool cloe::Stack::is_complete ( ) const

Return whether all required sections (simulators, vehicles, and controllers) are available.

An incomplete stack file may still be considered as valid. There are surely simulations that could be made without a defined vehicle or controller. Not having a simulator on the other hand means that any executed simulation is fairly pointless. But at least it will be over quickly in that case.

◆ is_valid()

bool cloe::Stack::is_valid ( ) const

Return true if this configuration would be valid.

Here is the call graph for this function:

◆ reset_schema()

void cloe::Stack::reset_schema ( )
overridevirtual

Reset the internal schema cache.

This causes schema_impl to be called next time the schema is requested.

Reimplemented from fable::Confable.

Here is the caller graph for this function:

◆ set_conf_reader()

void cloe::Stack::set_conf_reader ( ConfReader  fn)
inline

Set the function that performs the read operation of the inclusion of a configuration file.

The main purpose of this is to allow the engine to reset the reader to a custom one that performs variable interpolation if the user has it enabled.

◆ validate()

bool cloe::Stack::validate ( const Conf c,
std::optional< SchemaError > &  err 
) const
overridevirtual

Validate a configuration.

This cannot normally be done with schema().validate(), because plugins needed to be loaded in order to validate sections of the schema. This requires partial application of the schema.

This should be equivalent to from_conf() followed by validate_self().

Reimplemented from fable::Confable.

Here is the call graph for this function:

◆ validate_or_throw()

void cloe::Stack::validate_or_throw ( const Conf c) const
overridevirtual

Validate a Conf without applying it.

By default, this uses the validate_or_throw() method on schema(). If you want to guarantee anything extending beyond what's possible with schema, you can do that here.

This method should NOT call from_conf without also overriding from_conf to prevent infinite recursion.

Reimplemented from fable::Confable.

Here is the call graph for this function:

◆ validate_self()

void cloe::Stack::validate_self ( ) const

Validate own configuration.

This goes further than what a Schema can validate, since it may check for consistency and correctness (but not necessarily completeness, except for any references made) of the entire configuration.

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following files: