$darkmode
#include <vehicle.hpp>
Public Member Functions | |
| Vehicle (uint64_t id, const std::string &name) | |
| std::shared_ptr< Vehicle > | clone (uint64_t id, const std::string &name) |
| uint64_t | id () const |
| size_t | size () const |
| bool | has (const std::string &key) const |
| template<typename Enum , std::enable_if_t< std::is_enum< Enum >::value, int > = 0> | |
| bool | has (Enum c) const |
| template<typename T > | |
| std::shared_ptr< const T > | get (const std::string &key) const |
| template<typename T > | |
| std::shared_ptr< T > | get (const std::string &key) |
| template<typename T , typename Enum , std::enable_if_t< std::is_enum< Enum >::value, int > = 0> | |
| std::shared_ptr< const T > | get (Enum c) const |
| template<typename T , typename Enum , std::enable_if_t< std::is_enum< Enum >::value, int > = 0> | |
| std::shared_ptr< T > | get (Enum c) |
| template<typename... Arguments> | |
| void | new_component (Component *ptr, const Arguments &... aliases) |
| template<typename First , typename... Arguments> | |
| void | add_component (std::shared_ptr< Component > sp, const First &alias, const Arguments &... aliases) |
| template<typename Enum , std::enable_if_t< std::is_enum< Enum >::value, int > = 0> | |
| void | add_component (std::shared_ptr< Component > sp, Enum c) |
| void | add_component (std::shared_ptr< Component > sp, const std::string &alias) |
| template<typename First , typename... Arguments> | |
| void | emplace_component (std::shared_ptr< Component > sp, const First &alias, const Arguments &... aliases) |
| template<typename Enum , std::enable_if_t< std::is_enum< Enum >::value, int > = 0> | |
| void | emplace_component (std::shared_ptr< Component > sp, Enum c) |
| void | emplace_component (std::shared_ptr< Component > sp, const std::string &alias) |
| void | set_component (const std::string &key, std::shared_ptr< Component > component) |
| Duration | process (const Sync &sync) override |
| void | connect () override |
| void | disconnect () override |
| void | enroll (Registrar &r) override |
| void | reset () override |
| void | abort () override |
Public Member Functions inherited from cloe::Model | |
| virtual | ~Model () noexcept=default |
| virtual Duration | resolution () const |
| virtual bool | is_connected () const |
| virtual bool | is_operational () const |
| virtual void | start (const Sync &) |
| virtual void | pause (const Sync &) |
| virtual void | resume (const Sync &) |
| virtual void | stop (const Sync &) |
| Entity (std::string name) | |
| Entity (std::string name, std::string desc) | |
Public Member Functions inherited from cloe::Entity | |
| Entity (std::string name) | |
| Entity (std::string name, std::string desc) | |
| const std::string & | name () const |
| void | set_name (std::string name) |
| const std::string & | description () const |
| void | set_description (std::string desc) |
Protected Member Functions | |
| std::shared_ptr< const Component > | at (const std::string &key) const |
| std::shared_ptr< Component > | at (const std::string &key) |
Protected Member Functions inherited from cloe::Entity | |
| virtual Logger | logger () const |
Friends | |
| void | to_json (Json &j, const Vehicle &v) |
Additional Inherited Members | |
Protected Attributes inherited from cloe::Model | |
| bool | connected_ {false} |
| bool | operational_ {false} |
Protected Attributes inherited from cloe::Entity | |
| std::string | name_ |
| std::string | desc_ |
A Vehicle is a collection of sensor and actuator components.
Some of the components are sensors, and some are actuators. From the perspective of a controller, a sensor can be thought of as a read-only device, while an actuator can be thought of as a read-write device. The simulator will have a reversed perspectice, as it supplies data to or through sensor components and reads from actuators.
The initial set of components that are part of a Vehicle are supplied by a simulator. A simulator binding may derive from the Vehicle class and provide its own components that are (encouraged to derive from Cloe standard) sensors and actuators.
Through runtime configuration, the initial set of components may be extended or modified. It is therefore important that simulator bindings maintain an internal list of components which are read and written.
|
overridevirtual |
Signal an abort to model processing.
This method is called asynchronously. It is highly recommended to make use of a std::atomic_bool for purposes of making the abortion request known to other parts of the model. This method is called when the user requests the simulation to be aborted, e.g., by sending the SIGINT signal.
An abort will be followed by a stop if the simulation was started.
The default implementation will throw an error. This will be caught and possibly ignored. Otherwise, the simulation will be killed.
Reimplemented from cloe::Model.
|
protected |
Return the component with the given name or throw an Error that is actually helpful.
| std::shared_ptr< Vehicle > cloe::Vehicle::clone | ( | uint64_t | id, |
| const std::string & | name | ||
| ) |
Return a clone of a vehicle with the given ID and name.
This retains all the components that the vehicle has and allows the cloned vehicle to be modified without affecting the original vehicle.
|
overridevirtual |
Initiate a connection to the model, including any initialization.
After a successful connection, the following methods shall be callable:
When implementing this method, e.g. via override or final, make sure to call this method:
void MySuperModel::connect() final { // Your connection code Model::connect(); }
Reimplemented from cloe::Model.
|
overridevirtual |
Tear down the connection to the model.
After successful disconnection, it is not expected that the model should be able to connect again.
When implementing this method, e.g. via override or final, make sure to call this method:
void MySuperModel::disconnect() final { // Your disconnection code Model::disconnect(); }
Reimplemented from cloe::Model.
|
overridevirtual |
Register any events, actions, or handlers with the registrar.
Reimplemented from cloe::Model.
|
inline |
Return the component associated with the key.
This may throw one of:
|
inline |
Return the component associated with the enum value.
Under-the-hood, the enum is translated to a string, which is used to fetch the correct component.
|
inline |
Return whether the vehicle has a component with the given name.
|
inline |
Return whether the vehicle has the component as identified by the enum value.
Process all components.
This primarily consists of clearing the cache and updating internal state.
This may occur multiple times for each component, even if a component only exists once in a vehicle. For example, if a component exists in a vehicle, but then is wrapped by two different filters; the original sensor may not be directly reachable, but two different components will update it.
Implements cloe::Model.
|
overridevirtual |
Reset the model state.
This is called when Cloe is asked to reset the whole simulation to time 0. This can be the case when the simulator or a controller asks us to recover from a temporary problem without repeating the whole simulation setup.
The default implementation will raise an error. So if your model is not able to re-initialize, the simulation will be aborted.
Reimplemented from cloe::Model.
|
inline |
Return the number of components in the vehicle.