Ignition Gazebo

API Reference

1.0.2
Component< DataType, Identifier > Class Template Reference

A component type that wraps any data type. The intention is for this class to be used to create simple components while avoiding a lot of boilerplate code. The Identifier must be a unique type so that type aliases can be used to create new components. However the type does not need to be defined anywhere eg. using Static = Component<bool, class StaticTag>;. More...

#include <Component.hh>

Public Member Functions

 Component ()
 Default constructor. More...
 
 Component (const DataType &_data)
 Constructor. More...
 
 Component (DataType &&_data)
 Constructor data to be moved. More...
 
 Component (const Component &_component)
 Copy Constructor. More...
 
 Component (Component &&_component) noexcept=default
 Move Constructor. More...
 
 ~Component () override=default
 Destructor. More...
 
DataType & Data ()
 Get the mutable component data. More...
 
const DataType & Data () const
 Get the immutable component data. More...
 
void Deserialize (std::istream &_in) override
 Fills a component based on a stream with a serialized data. By default, it will do nothing. Derived classes should override this function to support deserialization. More...
 
bool operator!= (const Component &_component) const
 Inequality operator. More...
 
Componentoperator= (Component &&_component) noexcept=default
 Move assignment operator. More...
 
Componentoperator= (const Component &_component)
 Copy assignment operator. More...
 
bool operator== (const Component &_component) const
 Equality operator. More...
 
void Serialize (std::ostream &_out) const override
 Fills a stream with a serialized version of the component. By default, it will leave the stream empty. Derived classes should override this function to support serialization. More...
 
ComponentTypeId TypeId () const override
 Returns the unique ID for the component's type. The ID is derived from the name that is manually chosen during the Factory registration and is guaranteed to be the same across compilers and runs. More...
 
- Public Member Functions inherited from BaseComponent
 BaseComponent ()=default
 Default constructor. More...
 
virtual ~BaseComponent ()=default
 Default destructor. More...
 

Static Public Attributes

static ComponentTypeId typeId {0}
 Unique ID for this component type. This is set through the Factory registration. More...
 

Additional Inherited Members

Detailed Description

template<typename DataType, typename Identifier>
class ignition::gazebo::components::Component< DataType, Identifier >

A component type that wraps any data type. The intention is for this class to be used to create simple components while avoiding a lot of boilerplate code. The Identifier must be a unique type so that type aliases can be used to create new components. However the type does not need to be defined anywhere eg. using Static = Component<bool, class StaticTag>;.

Note, however, that this scheme does not have a mechanism to stop someone accidentally defining another component that wraps a bool as such: using AnotherComp = Component<bool, class StaticTag>; In this case, Static and AnotherComp are exactly the same types and would not be differentiable by the EntityComponentManager.

Template Parameters
DataTypeType of the data being wrapped by this component.
IdentifierUnique identifier for the component class, to avoid collision.

Constructor & Destructor Documentation

◆ Component() [1/5]

Component ( )

Default constructor.

Referenced by Component< DataType, Identifier >::Component().

◆ Component() [2/5]

Component ( const DataType &  _data)
explicit

Constructor.

Parameters
[in]_dataData to copy

◆ Component() [3/5]

Component ( DataType &&  _data)
explicit

Constructor data to be moved.

Parameters
[in]_dataData to moved

References Component< DataType, Identifier >::Component(), and Component< DataType, Identifier >::Data().

◆ Component() [4/5]

Component ( const Component< DataType, Identifier > &  _component)

Copy Constructor.

Parameters
[in]_componentComponent component to copy.

◆ Component() [5/5]

Component ( Component< DataType, Identifier > &&  _component)
defaultnoexcept

Move Constructor.

Parameters
[in]_componentComponent component to move.

◆ ~Component()

~Component ( )
overridedefault

Destructor.

Member Function Documentation

◆ Data() [1/2]

◆ Data() [2/2]

const DataType & Data ( ) const

Get the immutable component data.

Returns
Immutable reference to the actual component information.

References Component< DataType, Identifier >::Data(), Component< DataType, Identifier >::operator=(), and Component< DataType, Identifier >::operator==().

◆ Deserialize()

void Deserialize ( std::istream &  )
overridevirtual

Fills a component based on a stream with a serialized data. By default, it will do nothing. Derived classes should override this function to support deserialization.

Reimplemented from BaseComponent.

Reimplemented in LevelEntityNames.

References Component< DataType, Identifier >::Data().

◆ operator!=()

bool operator!= ( const Component< DataType, Identifier > &  _component) const

Inequality operator.

Parameters
[in]_componentComponent to compare to.
Returns
True if different.

References Component< DataType, Identifier >::Data().

Referenced by Component< DataType, Identifier >::operator==().

◆ operator=() [1/2]

Component& operator= ( Component< DataType, Identifier > &&  _component)
defaultnoexcept

Move assignment operator.

Parameters
[in]_componentComponent component to move.
Returns
Reference to this.

Referenced by Component< DataType, Identifier >::Data().

◆ operator=() [2/2]

Component& operator= ( const Component< DataType, Identifier > &  _component)

Copy assignment operator.

Parameters
[in]_componentComponent component to copy.
Returns
Reference to this.

◆ operator==()

bool operator== ( const Component< DataType, Identifier > &  _component) const

Equality operator.

Parameters
[in]_componentComponent to compare to.
Returns
True if equal.

References Component< DataType, Identifier >::Data(), and Component< DataType, Identifier >::operator!=().

Referenced by Component< DataType, Identifier >::Data().

◆ Serialize()

void Serialize ( std::ostream &  ) const
overridevirtual

Fills a stream with a serialized version of the component. By default, it will leave the stream empty. Derived classes should override this function to support serialization.

Reimplemented from BaseComponent.

Reimplemented in LevelEntityNames.

References Component< DataType, Identifier >::Data().

◆ TypeId()

ComponentTypeId TypeId ( ) const
overridevirtual

Returns the unique ID for the component's type. The ID is derived from the name that is manually chosen during the Factory registration and is guaranteed to be the same across compilers and runs.

Implements BaseComponent.

References Component< DataType, Identifier >::typeId.

Member Data Documentation

◆ typeId

ComponentTypeId typeId {0}
inlinestatic

Unique ID for this component type. This is set through the Factory registration.

Referenced by Component< DataType, Identifier >::TypeId(), and Component< NoData, Identifier >::TypeId().


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