Trax3 3.1.0
trax track library
Loading...
Searching...
No Matches
trax::Collection< Collection_Type, Value_Type > Struct Template Referenceabstract
Inheritance diagram for trax::Collection< Collection_Type, Value_Type >:

Classes

class  iterator_imp

Public Types

using iterator = iterator_imp<value_type,typename std::map<IDType,std::shared_ptr<value_type>>::const_iterator>
using const_iterator = iterator_imp<const value_type,typename std::map<IDType,std::shared_ptr<value_type>>::const_iterator>
Type information for decorator implementation
using collection_type = Collection_Type
using value_type = Value_Type

Public Member Functions

virtual const char * TypeName () const noexcept=0
virtual bool IsValid () const noexcept=0
 Checks whether the elements in this collection are valid.
virtual IDType Add (std::shared_ptr< Value_Type > pValue_Type)=0
 Adds an element to the container and returns its index in the container.
virtual IDType AddRelaxed (std::shared_ptr< Value_Type > pTraxType)=0
 Adds an element to the container and returns its index in the container. Does not throw.
virtual bool Remove (Value_Type *pValue_Type, bool zeroIDs=false)=0
 Removes an element from this container.
virtual int Take (Collection_Type &collection_Type)=0
 Moves all the items from another container to this container.
virtual void Clear ()=0
 Removes all the elements from this container.
virtual int Count () const =0
virtual iterator begin ()=0
virtual const_iterator begin () const =0
virtual const_iterator cbegin () const =0
virtual iterator end ()=0
virtual const_iterator end () const =0
virtual const_iterator cend () const =0
virtual std::shared_ptr< Value_Type > GetFirst () const =0
virtual std::shared_ptr< Value_Type > GetNext (const std::shared_ptr< Value_Type > &pValue_Type) const =0
virtual std::shared_ptr< Value_Type > GetLast () const =0
virtual std::shared_ptr< Value_Type > GetPrevious (const std::shared_ptr< Value_Type > &pValue_Type) const =0
virtual void PushActive (IDType id)=0
 Pushes an element on the activety stack.
virtual void PopActive ()=0
 Pops an element from the activity stack.
virtual std::shared_ptr< Value_Type > GetActive () const =0
virtual void ShiftIDs (int offset)=0
 Adds an offset to all ids.
virtual IDType MaxID () const =0
virtual IDType MinID () const =0
 Collection (const Collection &)=delete
 Collection (Collection &&)=delete
Collection & operator= (const Collection &)=delete
Collection & operator= (Collection &&)=delete
Get

Gets an element from the container.

Parameters
idIdentifier for the object to retreive.
nameName to get the object for.
Returns
A pointer to the requested element.
virtual std::shared_ptr< Value_Type > Get (IDType id) const =0
virtual std::shared_ptr< Value_Type > Get (const std::string &name) const =0
IsMember
Returns
true if the element is a member of the collection; false otherwise.
Parameters
itemreference to element to test for membership.
idUnique id to test wether it is already in use.
virtual bool IsMember (const value_type &item) const =0
virtual bool IsMember (IDType id) const =0

Protected Member Functions

virtual void SetDecorator (Collection_Type *pCollection_TypeDecorator)=0

Protected Attributes

friend Decorator< Collection_Type >

Member Function Documentation

◆ Add()

template<class Collection_Type, class Value_Type>
virtual IDType trax::Collection< Collection_Type, Value_Type >::Add ( std::shared_ptr< Value_Type > pValue_Type)
pure virtual

Adds an element to the container and returns its index in the container.

If the element carries an id, it is used as long as it is unique. If the id is 0 the object is assigned one valid id. If it is not zero but already occupied, an exception is thrown.

Parameters
pValue_TypeObject to get added to the fleet.
Exceptions
std::invalid_argumentif the object is invalid or the objects id is already occupied.

◆ AddRelaxed()

template<class Collection_Type, class Value_Type>
virtual IDType trax::Collection< Collection_Type, Value_Type >::AddRelaxed ( std::shared_ptr< Value_Type > pTraxType)
pure virtual

Adds an element to the container and returns its index in the container. Does not throw.

While the Collection::Add will throw an exception if an element carries an id wich is already occupied, this method will supply the element with a free one. This might lead to other ids becoming occupied without explicitely requested.

◆ begin() [1/2]

template<class Collection_Type, class Value_Type>
virtual const_iterator trax::Collection< Collection_Type, Value_Type >::begin ( ) const
pure virtual
Returns
An const_iterator to the first element in this container.

◆ begin() [2/2]

template<class Collection_Type, class Value_Type>
virtual iterator trax::Collection< Collection_Type, Value_Type >::begin ( )
pure virtual
Returns
An iterator to the first element in this container.

◆ Count()

template<class Collection_Type, class Value_Type>
virtual int trax::Collection< Collection_Type, Value_Type >::Count ( ) const
pure virtual
Returns
the number of elements in this container.

◆ end() [1/2]

