|
Safir SDK Core
|
Container class for sequences of values. More...
#include <Safir/Dob/Typesystem/SequenceContainer.h>
Public Types | |
| typedef T | ContainedType |
| typedef std::deque< T > | StorageType |
| typedef StorageType::const_iterator | const_iterator |
Public Member Functions | |
| SequenceContainer () | |
| Default Constructor. | |
| bool | IsNull () const override |
| Is the container set to null? | |
| void | SetNull () override |
| Set the container to null. | |
| size_t | size () const |
| Get the size of the sequence, i.e number of contained values. | |
| bool | empty () const |
| Check if sequence is empty. | |
| const ContainedType & | front () const |
| Get a const reference to the first value in the sequence. | |
| const ContainedType & | back () const |
| Get a const reference to the last value in the sequence. | |
| const_iterator | begin () const |
| Get const_iterator pointing to the first element in the sequence. | |
| const_iterator | end () const |
| Get const_iterator pointing past the last element in the sequence. | |
| void | clear () |
| Clear the sequence, i.e remove all values. | |
| const ContainedType & | operator[] (const size_t index) const |
| Get const reference to the value with specified index. | |
| const ContainedType & | at (const size_t index) const |
| Get const reference to the value with specified index. | |
| void | push_back (const ContainedType &val) |
| Insert a new value last in the sequence. | |
| void | SetVal (const size_t index, const ContainedType &val) |
| Update a specific value. | |
| const ContainedType & | GetVal (const size_t index) const |
| Get const reference to the value with specified index. | |
| void | InsertAt (const size_t index, const ContainedType &value) |
| Insert a new value at specified index. | |
| void | EraseAt (const size_t index) |
| Erase a value at specified index. | |
| void | Copy (const ContainerBase &that) override |
| Copy all the members from "that" into "this". | |
Public Member Functions inherited from Safir::Dob::Typesystem::ContainerBase | |
| constexpr | ContainerBase () |
| Default Constructor. | |
| constexpr | ContainerBase (const ContainerBase &)=default |
| Copy constructor. | |
| virtual | ~ContainerBase () |
| Virtual destructor. | |
| virtual bool | IsChanged () const |
| Is the change flag set on the container? | |
| virtual void | SetChanged (const bool changed) |
| Set the containers change flag. | |
Additional Inherited Members | |
Protected Member Functions inherited from Safir::Dob::Typesystem::ContainerBase | |
| ContainerBase & | operator= (const ContainerBase &other) |
| Copy assignment operator. | |
Protected Attributes inherited from Safir::Dob::Typesystem::ContainerBase | |
| bool | m_bIsChanged |
| The variable containing the change flag. | |
Container class for sequences of values.
A sequence is a collection of values that can dynamically grow or shrink in size. The whole container has a change flag that will automatically be set when values are added, removed or changed. Values in a sequence cannot be null and does not have individual change flags.
| typedef StorageType::const_iterator Safir::Dob::Typesystem::SequenceContainer< T >::const_iterator |
| typedef T Safir::Dob::Typesystem::SequenceContainer< T >::ContainedType |
| typedef std::deque<T> Safir::Dob::Typesystem::SequenceContainer< T >::StorageType |
| Safir::Dob::Typesystem::SequenceContainer< T >::SequenceContainer | ( | ) |
Default Constructor.
Construct a container that is not changed and not null.
| const ContainedType & Safir::Dob::Typesystem::SequenceContainer< T >::at | ( | const size_t | index | ) | const |
Get const reference to the value with specified index.
| index | [in] - Index of the value to get. |
| std::out_of_range | exception if index is not in range |
| const ContainedType & Safir::Dob::Typesystem::SequenceContainer< T >::back | ( | ) | const |
Get a const reference to the last value in the sequence.
| const_iterator Safir::Dob::Typesystem::SequenceContainer< T >::begin | ( | ) | const |
Get const_iterator pointing to the first element in the sequence.
| void Safir::Dob::Typesystem::SequenceContainer< T >::clear | ( | ) |
Clear the sequence, i.e remove all values.
After a call to clear the sequence will be empty which is implicitly the same as being null.
References Safir::Dob::Typesystem::ContainerBase::m_bIsChanged.
Referenced by Safir::Dob::Typesystem::SequenceContainer< T >::SetNull().
|
overridevirtual |
Copy all the members from "that" into "this".
Types must be the same for this to work!
| that | [in] - The object to copy into this. |
| SoftwareViolationException | If the types are not of the same kind. |
Implements Safir::Dob::Typesystem::ContainerBase.
References __WFILE__, and Safir::Dob::Typesystem::ContainerBase::m_bIsChanged.
| bool Safir::Dob::Typesystem::SequenceContainer< T >::empty | ( | ) | const |
Check if sequence is empty.
Referenced by Safir::Dob::Typesystem::SequenceContainer< T >::IsNull().
| const_iterator Safir::Dob::Typesystem::SequenceContainer< T >::end | ( | ) | const |
Get const_iterator pointing past the last element in the sequence.
| void Safir::Dob::Typesystem::SequenceContainer< T >::EraseAt | ( | const size_t | index | ) |
Erase a value at specified index.
The sequence will shrink.
| index | [in] - Index of the value to be removed. |
References Safir::Dob::Typesystem::ContainerBase::m_bIsChanged.
| const ContainedType & Safir::Dob::Typesystem::SequenceContainer< T >::front | ( | ) | const |
Get a const reference to the first value in the sequence.
| const ContainedType & Safir::Dob::Typesystem::SequenceContainer< T >::GetVal | ( | const size_t | index | ) | const |
Get const reference to the value with specified index.
| index | [in] - Index of the value to get. |
| std::out_of_range | exception if index is not in range |
| void Safir::Dob::Typesystem::SequenceContainer< T >::InsertAt | ( | const size_t | index, |
| const ContainedType & | value ) |
Insert a new value at specified index.
The sequence size will grow.
| index | [in] - Index of the new value. |
| value | [in] - Value to insert. |
References Safir::Dob::Typesystem::ContainerBase::m_bIsChanged.
|
overridevirtual |
Is the container set to null?
Implements Safir::Dob::Typesystem::ContainerBase.
References Safir::Dob::Typesystem::SequenceContainer< T >::empty().
| const ContainedType & Safir::Dob::Typesystem::SequenceContainer< T >::operator[] | ( | const size_t | index | ) | const |
Get const reference to the value with specified index.
Note that no checks are made to see whether index is inside range.
| index | [in] - Index of the value to get. |
| void Safir::Dob::Typesystem::SequenceContainer< T >::push_back | ( | const ContainedType & | val | ) |
Insert a new value last in the sequence.
If the sequence was null before it will no longer be null after a call to push_back.
| val | [in] - Value to be inserted. |
References Safir::Dob::Typesystem::ContainerBase::m_bIsChanged.
|
overridevirtual |
Set the container to null.
Implements Safir::Dob::Typesystem::ContainerBase.
References Safir::Dob::Typesystem::SequenceContainer< T >::clear().
| void Safir::Dob::Typesystem::SequenceContainer< T >::SetVal | ( | const size_t | index, |
| const ContainedType & | val ) |
Update a specific value.
Will not add new values. And indexing outside the sequence will generate an exception.
| index | [in] - Index of the value to set. |
| val | [in] - Value to set. |
| std::out_of_range | exception if index is not in range |
References Safir::Dob::Typesystem::ContainerBase::m_bIsChanged.
| size_t Safir::Dob::Typesystem::SequenceContainer< T >::size | ( | ) | const |
Get the size of the sequence, i.e number of contained values.