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

Template class for all containers of automatically generated DOB objects. More...

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

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

Public Types

typedef std::shared_ptr< T > T_Ptr
 Typedef for the contained smart pointer.
 
typedef T_Ptr ContainedType
 

Public Member Functions

 ObjectContainerImpl ()
 Default constructor.
 
 ObjectContainerImpl (const ObjectContainerImpl &other)
 Copy constructor.
 
ObjectContainerImploperator= (const ObjectContainerImpl &other)
 Copy assignment operator.
 
void SetPtr (const T_Ptr &ptr)
 Set the smart pointer in the container.
 
void SetPtr (const ObjectPtr &ptr) override
 Set the smart pointer in the container.
 
const T_PtrGetPtr () const
 Get the smart pointer from the container.
 
T * operator-> () const
 Dereference the smart pointer in the container.
 
void SetChanged (const bool changed) override
 Set the containers change flag.
 
bool IsChanged () const override
 Is the change flag set on the container?
 
bool IsNull () const override
 Is the container set to null?
 
void SetNull () override
 Set the container to null.
 
void Copy (const ContainerBase &that) override
 Virtual assignment.
 
ContainerBaseGetMember (const int member, const int index) override
 Get a reference to a member container from an object.
 
const ContainerBaseGetMember (const int member, const int index) const override
 Get a const reference to a member container from an object.
 
const ObjectPtr GetObjectPointer () const override
 Get a smart pointer to the contained object.
 
void SetObjectPointer (const ObjectPtr ptr) override
 Set the smart pointer in the container.
 
void ResetObjectPointer () override
 Reset (ie set to null) the contained pointer.
 
Blob serialization/deserialization part.

These functions are for internal use only! Their names and functionality are likely to change in the near future!

Int32 CalculateBlobSize () const
 Calculate the size of the blob-serialized form of the contained object.
 
- Public Member Functions inherited from Safir::Dob::Typesystem::ObjectContainerBase
 ObjectContainerBase ()
 Default constructor.
 
 ObjectContainerBase (const ObjectContainerBase &)=default
 Copy constructor.
 
bool IsChangedHere () const
 Is the change flag in the container set?
 
void SetChangedHere (const bool changed)
 Set the change flag in the container.
 
- Public Member Functions inherited from Safir::Dob::Typesystem::ContainerBase
constexpr ContainerBase ()
 Default Constructor.
 
constexpr ContainerBase (const ContainerBase &)=default
 Copy constructor.
 
virtual ~ContainerBase ()
 Virtual destructor.
 

Additional Inherited Members

- Protected Member Functions inherited from Safir::Dob::Typesystem::ObjectContainerBase
ObjectContainerBaseoperator= (const ObjectContainerBase &other)
 Copy assignment operator.
 
- 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::ObjectContainerImpl< T >

Template class for all containers of automatically generated DOB objects.

This class holds a smart pointer to an object, and has operations to get information from it and modify it. The -> operator is overloaded to make this class more transparent to use.

It is called ObjectContainerImpl because the name ObjectContainer is "taken" by the container that contains a Dob::Typesystem::Object object.

Parameters
TThe type to contain. Must inherit from Dob::Typesystem::Object.

Member Typedef Documentation

◆ ContainedType

template<class T >
typedef T_Ptr Safir::Dob::Typesystem::ObjectContainerImpl< T >::ContainedType

◆ T_Ptr

template<class T >
typedef std::shared_ptr<T> Safir::Dob::Typesystem::ObjectContainerImpl< T >::T_Ptr

Typedef for the contained smart pointer.

Constructor & Destructor Documentation

◆ ObjectContainerImpl() [1/2]

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

Default constructor.

Creates a null and not changed container.

◆ ObjectContainerImpl() [2/2]

template<class T >
Safir::Dob::Typesystem::ObjectContainerImpl< T >::ObjectContainerImpl ( const ObjectContainerImpl< T > & other)

Copy constructor.

Copy an object container. The contained object will be cloned.

Parameters
other[in] - The object to copy.
Exceptions
IncompatibleTypesExceptionSomething has gone horribly wrong with your copying!