template<class Collection_Type, class Value_Type>
virtual const_iterator trax::Collection< Collection_Type, Value_Type >::end ( ) const
pure virtual
Returns
An const_iterator to one past the last element in this container.

◆ end() [2/2]

template<class Collection_Type, class Value_Type>
virtual iterator trax::Collection< Collection_Type, Value_Type >::end ( )
pure virtual
Returns
An iterator to one past the last element in this container.

◆ GetActive()

template<class Collection_Type, class Value_Type>
virtual std::shared_ptr< Value_Type > trax::Collection< Collection_Type, Value_Type >::GetActive ( ) const
pure virtual
Returns
The topmost element on the activity stack.

◆ GetFirst()

template<class Collection_Type, class Value_Type>
virtual std::shared_ptr< Value_Type > trax::Collection< Collection_Type, Value_Type >::GetFirst ( ) const
pure virtual
Returns
A pointer to the first element in this container.

◆ GetLast()

template<class Collection_Type, class Value_Type>
virtual std::shared_ptr< Value_Type > trax::Collection< Collection_Type, Value_Type >::GetLast ( ) const
pure virtual
Returns
A pointer to the last element in this container.

◆ GetNext()

template<class Collection_Type, class Value_Type>
virtual std::shared_ptr< Value_Type > trax::Collection< Collection_Type, Value_Type >::GetNext ( const std::shared_ptr< Value_Type > & pValue_Type) const
pure virtual
Returns
A pointer to the next element in this container.
Parameters
pValue_TypeThe previous element to get the next for.

◆ GetPrevious()

template<class Collection_Type, class Value_Type>
virtual std::shared_ptr< Value_Type > trax::Collection< Collection_Type, Value_Type >::GetPrevious ( const std::shared_ptr< Value_Type > & pValue_Type) const
pure virtual
Returns
A pointer to the previous element in this container.
Parameters
pValue_TypeThe element to get the previous for.

◆ IsValid()

template<class Collection_Type, class Value_Type>
virtual bool trax::Collection< Collection_Type, Value_Type >::IsValid ( ) const
pure virtualnoexcept

Checks whether the elements in this collection are valid.

Returns
true if all the elements are valid.

◆ MaxID()

template<class Collection_Type, class Value_Type>
virtual IDType trax::Collection< Collection_Type, Value_Type >::MaxID ( ) const
pure virtual
Returns
The maximum valid id for an element of the collection. If no element is in the collection, the result will be zero.

◆ MinID()

template<class Collection_Type, class Value_Type>
virtual IDType trax::Collection< Collection_Type, Value_Type >::MinID ( ) const
pure virtual
Returns
The minimum valid id for an element of the collection. If no element is in the collection, the result will be zero.

◆ PopActive()

template<class Collection_Type, class Value_Type>
virtual void trax::Collection< Collection_Type, Value_Type >::PopActive ( )
pure virtual

Pops an element from the activity stack.

Exceptions
std::underflow_errorif the activity stack is empty.

◆ PushActive()

template<class Collection_Type, class Value_Type>
virtual void trax::Collection< Collection_Type, Value_Type >::PushActive ( IDType id)
pure virtual

Pushes an element on the activety stack.

The activity stack stores member elements for later retrieval. If an element is added to the container, it automatically is pushed on the activity stack.

Parameters
idfor the element to push.

◆ Remove()

template<class Collection_Type, class Value_Type>
virtual bool trax::Collection< Collection_Type, Value_Type >::Remove ( Value_Type * pValue_Type,
bool zeroIDs = false )
pure virtual

Removes an element from this container.

Parameters
pValue_TypePointer to object to remove.
zeroIDsIf true sets the IDs of any removed object to 0. If false the ids are freed for the collection, but the objects keep their id values.
Returns
true if the object was found and successfully removed; false otherwise.

◆ ShiftIDs()

template<class Collection_Type, class Value_Type>
virtual void trax::Collection< Collection_Type, Value_Type >::ShiftIDs ( int offset)
pure virtual

Adds an offset to all ids.

If offset is not zero, this will invalidate all ids received prior to the shift.

Parameters
offsetDistance to move the id space.
Exceptions
std::out_of_rangeif by this operation one id would become <= 0.

◆ Take()

template<class Collection_Type, class Value_Type>
virtual int trax::Collection< Collection_Type, Value_Type >::Take ( Collection_Type & collection_Type)
pure virtual

Moves all the items from another container to this container.

The ids of the items might get changed thereby.

Parameters
collection_TypeContainer from wich to take over the elements.
Returns
The offset by which the elements of the collection were offset to maintain unambiguity of ids.

◆ TypeName()

template<class Collection_Type, class Value_Type>
virtual const char * trax::Collection< Collection_Type, Value_Type >::TypeName ( ) const
pure virtualnoexcept
Returns
the name for the object type that implements this interface.

The documentation for this struct was generated from the following file:
  • C:/Trend/Development/Trax3/Code/trax/collections/Collection.h