Ignition Gazebo

API Reference

1.0.2
Factory Class Reference

A factory that generates a component based on a string type. More...

#include <Factory.hh>

Public Member Functions

template<typename ComponentTypeT >
std::unique_ptr< ComponentTypeT > New ()
 Create a new instance of a component. More...
 
std::unique_ptr< components::BaseComponentNew (const ComponentTypeId &_type)
 Create a new instance of a component. More...
 
std::unique_ptr< ComponentStorageBaseNewStorage (const ComponentTypeId &_typeId)
 Create a new instance of a component storage. More...
 
template<typename ComponentTypeT >
void Register (const std::string &_type, ComponentDescriptorBase *_compDesc, StorageDescriptorBase *_storageDesc)
 Register a component so that the factory can create instances of the component and its storage based on an ID. More...
 
std::vector< uint64_t > TypeIds () const
 Get all the registered component types by ID. return Vector of component IDs. More...
 
template<typename ComponentTypeT >
void Unregister ()
 Unregister a component so that the factory can't create instances of the component or its storage anymore. More...
 

Detailed Description

A factory that generates a component based on a string type.

Member Function Documentation

◆ New() [1/2]

std::unique_ptr<ComponentTypeT> New ( )
inline

Create a new instance of a component.

Returns
Pointer to a component. Null if the component type could not be handled.
Template Parameters
ComponentTypeTcomponent type requested

◆ New() [2/2]

std::unique_ptr<components::BaseComponent> New ( const ComponentTypeId _type)
inline

Create a new instance of a component.

Parameters
[in]_typeComponent id to create.
Returns
Pointer to a component. Null if the component type could not be handled.

◆ NewStorage()

std::unique_ptr<ComponentStorageBase> NewStorage ( const ComponentTypeId _typeId)
inline

Create a new instance of a component storage.

Parameters
[in]_typeIdType of component which the storage will hold.
Returns
Pointer to a storage. Null if the component type could not be handled.

◆ Register()

void Register ( const std::string &  _type,
ComponentDescriptorBase _compDesc,
StorageDescriptorBase _storageDesc 
)
inline

Register a component so that the factory can create instances of the component and its storage based on an ID.

Parameters
[in]_typeType of component to register.
[in]_compDescObject to manage the creation of ComponentTypeT objects.
[in]_storageDescObject to manage the creation of storages for objects of type ComponentTypeT.
Template Parameters
ComponentTypeTType of component to register.

◆ TypeIds()

std::vector<uint64_t> TypeIds ( ) const
inline

Get all the registered component types by ID. return Vector of component IDs.

◆ Unregister()

void Unregister ( )
inline

Unregister a component so that the factory can't create instances of the component or its storage anymore.

Template Parameters
ComponentTypeTType of component to unregister.

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