Public Member Functions | Private Member Functions | Private Attributes

ObjectPtr Class Reference

Generic pointer to objects. More...

#include <keyvalue/value/ObjectPtr.h>

List of all members.

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 >
ObjectPtroperator= (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< ObjectkvPtr_
PtrTraits< void >::Type_ ptr_

Detailed Description

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.


Constructor & Destructor Documentation

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.

Parameters:
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.

Parameters:
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.

Parameters:
rhs : The content.

Member Function Documentation

ObjectPtr & operator= ( const Rhs &  rhs  ) 

Assignment operator.

Takes any type on 2-or-more-levels-down on the value hierarchy.

Parameters:
rhs : The data to be assigned.
Returns:
A reference to 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.

Parameters:
ObjectType : (template parameter) Defines the output type.
Returns:
This method returns a pointer to the object, if the cast succeeds. Otherwise it returns a null pointer.
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.

Parameters:
ObjectType : (template parameter) Defines the output type.
Returns:
This method returns a pointer to the object, if the cast succeeds. Otherwise it returns a null pointer.
void swap ( ObjectPtr other  )  [private]

Swap method.

Parameters:
other : The other ObjectPtr to swap with.