Cogs.Core
Classes | Public Member Functions | List of all members
Cogs::ComponentModel::ComponentCollectionBase Class Reference

A collection of components, held by component handles. More...

#include <ComponentCollection.h>

Inheritance diagram for Cogs::ComponentModel::ComponentCollectionBase:
Cogs::ComponentModel::ComponentCollection< ComponentType >

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 ComponentHandleoperator[] (size_t index) const
 Get the component at the given index.
 

Detailed Description

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.

Member Function Documentation

◆ add()

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.

Parameters
componentHandle to a component.

Definition at line 10 of file ComponentCollection.cpp.

Referenced by Cogs::ComponentModel::Entity::getComponents().

◆ begin()

ComponentCollectionIterator Cogs::ComponentModel::ComponentCollectionBase::begin ( ) const
inline

Iterator to the beginning of the collection.

Returns
A ComponentCollectionIterator referencing the first handle in the collection, or equal to end() if the collection is empty.

Definition at line 84 of file ComponentCollection.h.

◆ clear()

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().

◆ end()

ComponentCollectionIterator Cogs::ComponentModel::ComponentCollectionBase::end ( ) const
inline

Iterator to the end of the collection.

Returns
A ComponentCollectionIterator representing the end of the collection.

Definition at line 91 of file ComponentCollection.h.

References size().

◆ operator[]()

const ComponentHandle & Cogs::ComponentModel::ComponentCollectionBase::operator[] ( size_t  index) const
inline

Get the component at the given index.

Returns
A const reference to the component at the given location.

Definition at line 135 of file ComponentCollection.h.

◆ remove()

void Cogs::ComponentModel::ComponentCollectionBase::remove ( ComponentHandle  component)

Removes the given component from the collection.

Definition at line 15 of file ComponentCollection.cpp.

◆ size()

size_t Cogs::ComponentModel::ComponentCollectionBase::size ( ) const
inline

Get the size of the collection.

Returns
Number of component handles currently in the collection.

Definition at line 125 of file ComponentCollection.h.

Referenced by Cogs::Core::EntityStore::dumpHierarchy(), Cogs::ComponentModel::ComponentCollection< ComponentType >::end(), and end().


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