7 namespace ComponentModel
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>(); }
#define COGSFOUNDATION_API
Definition: FoundationBase.h:31
Iterator type for iterating over ComponentCollectionBase.
Definition: ComponentCollection.h:25
ComponentHandle & reference
Reference type.
Definition: ComponentCollection.h:40
const ComponentHandle * operator->() const
Pointer operator. Returns a pointer to the component handle at the current iterator index.
Definition: ComponentCollection.h:64
ComponentCollectionIterator(const ComponentCollectionIterator &other)
Create a new iterator, copying the state of other.
Definition: ComponentCollection.h:46
size_t difference_type
Difference type to calculate iterator distance.
Definition: ComponentCollection.h:34
const ComponentHandle & operator*()
Dereference operator. Returns a reference to the component handle at the iterators current iterator i...
Definition: ComponentCollection.h:58
ComponentHandle value_type
Value type.
Definition: ComponentCollection.h:31
ComponentCollectionIterator operator++()
Post increment operator. Moves the iterator to the next component handle in the collection.
Definition: ComponentCollection.h:52
ComponentHandle * pointer
Pointer type.
Definition: ComponentCollection.h:37
std::forward_iterator_tag iterator_category
Type of iterator. Can only be used to iterate forward over component handles in a collection.
Definition: ComponentCollection.h:28
const ComponentHandle & operator*() const
Const dereference operator. Returns a const reference to the component handle at the current iterator...
Definition: ComponentCollection.h:61
ComponentCollectionIterator & operator++(int)
Pre increment operator. Moves the iterator to the next component handle in the collection.
Definition: ComponentCollection.h:55
constexpr bool operator==(const ComponentCollectionIterator &other) const
Comparison operator. If the current index of both iterators are equal the iterators are considered eq...
Definition: ComponentCollection.h:49
ComponentCollectionIterator(const ComponentCollectionBase &collection, size_t index)
Creates a new iterator over the given collection with the given index.
Definition: ComponentCollection.h:43
A collection of components, held by component handles.
Definition: ComponentCollection.h:19
ComponentCollectionIterator begin() const
Iterator to the beginning of the collection.
Definition: ComponentCollection.h:84
COGSFOUNDATION_API void add(ComponentHandle component)
Adds the given component handle to the collection.
Definition: ComponentCollection.cpp:10
size_t size() const
Get the size of the collection.
Definition: ComponentCollection.h:125
const ComponentHandle & operator[](size_t index) const
Get the component at the given index.
Definition: ComponentCollection.h:135
ComponentCollectionIterator end() const
Iterator to the end of the collection.
Definition: ComponentCollection.h:91
COGSFOUNDATION_API ComponentCollectionBase()
Creates an empty component collection.
COGSFOUNDATION_API void remove(ComponentHandle component)
Removes the given component from the collection.
Definition: ComponentCollection.cpp:15
COGSFOUNDATION_API void clear()
Clears the contents of the collection.
Definition: ComponentCollection.cpp:22
Iterator type for iterating over typed component collections.
Definition: ComponentCollection.h:163
ComponentType & reference
Reference type to the templated ComponentType.
Definition: ComponentCollection.h:178
ComponentType value_type
Value type for dereferencing the iterator is the templated ComponentType.
Definition: ComponentCollection.h:169
const ComponentType & operator*() const
Const dereference operator. Returns a const reference to the component at the current iterator index.
Definition: ComponentCollection.h:199
std::forward_iterator_tag iterator_category
Type of iterator. Can only be used to iterate forward over components in a pool.
Definition: ComponentCollection.h:166
ComponentCollectionIterator operator++()
Post increment operator. Moves the iterator to the next component indexed in the collection.
Definition: ComponentCollection.h:190
ComponentCollectionIterator & operator++(int)
Pre increment operator. Moves the iterator to the next component indexed in the collection.
Definition: ComponentCollection.h:193
size_t difference_type
Difference type to calculate iterator distance.
Definition: ComponentCollection.h:172
const ComponentType * operator->() const
Pointer operator. Returns a pointer to the component at the current iterator index.
Definition: ComponentCollection.h:202
ComponentType & operator*()
Dereference operator. Returns a reference to the component at the iterators current iterator index.
Definition: ComponentCollection.h:196
ComponentCollectionIterator(const ComponentCollectionIterator &other)
Creates a new iterator copying the state of other.
Definition: ComponentCollection.h:184
constexpr bool operator==(const ComponentCollectionIterator &other) const
Comparison operator. If the current index of both iterators are equal the iterators are considered eq...
Definition: ComponentCollection.h:187
ComponentCollectionIterator(ComponentCollection &collection, size_t index)
Creates a new iterator over the given collection with the given index.
Definition: ComponentCollection.h:181
ComponentType * pointer
Pointer type to the templated ComponentType.
Definition: ComponentCollection.h:175
Typed collection of components.
Definition: ComponentCollection.h:157
ComponentCollectionIterator end()
Iterator to the end of the collection.
Definition: ComponentCollection.h:229
ComponentCollectionIterator begin()
Iterator to the beginning of the collection.
Definition: ComponentCollection.h:222
Main Cogs namespace.
Definition: MortonCode.h:5
Handle to a Component instance.
Definition: Component.h:67