qxLib
|
Container for components system. More...
#include <components.h>
Public Member Functions | |
template<std::derived_from< base_component_t > component_t> | |
component_t * | add (std::unique_ptr< component_t > pComponent, priority ePriority=priority::normal, flags< component_status > statusFlags=component_status::default_value) noexcept |
Add a component. More... | |
std::unique_ptr< base_component_t > | remove (const base_component_t *pRawComponent) noexcept |
Remove the component from the container. More... | |
template<std::derived_from< base_component_t > component_t> | |
component_t * | try_get (bool bIncludeDisabled=false) noexcept |
Try to get a component of the given type with the highest priority. More... | |
template<std::derived_from< base_component_t > component_t> | |
const component_t * | try_get (bool bIncludeDisabled=false) const noexcept |
Try to get a component of the given type with the highest priority. More... | |
template<std::derived_from< base_component_t > component_t = base_component_t> | |
component_t * | try_get (class_id id, bool bIncludeDisabled=false) noexcept |
Try to get a component of the given type id with the highest priority. More... | |
template<std::derived_from< base_component_t > component_t = base_component_t> | |
const component_t * | try_get (class_id id, bool bIncludeDisabled=false) const noexcept |
Try to get a component of the given type id with the highest priority. More... | |
template<std::derived_from< base_component_t > component_t> | |
component_t & | get (bool bIncludeDisabled=false) noexcept |
Get a component of the given type with the highest priority (no existence checks are performed) More... | |
template<std::derived_from< base_component_t > component_t> | |
const component_t & | get (bool bIncludeDisabled=false) const noexcept |
Get a component of the given type with the highest priority (no existence checks are performed) More... | |
template<std::derived_from< base_component_t > component_t = base_component_t> | |
base_component_t & | get (class_id id, bool bIncludeDisabled=false) noexcept |
Get a component of the given type with the highest priority (no existence checks are performed) More... | |
template<std::derived_from< base_component_t > component_t = base_component_t> | |
const base_component_t & | get (class_id id, bool bIncludeDisabled=false) const noexcept |
Get a component of the given type with the highest priority (no existence checks are performed) More... | |
template<std::derived_from< base_component_t > component_t = base_component_t> | |
auto | view () noexcept |
Get a view which may be used in a ranged-based for loop and consists of components of a given type with decreasing non-disabled priority. More... | |
template<std::derived_from< base_component_t > component_t = base_component_t> | |
auto | view () const noexcept |
Get a view which may be used in a ranged-based for loop and consists of components of a given type with decreasing non-disabled priority. More... | |
std::optional< flags< component_status > > | get_component_status (const base_component_t *pRawComponent) const noexcept |
Get component status. More... | |
bool | set_component_status (const base_component_t *pRawComponent, flags< component_status > newStatus) noexcept |
Set (override) a component status. More... | |
bool | add_component_status (const base_component_t *pRawComponent, flags< component_status > newStatuses) noexcept |
Add new component status flags to the current ones. More... | |
bool | remove_component_status (const base_component_t *pRawComponent, flags< component_status > statusesToRemove) noexcept |
Add component status flags from the current ones. More... | |
std::optional< priority > | get_component_priority (const base_component_t *pRawComponent) const noexcept |
Get component priority. More... | |
bool | set_component_priority (const base_component_t *pRawComponent, priority eNewComponentPriority) noexcept |
Set component priority. More... | |
bool | empty () const noexcept |
Check if container doesn't have any components. More... | |
void | clear () noexcept |
Clear the container, e.g. remove all the components. | |
Container for components system.
Stores components and allows them to be accessed by a template argument or a class id. Each component has a priority, which is used to iterate through a sequence of objects of a type (final or any super type) or to use getter methods, where a component with the highest priority will be given. You can use qx::priority::disabled to exclude the component from iteration or getters result.
base_component_t | - base component type |
Definition at line 45 of file components.h.
|
noexcept |
Add a component.
component_t | - component type which doesn't have to be a final class type, may be any base or super type |
pComponent | - component object |
ePriority | - initial component priority |
statusFlags | - initial component status |
- | raw component pointer which acts like a component's handle |
Definition at line 28 of file components.inl.
|
noexcept |
Add new component status flags to the current ones.
pRawComponent | - raw component pointer which acts like a component's handle |
newStatuses | - new component status flags |
- | true if a component has been found and a new value has been set |
Definition at line 217 of file components.inl.
|
noexcept |
Check if container doesn't have any components.
- | true if container doesn't have any components |
Definition at line 264 of file components.inl.
|
noexcept |
Get a component of the given type with the highest priority (no existence checks are performed)
component_t | - component type which doesn't have to be a final class type, may be any base or super type |
bIncludeDisabled | - true if a search should include disabled components |
- | component reference |
Definition at line 138 of file components.inl.
|
noexcept |
Get a component of the given type with the highest priority (no existence checks are performed)
component_t | - component type which doesn't have to be a final class type, may be any base or super type |
bIncludeDisabled | - true if a search should include disabled components |
- | component reference |
Definition at line 131 of file components.inl.
|
noexcept |
Get a component of the given type with the highest priority (no existence checks are performed)
component_t | - component type which doesn't have to be a final class type, may be any base or super type |
id | - type id |
bIncludeDisabled | - true if a search should include disabled components |
- | component reference |
Definition at line 152 of file components.inl.
|
noexcept |
Get a component of the given type with the highest priority (no existence checks are performed)
component_t | - component type which doesn't have to be a final class type, may be any base or super type |
id | - type id |
bIncludeDisabled | - true if a search should include disabled components |
- | component reference |
Definition at line 145 of file components.inl.
|
noexcept |
Get component priority.
pRawComponent | - raw component pointer which acts like a component's handle |
- | component priority |
Definition at line 243 of file components.inl.
|
noexcept |
Get component status.
pRawComponent | - raw component pointer which acts like a component's handle |
- | component status |
Definition at line 196 of file components.inl.
|
noexcept |
Remove the component from the container.
pRawComponent | - raw component pointer which acts like a component's handle |
- | component object |
Definition at line 51 of file components.inl.
|
noexcept |
Add component status flags from the current ones.
pRawComponent | - raw component pointer which acts like a component's handle |
statusesToRemove | - component status flags to remove |
- | true if a component has been found and a new value has been set |
Definition at line 230 of file components.inl.
|
noexcept |
Set component priority.
pRawComponent | - raw component pointer which acts like a component's handle |
eNewComponentPriority | - new component priority |
- | true if a component has been found and a new value has been set |
Definition at line 251 of file components.inl.
|
noexcept |
Set (override) a component status.
pRawComponent | - raw component pointer which acts like a component's handle |
newStatus | - new component status |
- | true if a component has been found and a new value has been set |
Definition at line 204 of file components.inl.
|
noexcept |
Try to get a component of the given type with the highest priority.
component_t | - component type which doesn't have to be a final class type, may be any base or super type |
bIncludeDisabled | - true if a search should include disabled components |
- | component pointer or nullptr |
Definition at line 100 of file components.inl.
|
noexcept |
Try to get a component of the given type with the highest priority.
component_t | - component type which doesn't have to be a final class type, may be any base or super type |
bIncludeDisabled | - true if a search should include disabled components |
- | component pointer or nullptr |
Definition at line 85 of file components.inl.
|
noexcept |
Try to get a component of the given type id with the highest priority.
component_t | - component type which doesn't have to be a final class type, may be any base or super type |
id | - type id |
bIncludeDisabled | - true if a search should include disabled components |
- | component pointer or nullptr |
Definition at line 124 of file components.inl.
|
noexcept |
Try to get a component of the given type id with the highest priority.
component_t | - component type which doesn't have to be a final class type, may be any base or super type |
id | - type id |
bIncludeDisabled | - true if a search should include disabled components |
- | component pointer or nullptr |
Definition at line 107 of file components.inl.
|
noexcept |
Get a view which may be used in a ranged-based for loop and consists of components of a given type with decreasing non-disabled priority.
component_t | - component type which doesn't have to be a final class type, may be any base or super type |
- | view of components |
Definition at line 178 of file components.inl.
|
noexcept |
Get a view which may be used in a ranged-based for loop and consists of components of a given type with decreasing non-disabled priority.
component_t | - component type which doesn't have to be a final class type, may be any base or super type |
- | view of components |
Definition at line 159 of file components.inl.