References __WFILE__, and Safir::Dob::Typesystem::ObjectContainerImpl< T >::IsNull().

Here is the call graph for this function:

Member Function Documentation

◆ CalculateBlobSize()

template<class T >
Int32 Safir::Dob::Typesystem::ObjectContainerImpl< T >::CalculateBlobSize ( ) const

Calculate the size of the blob-serialized form of the contained object.

Returns
The needed size in bytes. 0 if the container is null.

References Safir::Dob::Typesystem::ObjectContainerImpl< T >::IsNull().

Here is the call graph for this function:

◆ Copy()

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

Virtual assignment.

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__, Safir::Dob::Typesystem::ContainerBase::IsNull(), Safir::Dob::Typesystem::ContainerBase::m_bIsChanged, and Safir::Dob::Typesystem::ObjectContainerImpl< T >::SetObjectPointer().

Here is the call graph for this function:

◆ GetMember() [1/2]

template<class T >
const ContainerBase & Safir::Dob::Typesystem::ObjectContainerImpl< T >::GetMember ( const int member,
const int index ) const
overridevirtual

Get a const reference to a member container from an object.

Use the methods in Members to get member indices and array sizes for use with this method.

Note: Do not use this method unless you're very sure it is the one you need!

Parameters
member[in] - The index of the member to get.
index[in] - The array index of the member to get.
Returns
A const reference to the member container.
Exceptions
IllegalValueExceptionIf the index is not in the range of the array.
SoftwareViolationExceptionIf the element is not an array and the index is not 0.

Implements Safir::Dob::Typesystem::ObjectContainerBase.

References __WFILE__, and Safir::Dob::Typesystem::ObjectContainerImpl< T >::IsNull().

Here is the call graph for this function:

◆ GetMember() [2/2]

template<class T >
ContainerBase & Safir::Dob::Typesystem::ObjectContainerImpl< T >::GetMember ( const int member,
const int index )
overridevirtual

Get a reference to a member container from an object.

Use the methods in Members to get member indices and array sizes for use with this method.

Note: Do not use this method unless you're very sure it is the one you need!

Parameters
member[in] - The index of the member to get.
index[in] - The array index of the member to get.
Returns
A reference to the member container.
Exceptions
IllegalValueExceptionIf the index is not in the range of the array.
SoftwareViolationExceptionIf the element is not an array and the index is not 0.

Implements Safir::Dob::Typesystem::ObjectContainerBase.

References __WFILE__, and Safir::Dob::Typesystem::ObjectContainerImpl< T >::IsNull().

Here is the call graph for this function:

◆ GetObjectPointer()

template<class T >
const ObjectPtr Safir::Dob::Typesystem::ObjectContainerImpl< T >::GetObjectPointer ( ) const
overridevirtual

Get a smart pointer to the contained object.

This method will cast the smart object pointer to the derived type contained by the container to a smart pointer to an Object (the DOB object base class.

This method does not check if the container is null!

Note: Do not use this method unless you're very sure it is the one you need!

Returns
A smart pointer to the contained object.

Implements Safir::Dob::Typesystem::ObjectContainerBase.

◆ GetPtr()

template<class T >
const T_Ptr & Safir::Dob::Typesystem::ObjectContainerImpl< T >::GetPtr ( ) const

Get the smart pointer from the container.

This method will return the contained smart pointer unless the container is null, then an exception will be thrown.

Returns
A smart pointer to the contained object.
Exceptions
NullExceptionThe container is null.

References __WFILE__, and Safir::Dob::Typesystem::ObjectContainerImpl< T >::IsNull().

Here is the call graph for this function:

◆ IsChanged()

template<class T >
bool Safir::Dob::Typesystem::ObjectContainerImpl< T >::IsChanged ( ) const
overridevirtual

Is the change flag set on the container?

The change flag gets updated every time the contained value changes.

Note: If this is a container containing objects this call will recursively check change flags in the contained objects.

Returns
True if the containers change flag is set.

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

References Safir::Dob::Typesystem::ObjectContainerImpl< T >::IsNull(), and Safir::Dob::Typesystem::ContainerBase::m_bIsChanged.

Here is the call graph for this function:

◆ IsNull()

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

◆ operator->()

template<class T >
T * Safir::Dob::Typesystem::ObjectContainerImpl< T >::operator-> ( ) const

Dereference the smart pointer in the container.

This method will call the -> operator on the smart pointer in the container to allow users to directly access members in the object.

Returns
A pointer to the contained object.
Exceptions
NullExceptionThe container is null.

References __WFILE__, and Safir::Dob::Typesystem::ObjectContainerImpl< T >::IsNull().

Here is the call graph for this function:

◆ operator=()

template<class T >
ObjectContainerImpl & Safir::Dob::Typesystem::ObjectContainerImpl< T >::operator= ( const ObjectContainerImpl< T > & other)

Copy assignment operator.

Parameters
other[in] - The object to copy.
Returns
A reference to this.
Exceptions
IncompatibleTypesExceptionThe contained types are not compatible!

References __WFILE__, Safir::Dob::Typesystem::ObjectContainerImpl< T >::IsNull(), and Safir::Dob::Typesystem::ObjectContainerBase::operator=().

Here is the call graph for this function:

◆ ResetObjectPointer()

template<class T >
void Safir::Dob::Typesystem::ObjectContainerImpl< T >::ResetObjectPointer ( )
overridevirtual

Reset (ie set to null) the contained pointer.

Warning: This method does not update the change flag!

Note: Do not use this method unless you're very sure it is the one you need!

Implements Safir::Dob::Typesystem::ObjectContainerBase.

◆ SetChanged()

template<class T >
void Safir::Dob::Typesystem::ObjectContainerImpl< T >::SetChanged ( const bool changed)
overridevirtual

Set the containers change flag.

It should be fairly unusual for an application to have to use this operation. There is nothing dangerous about it, but are you sure this is the operation you were after?

The change flag is how receivers of objects can work out what the sender really wanted done on the object.

Note: If this is a container containing one or more objects this call will recursively set all the change flags in the contained objects.

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

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

References Safir::Dob::Typesystem::ObjectContainerImpl< T >::IsNull(), and Safir::Dob::Typesystem::ContainerBase::m_bIsChanged.

Here is the call graph for this function:

◆ SetNull()

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

◆ SetObjectPointer()

template<class T >
void Safir::Dob::Typesystem::ObjectContainerImpl< T >::SetObjectPointer ( const ObjectPtr ptr)
overridevirtual

Set the smart pointer in the container.

This method will set the contained pointer to point to another object. Checks are NOT always made to see that it is of the correct type.

Warning: This method does not update the change flag!

Note: Do not use this method unless you're very sure it is the one you need!

Parameters
ptr[in] A pointer to the new object to point to.

Implements Safir::Dob::Typesystem::ObjectContainerBase.

References __WFILE__.

Referenced by Safir::Dob::Typesystem::ObjectContainerImpl< T >::Copy(), and Safir::Dob::Typesystem::ObjectContainerImpl< Object >::Copy().

Here is the caller graph for this function:

◆ SetPtr() [1/2]

template<class T >
void Safir::Dob::Typesystem::ObjectContainerImpl< T >::SetPtr ( const ObjectPtr & ptr)
overridevirtual

Set the smart pointer in the container.

This method will set the contained pointer to point to another object. Checks are always made to see that it is of the correct type. The change flag of the container will be updated.

Parameters
ptr[in] A pointer to the new object to point to.
Exceptions
IncompatibleTypesExceptionIf the ptr is not of the type contained by the container.

Implements Safir::Dob::Typesystem::ObjectContainerBase.

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

◆ SetPtr() [2/2]

template<class T >
void Safir::Dob::Typesystem::ObjectContainerImpl< T >::SetPtr ( const T_Ptr & ptr)

Set the smart pointer in the container.

This method will set the contained pointer to point to another object. The change flag of the container will be updated.

Parameters
ptr[in] A pointer to the new object to point to.

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