A container for a group of properties.
More...
#include <PropertyContainer.h>
A container for a group of properties.
Definition at line 38 of file PropertyContainer.h.
◆ Callback
template<typename... Args>
◆ addProperty()
bool ime::PropertyContainer::addProperty |
( |
const Property & |
Property | ) |
|
Add a property.
- Parameters
-
- Returns
- True if the property was added or false if a property with the same name already exits
◆ clear()
void ime::PropertyContainer::clear |
( |
| ) |
|
Remove all the stored properties from the container.
◆ forEachProperty()
void ime::PropertyContainer::forEachProperty |
( |
const Callback< Property & > & |
callback | ) |
|
Execute a callback for each property in the container.
- Parameters
-
callback | The function to be executed |
The callback is passed the property on each invocation
◆ getSize()
std::size_t ime::PropertyContainer::getSize |
( |
| ) |
const |
Get the number of properties in the container.
- Returns
- The number of properties in the container
◆ getValue()
template<typename T >
T ime::PropertyContainer::getValue |
( |
const std::string & |
name | ) |
const |
Get the value of a property.
- Parameters
-
name | Name of the property to get value for |
- Exceptions
-
std::bad_any_cast | if the value stored by the property is not of type T |
- Returns
- Value of a property
This function will throw an exception if the template argument T and the type of the stored value don't match. This means that the property must always have a value before calling this function
- See also
- propertyHasValue
-
setValue
◆ hasProperty()
bool ime::PropertyContainer::hasProperty |
( |
const std::string & |
name | ) |
const |
Check if container has a given property.
- Parameters
-
name | Name of the property to check |
- Returns
- True if property exists, otherwise false
◆ propertyHasValue()
bool ime::PropertyContainer::propertyHasValue |
( |
const std::string & |
name | ) |
const |
Check if a property has a value or not.
- Parameters
-
name | Name of the property to be checked |
- Returns
- True if property has value or false if the property does not have a value or does not exist
- See also
- hasProperty
◆ removeProperty()
bool ime::PropertyContainer::removeProperty |
( |
const std::string & |
name | ) |
|
Remove a property.
- Parameters
-
name | Name of the property to remove |
- Returns
- True if the property was removed or false if the specified property doesnt exist
◆ setValue()
template<typename T >
void ime::PropertyContainer::setValue |
( |
const std::string & |
name, |
|
|
T && |
value |
|
) |
| |
Set the value of a property.
- Parameters
-
name | Name of the property to set value for |
value | New value of the property |
The type of
- Template Parameters
-
T | must be remembered in order to retrieve the value later |
- See also
- getValue
The documentation for this class was generated from the following file: