Register#

#include "navground/core/register.h"
using navground::core::PropertyRegister = std::map<std::string, Properties>#
template<typename T>
struct HasRegister : public navground::core::HasProperties#

Contains a register of sub-classes of T, registered by name using register_type.

Template Parameters:

T – The base class of all to be registered sub-classes.

Subclassed by navground::sim::Scenario, navground::sim::StateEstimation, navground::sim::Task

Public Types

using C = std::shared_ptr<T>#

A shared pointer to an object of type T.

using Factory = std::function<C()>#

Factory function to construct objects of type T.

Public Functions

inline virtual std::string get_type() const#

Gets the name associated to the type of an object in the register.

Returns:

The associated name or empty if not registered.

inline virtual const Properties &get_properties() const override#

Gets the registered properties.

Returns:

The properties or empty if not registered.

inline virtual void encode(YAML::Node &node) const#

Allows to customize YAML encoding.

Parameters:

node – The YAML node

inline virtual void decode(const YAML::Node &node)#

Allows to customize YAML decoding.

Parameters:

node – The YAML node

Public Static Functions

static std::map<std::string, Factory> &factory()#

The registered factories.

Returns:

A map of registered factory functions name -> factory.

static PropertyRegister &type_properties()#

The registered properties.

Returns:

A map with the list of properties for all registered sub-classes name -> properties.

static SchemaRegister &type_schema()#

The registered properties.

Returns:

A map with the list of properties for all registered sub-classes name -> properties.

static inline C make_type(const std::string &type)#

Create a shared pointer of type T, selecting the factory method by name.

Parameters:

type[in] The associated sub-class name.

Returns:

A pointer to an object of a registered sub-class. Returns nullptr (C++) or None(Python) in case the desired name is not found.

static inline bool has_type(const std::string &type)#

Check whether a type name has been registered.

Parameters:

type[in] The associated sub-class name.

Returns:

True if the type name has been registered

static inline std::vector<std::string> types()#

Reads the names of all registered sub-classes.

Returns:

A collection of names associated with registered sub-classes.

template<typename S>
static inline std::string register_type(const std::string &type, const Properties &properties = {}, const Schema &schema = nullptr)#

Register a sub-class of T, associating it with a user-defined name.

Parameters:
  • type[in] The user-defined name to be associated with the sub-class.

  • properties[in] Registered properties

  • schema[in] An optional schema for custom YAML decoders.

Template Parameters:

S – The type of the sub-class

Returns:

The associated name.

template<typename S>
static inline std::string get_type()#

Gets name associated to the type in the register.

Template Parameters:

S – The type

Returns:

The associated name or empty if not registered.

template<typename S>
static inline const Properties &get_properties()#

Gets the registered properties for this type.

Template Parameters:

S – The type

Returns:

The properties or empty if not registered.

Macros#

DECLARE_TYPE#

Adds type declaration.

static const std::string type;
DECLARE_PROPERTIES#

Adds properties declaration.

static const std::map<std::string, navground::core::Property> properties;
DECLARE_TYPE_AND_PROPERTIES#

Combine DECLARE_TYPE and DECLARE_PROPERTIES.

static const std::string type;
static const std::map<std::string, navground::core::Property> properties;