$darkmode
#include <stack.hpp>
Public Member Functions | |
| Stack (const Stack &other) | |
| Stack (Stack &&other) noexcept | |
| Stack & | operator= (const Stack &other) |
| Stack & | operator= (Stack &&other) noexcept |
| Logger | logger () const |
| void | set_conf_reader (ConfReader fn) |
| void | merge_stackfile (const std::string &filepath) |
| 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< Plugin > | get_plugin_with_name (const std::string &key) const |
| std::shared_ptr< Plugin > | get_plugin_with_path (const std::string &key) const |
| std::shared_ptr< Plugin > | get_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< DefaultConf > | get_simulator_defaults (std::string binding, std::string name) const |
| std::vector< DefaultConf > | get_controller_defaults (std::string binding, std::string name) const |
| std::vector< DefaultConf > | get_vehicle_defaults (std::string name) const |
| std::vector< DefaultConf > | get_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 | |
| Confable & | operator= (const Confable &other) noexcept |
| Confable & | operator= (Confable &&other) noexcept |
| Schema & | schema () |
| const Schema & | schema () const |
| virtual void | to_json (Json &j) const |
| Json | to_json () const |
Public Attributes | |
| std::string | version |
| EngineConf | engine |
| ServerConf | server |
| std::vector< IncludeConf > | include |
| std::vector< LoggingConf > | logging |
| std::vector< PluginConf > | plugins |
| std::vector< DefaultConf > | simulator_defaults |
| std::vector< SimulatorConf > | simulators |
| std::vector< DefaultConf > | controller_defaults |
| std::vector< ControllerConf > | controllers |
| std::vector< DefaultConf > | component_defaults |
| std::vector< VehicleConf > | vehicles |
| std::vector< TriggerConf > | triggers |
| 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) |
Stack represents the entire configuration of the engine and the simulation to be run.
| Json cloe::Stack::active_config | ( | ) | const |
Return the current active configuration as JSON.
| void cloe::Stack::apply_plugin_conf | ( | const PluginConf & | c | ) |
Try to load and register one or more plugins based on the PluginConf.
| void cloe::Stack::check_completeness | ( | ) | const |
Throw a StackIncompleteError if configuration is not complete.
| 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:
This also checks (best-effort) whether references that are made are valid.
Check that the given name does not exist yet.
| void cloe::Stack::check_defaults | ( | ) | const |
Check whether all default configurations are correct.
|
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.
|
protected |
Recursively load and apply the configuration, taking maximum depth into account.
|
inline |
Return all loaded plugins, regardless of type.
| 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.
| std::shared_ptr< Plugin > cloe::Stack::get_plugin_with_name | ( | const std::string & | key | ) | const |
Return the loaded plugin with the following name.
std::out_of_range is thrown. | 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.
std::out_of_range is thrown. | bool cloe::Stack::has_plugin_with_name | ( | const std::string & | key | ) | const |
Return true if there is a plugin with this name.
| bool cloe::Stack::has_plugin_with_path | ( | const std::string & | path | ) | const |
Return if there is a plugin with this path.
|
inline |
Initialize is only necessary if you want default plugins to be loaded without reading a configuration file.
| Json cloe::Stack::input_config | ( | ) | const |
Return a list of JSON input configurations.
| 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().
| 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.
| 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.
| bool cloe::Stack::is_valid | ( | ) | const |
Return true if this configuration would be valid.
| void cloe::Stack::merge_stackfile | ( | const std::string & | filepath | ) |
Open the given JSON file and merge it into the stack.
|
overridevirtual |
Reset the internal schema cache.
This causes schema_impl to be called next time the schema is requested.
Reimplemented from fable::Confable.
|
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.
|
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.
|
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.
| 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.