![]() |
Safir SDK Core
|
Template class for all containers of automatically generated DOB objects. More...
#include <Safir/Dob/Typesystem/ObjectContainer.h>
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. | |
ObjectContainerImpl & | operator= (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_Ptr & | GetPtr () 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. | |
ContainerBase & | GetMember (const int member, const int index) override |
Get a reference to a member container from an object. | |
const ContainerBase & | GetMember (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. | |
![]() | |
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. | |
![]() | |
constexpr | ContainerBase () |
Default Constructor. | |
constexpr | ContainerBase (const ContainerBase &)=default |
Copy constructor. | |
virtual | ~ContainerBase () |
Virtual destructor. | |
Additional Inherited Members | |
![]() | |
ObjectContainerBase & | operator= (const ObjectContainerBase &other) |
Copy assignment operator. | |
![]() | |
ContainerBase & | operator= (const ContainerBase &other) |
Copy assignment operator. | |
![]() | |
bool | m_bIsChanged |
The variable containing the change flag. | |
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.
T | The type to contain. Must inherit from Dob::Typesystem::Object. |
typedef T_Ptr Safir::Dob::Typesystem::ObjectContainerImpl< T >::ContainedType |
typedef std::shared_ptr<T> Safir::Dob::Typesystem::ObjectContainerImpl< T >::T_Ptr |
Typedef for the contained smart pointer.
Safir::Dob::Typesystem::ObjectContainerImpl< T >::ObjectContainerImpl | ( | ) |
Default constructor.
Creates a null and not changed container.
Safir::Dob::Typesystem::ObjectContainerImpl< T >::ObjectContainerImpl | ( | const ObjectContainerImpl< T > & | other | ) |
Copy constructor.
Copy an object container. The contained object will be cloned.
other | [in] - The object to copy. |
IncompatibleTypesException | Something has gone horribly wrong with your copying! |
References __WFILE__, and Safir::Dob::Typesystem::ObjectContainerImpl< T >::IsNull().
Int32 Safir::Dob::Typesystem::ObjectContainerImpl< T >::CalculateBlobSize | ( | ) | const |
Calculate the size of the blob-serialized form of the contained object.
References Safir::Dob::Typesystem::ObjectContainerImpl< T >::IsNull().
|
overridevirtual |
Virtual assignment.
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__, Safir::Dob::Typesystem::ContainerBase::IsNull(), Safir::Dob::Typesystem::ContainerBase::m_bIsChanged, and Safir::Dob::Typesystem::ObjectContainerImpl< T >::SetObjectPointer().
|
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!
member | [in] - The index of the member to get. |
index | [in] - The array index of the member to get. |
IllegalValueException | If the index is not in the range of the array. |
SoftwareViolationException | If 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().
|
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!
member | [in] - The index of the member to get. |
index | [in] - The array index of the member to get. |
IllegalValueException | If the index is not in the range of the array. |
SoftwareViolationException | If 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().
|
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!
Implements Safir::Dob::Typesystem::ObjectContainerBase.
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.
NullException | The container is null. |
References __WFILE__, and Safir::Dob::Typesystem::ObjectContainerImpl< T >::IsNull().
|
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.
Reimplemented from Safir::Dob::Typesystem::ContainerBase.
References Safir::Dob::Typesystem::ObjectContainerImpl< T >::IsNull(), and Safir::Dob::Typesystem::ContainerBase::m_bIsChanged.
|
overridevirtual |
Is the container set to null?
Implements Safir::Dob::Typesystem::ContainerBase.
Referenced by Safir::Dob::Typesystem::ObjectContainerImpl< T >::ObjectContainerImpl(), Safir::Dob::Typesystem::ObjectContainerImpl< Object >::ObjectContainerImpl(), Safir::Dob::Typesystem::ObjectContainerImpl< T >::CalculateBlobSize(), Safir::Dob::Typesystem::ObjectContainerImpl< T >::GetMember(), Safir::Dob::Typesystem::ObjectContainerImpl< Object >::GetMember(), Safir::Dob::Typesystem::ObjectContainerImpl< T >::GetMember(), Safir::Dob::Typesystem::ObjectContainerImpl< Object >::GetMember(), Safir::Dob::Typesystem::ObjectContainerImpl< T >::GetPtr(), Safir::Dob::Typesystem::ObjectContainerImpl< Object >::GetPtr(), Safir::Dob::Typesystem::ObjectContainerImpl< T >::IsChanged(), Safir::Dob::Typesystem::ObjectContainerImpl< Object >::IsChanged(), Safir::Dob::Typesystem::ObjectContainerImpl< T >::operator->(), Safir::Dob::Typesystem::ObjectContainerImpl< Object >::operator->(), Safir::Dob::Typesystem::ObjectContainerImpl< T >::operator=(), Safir::Dob::Typesystem::ObjectContainerImpl< Object >::operator=(), Safir::Dob::Typesystem::ObjectContainerImpl< T >::SetChanged(), and Safir::Dob::Typesystem::ObjectContainerImpl< Object >::SetChanged().
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.
NullException | The container is null. |
References __WFILE__, and Safir::Dob::Typesystem::ObjectContainerImpl< T >::IsNull().
ObjectContainerImpl & Safir::Dob::Typesystem::ObjectContainerImpl< T >::operator= | ( | const ObjectContainerImpl< T > & | other | ) |
Copy assignment operator.
other | [in] - The object to copy. |
IncompatibleTypesException | The contained types are not compatible! |
References __WFILE__, Safir::Dob::Typesystem::ObjectContainerImpl< T >::IsNull(), and Safir::Dob::Typesystem::ObjectContainerBase::operator=().
|
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.
|
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.
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.
|
overridevirtual |
Set the container to null.
Implements Safir::Dob::Typesystem::ContainerBase.
References Safir::Dob::Typesystem::ContainerBase::m_bIsChanged.
|
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!
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().
|
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.
ptr | [in] A pointer to the new object to point to. |
IncompatibleTypesException | If 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.
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.
ptr | [in] A pointer to the new object to point to. |
References Safir::Dob::Typesystem::ContainerBase::m_bIsChanged.