Resources

Topics

RobWorkProject
List of all members | Public Types | Public Member Functions | Related Functions
Ptr< T > Class Template Reference

Ptr stores a pointer and optionally takes ownership of the value. More...

#include <Ptr.hpp>

Public Types

typedef boost::shared_ptr< T > shared_ptr
 The internal type of shared pointer used.
 
typedef T * pointer
 Pointer type.
 
typedef T & reference
 Reference type.
 
typedef T value_type
 Value type.
 

Public Member Functions

 Ptr ()
 Default constructor yielding a NULL-pointer.
 
 Ptr (T *ptr)
 Do not take ownership of ptr. More...
 
 Ptr (shared_ptr ptr)
 Take ownership of ptr. More...
 
template<class S >
Ptr< S > cast ()
 Cast the smart pointer to a different type. More...
 
template<class S >
Ptr< S > cast () const
 Cast the smart pointer to a different type. More...
 
template<class S >
Ptr< S > scast ()
 Cast the smart pointer statically to a different type. More...
 
template<class S >
Ptr< S > scast () const
 Cast the smart pointer statically to a different type. More...
 
template<class S >
 Ptr (Ptr< S > const &p, typename boost::enable_if< boost::is_base_of< T, S > >::type *=0)
 Implicit conversion to a superclass of a ptr.
 
pointer get () const
 The pointer stored in the object.
 
reference operator* () const
 Dereferencing operator.
 
pointer operator-> () const
 Member access operator.
 
 operator void * () const
 Support for implicit conversion to bool.
 
template<class A >
bool operator== (const Ptr< A > &p) const
 equallity operator, this only tests if the pointers to the referenced objects are the same and NOT if the smart pointers are the same. More...
 
bool operator== (void *p) const
 Tests if the smart pointer points to the same instance as p.
 
bool isShared ()
 check if this Ptr has shared ownership or none ownership More...
 
bool isNull () const
 Returns true is the smart pointer is null.
 
boost::shared_ptr< T > getSharedPtr () const
 Returns the boost shared pointer used internally.
 

Related Functions

(Note that these are not member functions.)

template<class T >
Ptr< T > ownedPtr (T *ptr)
 A Ptr that takes ownership over a raw pointer ptr.
 

Detailed Description

template<class T>
class rw::common::Ptr< T >

Ptr stores a pointer and optionally takes ownership of the value.

Constructor & Destructor Documentation

Ptr ( T *  ptr)
inline

Do not take ownership of ptr.

ptr can be null.

The constructor is implicit on purpose.

Ptr ( shared_ptr  ptr)
inline

Take ownership of ptr.

ptr can be null.

The constructor is implicit on purpose.

Member Function Documentation

Ptr<S> cast ( )
inline

Cast the smart pointer to a different type.

Returns
smart pointer that can be null if cast was not possible.
Ptr<S> cast ( ) const
inline

Cast the smart pointer to a different type.

Returns
smart pointer that can be null if cast was not possible.
bool isShared ( )
inline

check if this Ptr has shared ownership or none ownership

Returns
true if Ptr has shared ownership, false if it has no ownership.
bool operator== ( const Ptr< A > &  p) const
inline

equallity operator, this only tests if the pointers to the referenced objects are the same and NOT if the smart pointers are the same.

Parameters
p[in] smart pointer to compare with
Returns
true if the referenced objects are the same
Ptr<S> scast ( )
inline

Cast the smart pointer statically to a different type.

This is more efficient if it is already known that the object is of a certain type. If this is not known, please use the more safe cast() instead.

Returns
smart pointer that can be null if cast was not possible.
Ptr<S> scast ( ) const
inline

Cast the smart pointer statically to a different type.

This is more efficient if it is already known that the object is of a certain type. If this is not known, please use the more safe cast() instead.

Returns
smart pointer that can be null if cast was not possible.

The documentation for this class was generated from the following file: