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... | |
Component & | operator= (Component &&_component) noexcept=default |
Move assignment operator. More... | |
Component & | operator= (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
-
DataType Type of the data being wrapped by this component. Identifier Unique 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]
|
explicit |
Constructor.
- Parameters
-
[in] _data Data to copy
◆ Component() [3/5]
|
explicit |
Constructor data to be moved.
- Parameters
-
[in] _data Data to moved
References Component< DataType, Identifier >::Component(), and Component< DataType, Identifier >::Data().
◆ Component() [4/5]
Copy Constructor.
- Parameters
-
[in] _component Component component to copy.
◆ Component() [5/5]
Move Constructor.
- Parameters
-
[in] _component Component component to move.
◆ ~Component()
|
overridedefault |
Destructor.
Member Function Documentation
◆ Data() [1/2]
DataType & Data | ( | ) |
Get the mutable component data.
- Returns
- Mutable reference to the actual component information.
Referenced by Component< DataType, Identifier >::Component(), Component< DataType, Identifier >::Data(), LevelEntityNames::Deserialize(), Component< DataType, Identifier >::Deserialize(), Component< DataType, Identifier >::operator!=(), Component< DataType, Identifier >::operator==(), LevelEntityNames::Serialize(), and Component< DataType, Identifier >::Serialize().
◆ 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()
|
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] _component Component to compare to.
- Returns
- True if different.
References Component< DataType, Identifier >::Data().
Referenced by Component< DataType, Identifier >::operator==().
◆ operator=() [1/2]
Move assignment operator.
- Parameters
-
[in] _component Component component to move.
- Returns
- Reference to this.
Referenced by Component< DataType, Identifier >::Data().
◆ operator=() [2/2]
Copy assignment operator.
- Parameters
-
[in] _component Component component to copy.
- Returns
- Reference to this.
◆ operator==()
bool operator== | ( | const Component< DataType, Identifier > & | _component | ) | const |
Equality operator.
- Parameters
-
[in] _component Component to compare to.
- Returns
- True if equal.
References Component< DataType, Identifier >::Data(), and Component< DataType, Identifier >::operator!=().
Referenced by Component< DataType, Identifier >::Data().
◆ Serialize()
|
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()
|
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
|
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: