Safir SDK Core
Loading...
Searching...
No Matches
Safir::Dob::Typesystem::SequenceContainer< T > Class Template Reference

Container class for sequences of values. More...

#include <Safir/Dob/Typesystem/SequenceContainer.h>

Inheritance diagram for Safir::Dob::Typesystem::SequenceContainer< T >:
[legend]
Collaboration diagram for Safir::Dob::Typesystem::SequenceContainer< T >:
[legend]

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 ContainedTypefront () const
 Get a const reference to the first value in the sequence.
 
const ContainedTypeback () 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 ContainedTypeoperator[] (const size_t index) const
 Get const reference to the value with specified index.
 
const ContainedTypeat (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 ContainedTypeGetVal (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
ContainerBaseoperator= (const ContainerBase &other)
 Copy assignment operator.
 
- Protected Attributes inherited from Safir::Dob::Typesystem::ContainerBase
bool m_bIsChanged
 The variable containing the change flag.
 

Detailed Description

template<class T>
class Safir::Dob::Typesystem::SequenceContainer< T >

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.

Member Typedef Documentation

◆ const_iterator

template<class T >
typedef StorageType::const_iterator Safir::Dob::Typesystem::SequenceContainer< T >::const_iterator

◆ ContainedType

template<class T >
typedef T Safir::Dob::Typesystem::SequenceContainer< T >::ContainedType

◆ StorageType

template<class T >
typedef std::deque<T> Safir::Dob::Typesystem::SequenceContainer< T >::StorageType

Constructor & Destructor Documentation

◆ SequenceContainer()

template<class T >
Safir::Dob::Typesystem::SequenceContainer< T >::SequenceContainer ( )

Default Constructor.

Construct a container that is not changed and not null.

Member Function Documentation

◆ at()

template<class T >
const ContainedType & Safir::Dob::Typesystem::SequenceContainer< T >::at ( const size_t index) const

Get const reference to the value with specified index.

Parameters
index[in] - Index of the value to get.
Returns
Const reference to a value.
Exceptions
std::out_of_rangeexception if index is not in range

◆ back()

template<class T >
const ContainedType & Safir::Dob::Typesystem::SequenceContainer< T >::back ( ) const

Get a const reference to the last value in the sequence.

Returns
Reference to last value.

◆ begin()

template<class T >
const_iterator Safir::Dob::Typesystem::SequenceContainer< T >::begin ( ) const

Get const_iterator pointing to the first element in the sequence.

Returns
Iterator pointing to first element.

◆ clear()

template<class T >
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().

Here is the caller graph for this function:

◆ Copy()

template<class T >
void Safir::Dob::Typesystem::SequenceContainer< T >::Copy ( const ContainerBase & that)
overridevirtual

Copy all the members from "that" into "this".

Types must be the same for this to work!

Parameters
that[in] - The object to copy into this.
Exceptions
SoftwareViolationExceptionIf the types are not of the same kind.

Implements Safir::Dob::Typesystem::ContainerBase.

References __WFILE__, and Safir::Dob::Typesystem::ContainerBase::m_bIsChanged.

◆ empty()

template<class T >
bool Safir::Dob::Typesystem::SequenceContainer< T >::empty ( ) const

Check if sequence is empty.

Returns
True if sequence is empty, else false.

Referenced by Safir::Dob::Typesystem::SequenceContainer< T >::IsNull().

Here is the caller graph for this function:

◆ end()

template<class T >
const_iterator Safir::Dob::Typesystem::SequenceContainer< T >::end ( ) const

Get const_iterator pointing past the last element in the sequence.

Returns
Iterator pointing to the end of the sequence.

◆ EraseAt()

template<class T >
void Safir::Dob::Typesystem::SequenceContainer< T >::EraseAt ( const size_t index)

Erase a value at specified index.

The sequence will shrink.

Parameters
index[in] - Index of the value to be removed.

References Safir::Dob::Typesystem::ContainerBase::m_bIsChanged.

◆ front()

template<class T >
const ContainedType & Safir::Dob::Typesystem::SequenceContainer< T >::front ( ) const

Get a const reference to the first value in the sequence.

Returns
Reference to first value.

◆ GetVal()

template<class T >
const ContainedType & Safir::Dob::Typesystem::SequenceContainer< T >::GetVal ( const size_t index) const

Get const reference to the value with specified index.

Parameters
index[in] - Index of the value to get.
Returns
Const reference to a value.
Exceptions
std::out_of_rangeexception if index is not in range

◆ InsertAt()

template<class T >
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.

Parameters
index[in] - Index of the new value.
value[in] - Value to insert.

References Safir::Dob::Typesystem::ContainerBase::m_bIsChanged.

◆ IsNull()

template<class T >
bool Safir::Dob::Typesystem::SequenceContainer< T >::IsNull ( ) const
overridevirtual

Is the container set to null?

Returns
True if the container is set to null.

Implements Safir::Dob::Typesystem::ContainerBase.

References Safir::Dob::Typesystem::SequenceContainer< T >::empty().

Here is the call graph for this function:

◆ operator[]()

template<class T >
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.

Parameters
index[in] - Index of the value to get.
Returns
Const reference to a value.

◆ push_back()

template<class T >
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.

Parameters
val[in] - Value to be inserted.

References Safir::Dob::Typesystem::ContainerBase::m_bIsChanged.

◆ SetNull()

template<class T >
void Safir::Dob::Typesystem::SequenceContainer< T >::SetNull ( )
overridevirtual

Set the container to null.

Implements Safir::Dob::Typesystem::ContainerBase.

References Safir::Dob::Typesystem::SequenceContainer< T >::clear().

Here is the call graph for this function:

◆ SetVal()

template<class T >
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.

Parameters
index[in] - Index of the value to set.
val[in] - Value to set.
Exceptions
std::out_of_rangeexception if index is not in range

References Safir::Dob::Typesystem::ContainerBase::m_bIsChanged.

◆ size()

template<class T >
size_t Safir::Dob::Typesystem::SequenceContainer< T >::size ( ) const

Get the size of the sequence, i.e number of contained values.

Returns
The number of values in the sequence.