gz/sim/components/Factory.hh
Go to the documentation of this file.
T at(T... args)
Base class for all components.
Definition: gz/sim/components/Component.hh:231
virtual ComponentTypeId TypeId() const =0
Returns the unique ID for the component's type. The ID is derived from the name that is manually chos...
A base class for an object responsible for creating components.
Definition: gz/sim/components/Factory.hh:48
virtual ~ComponentDescriptorBase()=default
Destructor.
virtual std::unique_ptr< BaseComponent > Create() const =0
Create an instance of a Component.
virtual std::unique_ptr< BaseComponent > Create(const components::BaseComponent *_data) const =0
Create an instance of a Component, populated with specific data.
A class to hold the queue of component descriptors registered by translation units....
Definition: gz/sim/components/Factory.hh:160
void IGNITION_GAZEBO_HIDDEN Remove(RegistrationObjectId _regObjId)
Remove a component descriptor from the queue. This also deletes memory allocated for the component de...
Definition: gz/sim/components/Factory.hh:184
IGNITION_GAZEBO_HIDDEN std::unique_ptr< BaseComponent > Create(const components::BaseComponent *_data) const
Create a component using the latest available component descriptor. This simply forward to ComponentD...
Definition: gz/sim/components/Factory.hh:213
void IGNITION_GAZEBO_HIDDEN Add(RegistrationObjectId _regObjId, ComponentDescriptorBase *_comp)
Add a component descriptor to the queue.
Definition: gz/sim/components/Factory.hh:172
IGNITION_GAZEBO_HIDDEN std::unique_ptr< BaseComponent > Create() const
Create a component using the latest available component descriptor. This simply forward to ComponentD...
Definition: gz/sim/components/Factory.hh:201
bool IGNITION_GAZEBO_HIDDEN Empty()
Check if the queue is empty.
Definition: gz/sim/components/Factory.hh:162
A class for an object responsible for creating components.
Definition: gz/sim/components/Factory.hh:68
std::unique_ptr< BaseComponent > Create() const override
Documentation inherited.
Definition: gz/sim/components/Factory.hh:70
virtual std::unique_ptr< BaseComponent > Create(const components::BaseComponent *_data) const override
Documentation inherited.
Definition: gz/sim/components/Factory.hh:76
A factory that generates a component based on a string type.
Definition: gz/sim/components/Factory.hh:233
std::string Name(ComponentTypeId _typeId) const
Get a component's type name given its type ID. return Unique component name.
Definition: gz/sim/components/Factory.hh:482
void Unregister()
Unregister a component so that the factory can't create instances of the component anymore.
Definition: gz/sim/components/Factory.hh:336
Factory(Factory &)=delete
void Unregister(ComponentTypeId _typeId)
Unregister a component so that the factory can't create instances of the component anymore.
Definition: gz/sim/components/Factory.hh:360
void Unregister(ComponentTypeId _typeId, RegistrationObjectId _regObjId)
Unregister a component so that the factory can't create instances of the component anymore.
Definition: gz/sim/components/Factory.hh:374
void Unregister(RegistrationObjectId _regObjId)
Unregister a component so that the factory can't create instances of the component anymore.
Definition: gz/sim/components/Factory.hh:348
std::unique_ptr< ComponentTypeT > New()
Create a new instance of a component.
Definition: gz/sim/components/Factory.hh:394
std::vector< ComponentTypeId > TypeIds() const
Get all the registered component types by ID. return Vector of component IDs.
Definition: gz/sim/components/Factory.hh:462
static Factory * Instance()
Get an instance of the singleton.
bool HasType(ComponentTypeId _typeId)
Check if a component type has been registered. return True if registered.
Definition: gz/sim/components/Factory.hh:475
Factory(const Factory &)=delete
std::unique_ptr< components::BaseComponent > New(const ComponentTypeId &_type, const components::BaseComponent *_data)
Create a new instance of a component, initialized with particular data.
Definition: gz/sim/components/Factory.hh:423
Factory()=default
void Register(const std::string &_type, ComponentDescriptorBase *_compDesc)
Register a component so that the factory can create instances of the component based on an ID.
Definition: gz/sim/components/Factory.hh:269
std::map< ComponentTypeId, std::string > namesById
A list of IDs and their equivalent names.
Definition: gz/sim/components/Factory.hh:494
std::map< ComponentTypeId, std::string > runtimeNamesById
Keep track of the runtime names for types and warn the user if they try to register different types w...
Definition: gz/sim/components/Factory.hh:499
std::unique_ptr< components::BaseComponent > New(const ComponentTypeId &_type)
Create a new instance of a component.
Definition: gz/sim/components/Factory.hh:404
void Register(const std::string &_type, ComponentDescriptorBase *_compDesc, RegistrationObjectId _regObjId)
Register a component so that the factory can create instances of the component based on an ID.
Definition: gz/sim/components/Factory.hh:285
A base class for an object responsible for creating storages.
Definition: gz/sim/components/Factory.hh:86
A class for an object responsible for creating storages.
Definition: gz/sim/components/Factory.hh:103
T endl(T... args)
T find_if(T... args)
uint64_t ComponentTypeId
A unique identifier for a component type. A component type must be derived from components::BaseCompo...
Definition: include/gz/sim/Types.hh:90
STL namespace.
T prev(T... args)
T push_back(T... args)
A wrapper around uintptr_t to prevent implicit conversions.
Definition: gz/sim/components/Factory.hh:118
std::uintptr_t id
Wrapped uintptr_t variable.
Definition: gz/sim/components/Factory.hh:141
bool operator==(const RegistrationObjectId &_other) const
Equality comparison.
Definition: gz/sim/components/Factory.hh:135
RegistrationObjectId(void *_ptr)
Construct object from a pointer.
Definition: gz/sim/components/Factory.hh:121
RegistrationObjectId(std::uintptr_t _ptrAddress)
Construct object from a uintptr_t.
Definition: gz/sim/components/Factory.hh:128