Cogs.Foundation
|
A collection of components, held by component handles. More...
#include <ComponentCollection.h>
Classes | |
class | ComponentCollectionIterator |
Iterator type for iterating over ComponentCollectionBase. More... | |
Public Member Functions | |
ComponentCollectionIterator | begin () const |
Iterator to the beginning of the collection. | |
ComponentCollectionIterator | end () const |
Iterator to the end of the collection. | |
COGSFOUNDATION_API | ComponentCollectionBase () |
Creates an empty component collection. | |
COGSFOUNDATION_API void | add (ComponentHandle component) |
Adds the given component handle to the collection. | |
COGSFOUNDATION_API void | remove (ComponentHandle component) |
Removes the given component from the collection. | |
COGSFOUNDATION_API void | clear () |
Clears the contents of the collection. | |
size_t | size () const |
Get the size of the collection. | |
const ComponentHandle & | operator[] (size_t index) const |
Get the component at the given index. | |
A collection of components, held by component handles.
Component collections can be used to hold a number of component handles, which can represent components of disjoint types.
The lifetimes of the components represented by the handles are not affected by their presence in the collection. This should be managed outside the collection scope.
|
default |
Creates an empty component collection.
void Cogs::ComponentModel::ComponentCollectionBase::add | ( | ComponentHandle | component | ) |
Adds the given component handle to the collection.
The collection does not manage lifetime of the component given by the handle, so it is the callers responsibility to ensure the component stays alive for the lifetime of the collection.
component | Handle to a component. |
Referenced by Cogs::ComponentModel::Entity::getComponents().
|
inline |
Iterator to the beginning of the collection.
void Cogs::ComponentModel::ComponentCollectionBase::clear | ( | ) |
Clears the contents of the collection.
The lifetime of the components referenced by the held handles is not affected by this operation.
Referenced by Cogs::ComponentModel::Entity::getComponents().
|
inline |
Iterator to the end of the collection.
References size().
|
inline |
Get the component at the given index.
void Cogs::ComponentModel::ComponentCollectionBase::remove | ( | ComponentHandle | component | ) |
Removes the given component from the collection.
|
inline |
Get the size of the collection.
Referenced by Cogs::ComponentModel::ComponentCollection< ComponentType >::end(), and end().