Safir SDK Core
Loading...
Searching...
No Matches
Safir::Dob::Typesystem::DictionaryContainerBase Class Referenceabstract

Base class for all dictionary containers. More...

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

Inheritance diagram for Safir::Dob::Typesystem::DictionaryContainerBase:
[legend]
Collaboration diagram for Safir::Dob::Typesystem::DictionaryContainerBase:
[legend]

Public Member Functions

 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.
 
virtual size_t size () const =0
 Get the size of the dictionary, i.e number of contained keys.
 
virtual bool empty () const =0
 Check if dictionary is empty.
 
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.

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.
 
virtual ContainerBaseGetValueContainerAt (const size_t index)=0
 Get the container of the value at a particular position in the dictionary.
 
virtual const ContainerBaseGetValueContainerAt (const size_t index) const =0
 Const version of GetValueContainerAt()
 
- 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 IsNull () const =0
 Is the container set to null?
 
virtual void SetNull ()=0
 Set the container to null.
 
virtual bool IsChanged () const
 Is the change flag set on the container?
 
virtual void SetChanged (const bool changed)
 Set the containers change flag.
 
virtual void Copy (const ContainerBase &that)=0
 Virtual assignment.
 

Protected Member Functions

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

Friends

void Utilities::MergeChanges (ObjectPtr into, const ObjectConstPtr &from)
 

Additional Inherited Members

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

Detailed Description

Base class for all dictionary containers.

The reason for the existence of this class is that code that uses the reflection functionality must be able to get hold of members of items.

Constructor & Destructor Documentation

◆ DictionaryContainerBase()

Safir::Dob::Typesystem::DictionaryContainerBase::DictionaryContainerBase ( )

Default Constructor.

Member Function Documentation

◆ empty()

virtual bool Safir::Dob::Typesystem::DictionaryContainerBase::empty ( ) const
pure virtual

Check if dictionary is empty.

Returns
True if dictionary is empty, else false.

Implemented in Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >.

◆ GetKeyAt()

template<class KeyT >
const KeyT & Safir::Dob::Typesystem::DictionaryContainerBase::GetKeyAt ( const size_t index) const

Get the key 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.

This function needs to be called like this: dict.GetKeyAt<Int32>(10). If the dictionary does not have KeyT as its key type the behaviour is undefined.

For enumeration values, use EnumerationValue as the type, and you will get the ordinal value.

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

References GetKeyAtInternal().

Here is the call graph for this function:

◆ GetKeyAtInternal()

virtual const void * Safir::Dob::Typesystem::DictionaryContainerBase::GetKeyAtInternal ( const size_t index) const
protectedpure virtual

Implemented in Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >.

Referenced by GetKeyAt().

Here is the caller graph for this function:

◆ GetValueContainerAt() [1/2]

virtual const ContainerBase & Safir::Dob::Typesystem::DictionaryContainerBase::GetValueContainerAt ( const size_t index) const
pure virtual

◆ GetValueContainerAt() [2/2]

virtual ContainerBase & Safir::Dob::Typesystem::DictionaryContainerBase::GetValueContainerAt ( const size_t index)
pure virtual

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.

Implemented in Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >.

◆ InsertNull()

template<class KeyT >
ContainerBase & Safir::Dob::Typesystem::DictionaryContainerBase::InsertNull ( const KeyT & key)

Adds a new key to the dictionary and return the value container.

If the key already exists, the value will be overwritten.

If the dictionary does not have KeyT as its key type the behaviour is undefined. However if the keyT is an enum type together with a valid enum value, or keyT int togehter with a valid ordinal is allowed.

Parameters
keythe key to be added.
Returns
the value container that belongs to the key.

References InsertNullInternal().

Here is the call graph for this function:

◆ InsertNullInternal()

virtual ContainerBase & Safir::Dob::Typesystem::DictionaryContainerBase::InsertNullInternal ( const void * key,
const std::type_info & typeInfo )
protectedpure virtual

Implemented in Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >.

Referenced by InsertNull().

Here is the caller graph for this function:

◆ IsChangedHere()

bool Safir::Dob::Typesystem::DictionaryContainerBase::IsChangedHere ( ) const

Is the change flag in the container set?

This method is like IsChanged without the recursion.

Returns
True if the containers change flag is set.

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

◆ SetChangedHere()

void Safir::Dob::Typesystem::DictionaryContainerBase::SetChangedHere ( const bool changed)

Set the change flag in the container.

This method is like SetChanged without the recursion

Parameters
changed[in] - The value to set the change flag to.

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

◆ size()

virtual size_t Safir::Dob::Typesystem::DictionaryContainerBase::size ( ) const
pure virtual

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

Returns
The number of values in the dictionary.

Implemented in Safir::Dob::Typesystem::DictionaryContainer< KeyT, ValT >.

Friends And Related Symbol Documentation

◆ Utilities::MergeChanges

void Utilities::MergeChanges ( ObjectPtr into,
const ObjectConstPtr & from )
friend