Safir SDK Core
Loading...
Searching...
No Matches
Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT > Class Template Reference

Container class for dictionaries of key value pairs. More...

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

Inheritance diagram for Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >:
[legend]
Collaboration diagram for Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >:
[legend]

Public Types

typedef KeyT KeyType
 
typedef ValT ValueContainerType
 
typedef ValueContainerType::ContainedType ContainedType
 
typedef std::map< KeyType, ValueContainerTypeStorageType
 
typedef StorageType::const_iterator const_iterator
 
typedef StorageType::iterator iterator
 
typedef StorageType::value_type value_type
 

Public Member Functions

 DictionaryContainer ()
 Default Constructor.
 
bool IsNull () const override
 Is the container set to null?
 
void SetNull () override
 Set the container to null.
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
iterator find (const KeyType &key)
 
const_iterator find (const KeyType &key) const
 
size_t size () const override
 Get the size of the dictionary, i.e number of contained keys.
 
bool empty () const override
 Check if dictionary is empty.
 
size_t count (const KeyType &key) const
 
ValueContainerTypeoperator[] (const KeyType &key)
 
ValueContainerTypeat (const KeyType &key)
 Like operator[], but throws std::out_of_range if key is not in dictionary.
 
const ValueContainerTypeat (const KeyType &key) const
 Like operator[], but throws std::out_of_range if key is not in dictionary.
 
bool IsChanged () const override
 IsChanged - Check if the dictionary has changed.
 
void SetChanged (const bool changed) override
 SetChanged - Set the change state of the dictionary.
 
void clear ()
 clear - Clear the dictionary, i.e remove all keys/values.
 
void Insert (const KeyType &key, const ContainedType &val)
 
size_t erase (const KeyType &key)
 
void Copy (const ContainerBase &that) override
 Copy - Copy all the members from "that" into "this".
 
Reflection part.

These methods allow applications to manipulate the members of objects without having been compiled against it.

There should be no reason for most applications to use these methods.

const ContainerBaseGetValueContainerAt (const size_t index) const override
 Const version of GetValueContainerAt()
 
ContainerBaseGetValueContainerAt (const size_t index) override
 Get the container of the value at a particular position in the dictionary.
 
- Public Member Functions inherited from Safir::Dob::Typesystem::DictionaryContainerBase
 DictionaryContainerBase ()
 Default Constructor.
 
bool IsChangedHere () const
 Is the change flag in the container set?
 
void SetChangedHere (const bool changed)
 Set the change flag in the container.
 
template<class KeyT >
ContainerBaseInsertNull (const KeyT &key)
 Adds a new key to the dictionary and return the value container.
 
template<class KeyT >
const KeyT & GetKeyAt (const size_t index) const
 Get the key at a particular position in the dictionary.
 
- Public Member Functions inherited from Safir::Dob::Typesystem::ContainerBase
constexpr ContainerBase ()
 Default Constructor.
 
constexpr ContainerBase (const ContainerBase &)=default
 Copy constructor.
 
virtual ~ContainerBase ()
 Virtual destructor.
 

Protected Member Functions

ContainerBaseInsertNullInternal (const void *key, const std::type_info &typeInfo) override
 
const void * GetKeyAtInternal (const size_t index) const override
 
- Protected Member Functions inherited from Safir::Dob::Typesystem::ContainerBase
ContainerBaseoperator= (const ContainerBase &other)
 Copy assignment operator.
 

Additional Inherited Members

- Protected Attributes inherited from Safir::Dob::Typesystem::ContainerBase
bool m_bIsChanged
 The variable containing the change flag.
 

Detailed Description

template<class KeyT, class ValT>
class Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >

Container class for dictionaries of key value pairs.

A dictionary 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.

Member Typedef Documentation

◆ const_iterator

template<class KeyT , class ValT >
typedef StorageType::const_iterator Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::const_iterator

◆ ContainedType

template<class KeyT , class ValT >
typedef ValueContainerType::ContainedType Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::ContainedType

◆ iterator

template<class KeyT , class ValT >
typedef StorageType::iterator Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::iterator

◆ KeyType

template<class KeyT , class ValT >
typedef KeyT Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::KeyType

◆ StorageType

template<class KeyT , class ValT >
typedef std::map<KeyType, ValueContainerType> Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::StorageType

◆ value_type

template<class KeyT , class ValT >
typedef StorageType::value_type Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::value_type

◆ ValueContainerType

template<class KeyT , class ValT >
typedef ValT Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::ValueContainerType

Constructor & Destructor Documentation

◆ DictionaryContainer()

template<class KeyT , class ValT >
Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::DictionaryContainer ( )

Default Constructor.

Construct a container that is not changed and not null.

Member Function Documentation

◆ at() [1/2]

template<class KeyT , class ValT >
ValueContainerType & Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::at ( const KeyType & key)

Like operator[], but throws std::out_of_range if key is not in dictionary.

Referenced by Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::at().

Here is the caller graph for this function:

◆ at() [2/2]

template<class KeyT , class ValT >
const ValueContainerType & Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::at ( const KeyType & key) const

Like operator[], but throws std::out_of_range if key is not in dictionary.

Const version

References Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::at().

Here is the call graph for this function:

◆ begin() [1/2]

template<class KeyT , class ValT >
iterator Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::begin ( )

Referenced by Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::Copy().

Here is the caller graph for this function:

◆ begin() [2/2]

template<class KeyT , class ValT >
const_iterator Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::begin ( ) const

◆ clear()

template<class KeyT , class ValT >
void Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::clear ( )

clear - Clear the dictionary, i.e remove all keys/values.

After a call to clear the dictionary will be empty and hence it will be null too.

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

Referenced by Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::Copy(), and Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::SetNull().

Here is the caller graph for this function:

◆ Copy()

template<class KeyT , class ValT >
void Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::Copy ( const ContainerBase & that)
overridevirtual

Copy - 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.

Note: if types are not compatible the behaviour is undefined.

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

References Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::begin(), Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::clear(), Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::end(), and Safir::Dob::Typesystem::ContainerBase::m_bIsChanged.

Here is the call graph for this function:

◆ count()

template<class KeyT , class ValT >
size_t Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::count ( const KeyType & key) const

Referenced by Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::erase().

Here is the caller graph for this function:

◆ empty()

template<class KeyT , class ValT >
bool Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::empty ( ) const
overridevirtual

Check if dictionary is empty.

Returns
True if dictionary is empty, else false.

Implements Safir::Dob::Typesystem::DictionaryContainerBase.

Referenced by Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::IsNull().

Here is the caller graph for this function:

◆ end() [1/2]

template<class KeyT , class ValT >
iterator Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::end ( )

Referenced by Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::Copy().

Here is the caller graph for this function:

◆ end() [2/2]

template<class KeyT , class ValT >
const_iterator Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::end ( ) const

◆ erase()

template<class KeyT , class ValT >
size_t Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::erase ( const KeyType & key)

References Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::count(), and Safir::Dob::Typesystem::ContainerBase::m_bIsChanged.

Here is the call graph for this function:

◆ find() [1/2]

template<class KeyT , class ValT >
iterator Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::find ( const KeyType & key)

◆ find() [2/2]

template<class KeyT , class ValT >
const_iterator Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::find ( const KeyType & key) const

◆ GetKeyAtInternal()

template<class KeyT , class ValT >
const void * Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::GetKeyAtInternal ( const size_t index) const
overrideprotectedvirtual

Implements Safir::Dob::Typesystem::DictionaryContainerBase.

References __WFILE__, and Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::size().

Here is the call graph for this function:

◆ GetValueContainerAt() [1/2]

template<class KeyT , class ValT >
const ContainerBase & Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::GetValueContainerAt ( const size_t index) const
overridevirtual

Const version of GetValueContainerAt()

Implements Safir::Dob::Typesystem::DictionaryContainerBase.

References Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::GetValueContainerAt().

Referenced by Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::GetValueContainerAt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetValueContainerAt() [2/2]

template<class KeyT , class ValT >
ContainerBase & Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::GetValueContainerAt ( const size_t index)
overridevirtual

Get the container of the value at a particular position in the dictionary.

Note that the order of keys in the dictionary is not guaranteed. This is not a particularly "cheap" way of accessing the contents of a dictionary. Much better to use the iterators in the implementing class.

Parameters
indexan index between 0 and size().
Returns
The container at a position in the dictionary.

Implements Safir::Dob::Typesystem::DictionaryContainerBase.

References __WFILE__, and Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::size().

Here is the call graph for this function:

◆ Insert()

template<class KeyT , class ValT >
void Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::Insert ( const KeyType & key,
const ContainedType & val )

◆ InsertNullInternal()

template<class KeyT , class ValT >
ContainerBase & Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::InsertNullInternal ( const void * key,
const std::type_info & typeInfo )
overrideprotectedvirtual

◆ IsChanged()

template<class KeyT , class ValT >
bool Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::IsChanged ( ) const
overridevirtual

IsChanged - Check if the dictionary has changed.

Returns
True if changed, else false.

Reimplemented from Safir::Dob::Typesystem::ContainerBase.

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

◆ IsNull()

template<class KeyT , class ValT >
bool Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::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::DictionaryContainer< KeyT, ValT >::empty().

Here is the call graph for this function:

◆ operator[]()

template<class KeyT , class ValT >
ValueContainerType & Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::operator[] ( const KeyType & key)

◆ SetChanged()

template<class KeyT , class ValT >
void Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::SetChanged ( const bool changed)
overridevirtual

SetChanged - Set the change state of the dictionary.

Parameters
changed[in] - If true, the dictionary is set to changed, it is set to not changed.

Reimplemented from Safir::Dob::Typesystem::ContainerBase.

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

◆ SetNull()

template<class KeyT , class ValT >
void Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::SetNull ( )
overridevirtual

Set the container to null.

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

References Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::clear().

Here is the call graph for this function:

◆ size()

template<class KeyT , class ValT >
size_t Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::size ( ) const
overridevirtual

Get the size of the dictionary, i.e number of contained keys.

Returns
The number of values in the dictionary.

Implements Safir::Dob::Typesystem::DictionaryContainerBase.

Referenced by Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::GetKeyAtInternal(), and Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >::GetValueContainerAt().

Here is the caller graph for this function: