Generic pointer to objects. More...
#include <keyvalue/value/ObjectPtr.h>
Public Member Functions | |
ObjectPtr () | |
Builds a null pointer. | |
template<typename ObjectType > | |
ObjectPtr (const shared_ptr< ObjectType > &ptr, typename::boost::enable_if< ::boost::is_base_of< Object, ObjectType > >::type *dummy=0) | |
Builds a pointer pointing to a KeyValue object. | |
template<typename ObjectType , template< typename > class SmartPtr> | |
ObjectPtr (const SmartPtr< ObjectType > &ptr, typename::boost::disable_if< ::boost::is_base_of< Object, ObjectType > >::type *dummy=0) | |
Builds a pointer pointing to a non KeyValue object. | |
template<typename Rhs > | |
ObjectPtr (const Rhs &rhs) | |
Builds and sets content. | |
template<typename Rhs > | |
ObjectPtr & | operator= (const Rhs &rhs) |
Assignment operator. | |
operator bool () const | |
Automatic conversion to bool . | |
template<typename ObjectType > | |
shared_ptr< ObjectType > | cast (typename::boost::enable_if< ::boost::is_base_of< Object, ObjectType > >::type *dummy=0) const |
Cast to shared_ptr<ObjectType>Type_. | |
template<typename ObjectType > | |
PtrTraits< ObjectType >::Type_ | cast (typename::boost::disable_if< ::boost::is_base_of< Object, ObjectType > >::type *dummy=0) const |
Cast to PtrTraits<ObjectType>Type_. | |
Private Member Functions | |
void | swap (ObjectPtr &other) |
Swap method. | |
Private Attributes | |
shared_ptr< Object > | kvPtr_ |
PtrTraits< void >::Type_ | ptr_ |
Generic pointer to objects.
Recall that Processors deal with different types of objects and there should be a heterogeneous way to store them in the repository. This class
is a wrapper for a smart pointer class
that, through type erasure, can point to different types of objects.
This class
also performs casts between typed and type-erased pointers in such a way that Processors deal with the typed pointers.
ObjectPtr | ( | ) |
Builds a null pointer.
A null pointer is one that cannot be casted to any typed pointer and when casted to bool
yields false
.
ObjectPtr | ( | const shared_ptr< ObjectType > & | ptr, | |
typename::boost::enable_if< ::boost::is_base_of< Object, ObjectType > >::type * | dummy = 0 | |||
) |
Builds a pointer pointing to a KeyValue object.
ptr | : The pointer to be built from. | |
dummy | : Used for SFINAE. DO NOT CHANGE IT! |
ObjectPtr | ( | const SmartPtr< ObjectType > & | ptr, | |
typename::boost::disable_if< ::boost::is_base_of< Object, ObjectType > >::type * | dummy = 0 | |||
) |
Builds a pointer pointing to a non KeyValue object.
ObjectType | : (template parameter) Type of object. | |
SmartPtr | : (template template parameter) A smart pointer template class . It must be such that PtrTraits<ObjectType>Type_ = SmartPtr<ObjectType>. | |
ptr | : The pointer to be assigned. |
ObjectPtr | ( | const Rhs & | rhs | ) |
Builds and sets content.
Takes any type on 2-or-more-levels-down on the value hierarchy.
rhs | : The content. |
ObjectPtr & operator= | ( | const Rhs & | rhs | ) |
Assignment operator.
Takes any type on 2-or-more-levels-down on the value hierarchy.
rhs | : The data to be assigned. |
this
. operator bool | ( | ) | const |
Automatic conversion to bool
.
To allow usage of ObjectPtr
in conditional expressions.
shared_ptr< ObjectType > cast | ( | typename::boost::enable_if< ::boost::is_base_of< Object, ObjectType > >::type * | dummy = 0 |
) | const |
Cast to shared_ptr<ObjectType>Type_.
If the internal pointer points to an object of type ObjectType, then the cast succeeds.
ObjectType | : (template parameter) Defines the output type. |
PtrTraits< ObjectType >::Type_ cast | ( | typename::boost::disable_if< ::boost::is_base_of< Object, ObjectType > >::type * | dummy = 0 |
) | const |
Cast to PtrTraits<ObjectType>Type_.
If the internal pointer points to an object of type ObjectType, then the cast succeeds.
ObjectType | : (template parameter) Defines the output type. |