Cogs.Core
|
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.
Definition at line 18 of file ComponentCollection.h.
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. |
Definition at line 10 of file ComponentCollection.cpp.
Referenced by Cogs::ComponentModel::Entity::getComponents().
|
inline |
Iterator to the beginning of the collection.
Definition at line 84 of file ComponentCollection.h.
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.
Definition at line 22 of file ComponentCollection.cpp.
Referenced by Cogs::ComponentModel::Entity::getComponents().
|
inline |
Iterator to the end of the collection.
Definition at line 91 of file ComponentCollection.h.
References size().
|
inline |
Get the component at the given index.
Definition at line 135 of file ComponentCollection.h.
void Cogs::ComponentModel::ComponentCollectionBase::remove | ( | ComponentHandle | component | ) |
Removes the given component from the collection.
Definition at line 15 of file ComponentCollection.cpp.
|
inline |
Get the size of the collection.
Definition at line 125 of file ComponentCollection.h.
Referenced by Cogs::Core::EntityStore::dumpHierarchy(), Cogs::ComponentModel::ComponentCollection< ComponentType >::end(), and end().