VEGO-Engine  0.1
Loading...
Searching...
No Matches
DataComponent Class Reference
Inheritance diagram for DataComponent:
[legend]
Collaboration diagram for DataComponent:
[legend]

Public Member Functions

template<typename T>
void setEntry (const std::string &key, const T &value)
 Set a key-value pair of any type in the data map.
 
template<typename T>
std::optional< T > getEntry (std::string key) const
 Get a value of type T from the data map.
 
- Public Member Functions inherited from Component
virtual void init ()
 
virtual void update (uint_fast16_t diffTime)
 

Additional Inherited Members

- Public Attributes inherited from Component
Entityentity
 

Member Function Documentation

◆ getEntry()

template<typename T>
std::optional< T > DataComponent::getEntry ( std::string key) const
inline

Get a value of type T from the data map.

e.g. getEntry<int>("speed"); in this case the key is "speed" and the value is returned as an integer

Parameters
keyThe name to retrieve the value from
Returns
An optional of type T containing the value if it exists and matches in typeid, otherwise std::nullopt

◆ setEntry()

template<typename T>
void DataComponent::setEntry ( const std::string & key,
const T & value )
inline

Set a key-value pair of any type in the data map.

e.g. setEntry("speed", 180); in this case the key is "speed" and the value is set to an integer of 180

Parameters
keyThe name to store the value under
valueThe value to store of type T

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