Cogs.Foundation
Loading...
Searching...
No Matches
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.

Constructor & Destructor Documentation

◆ ComponentCollectionBase()

Cogs::ComponentModel::ComponentCollectionBase::ComponentCollectionBase ( )
default

Creates an empty component collection.

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.

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.

◆ 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.

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.

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.

◆ remove()

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

Removes the given component from the collection.

◆ size()

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

Get the size of the collection.

Returns
Number of component handles currently in the collection.

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


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