7 namespace ComponentModel
118 COGSFOUNDATION_API
void clear();
127 return components.size();
137 return components[index];
144 std::vector<ComponentHandle> components;
155 template<
typename ComponentType>
196 ComponentType &
operator*() {
return *collection[index].template resolveComponent<ComponentType>(); }
199 const ComponentType &
operator*()
const {
return *collection[index].template resolveComponent<ComponentType>(); }
202 const ComponentType *
operator->()
const {
return collection[index].template resolveComponent<ComponentType>(); }
Iterator type for iterating over ComponentCollectionBase.
ComponentHandle & reference
Reference type.
const ComponentHandle * operator->() const
Pointer operator. Returns a pointer to the component handle at the current iterator index.
ComponentCollectionIterator(const ComponentCollectionIterator &other)
Create a new iterator, copying the state of other.
size_t difference_type
Difference type to calculate iterator distance.
const ComponentHandle & operator*()
Dereference operator. Returns a reference to the component handle at the iterators current iterator i...
ComponentHandle value_type
Value type.
ComponentCollectionIterator operator++()
Post increment operator. Moves the iterator to the next component handle in the collection.
ComponentHandle * pointer
Pointer type.
std::forward_iterator_tag iterator_category
Type of iterator. Can only be used to iterate forward over component handles in a collection.
const ComponentHandle & operator*() const
Const dereference operator. Returns a const reference to the component handle at the current iterator...
ComponentCollectionIterator & operator++(int)
Pre increment operator. Moves the iterator to the next component handle in the collection.
constexpr bool operator==(const ComponentCollectionIterator &other) const
Comparison operator. If the current index of both iterators are equal the iterators are considered eq...
ComponentCollectionIterator(const ComponentCollectionBase &collection, size_t index)
Creates a new iterator over the given collection with the given index.
A collection of components, held by component handles.
ComponentCollectionIterator begin() const
Iterator to the beginning of the collection.
COGSFOUNDATION_API void add(ComponentHandle component)
Adds the given component handle to 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.
ComponentCollectionIterator end() const
Iterator to the end of the collection.
COGSFOUNDATION_API ComponentCollectionBase()
Creates an empty component collection.
COGSFOUNDATION_API void remove(ComponentHandle component)
Removes the given component from the collection.
COGSFOUNDATION_API void clear()
Clears the contents of the collection.
Iterator type for iterating over typed component collections.
ComponentType & reference
Reference type to the templated ComponentType.
ComponentType value_type
Value type for dereferencing the iterator is the templated ComponentType.
const ComponentType & operator*() const
Const dereference operator. Returns a const reference to the component at the current iterator index.
std::forward_iterator_tag iterator_category
Type of iterator. Can only be used to iterate forward over components in a pool.
ComponentCollectionIterator operator++()
Post increment operator. Moves the iterator to the next component indexed in the collection.
ComponentCollectionIterator & operator++(int)
Pre increment operator. Moves the iterator to the next component indexed in the collection.
size_t difference_type
Difference type to calculate iterator distance.
const ComponentType * operator->() const
Pointer operator. Returns a pointer to the component at the current iterator index.
ComponentType & operator*()
Dereference operator. Returns a reference to the component at the iterators current iterator index.
ComponentCollectionIterator(const ComponentCollectionIterator &other)
Creates a new iterator copying the state of other.
constexpr bool operator==(const ComponentCollectionIterator &other) const
Comparison operator. If the current index of both iterators are equal the iterators are considered eq...
ComponentCollectionIterator(ComponentCollection &collection, size_t index)
Creates a new iterator over the given collection with the given index.
ComponentType * pointer
Pointer type to the templated ComponentType.
Typed collection of components.
ComponentCollectionIterator end()
Iterator to the end of the collection.
ComponentCollectionIterator begin()
Iterator to the beginning of the collection.
Contains all Cogs related functionality.
Handle to a Component instance.