RobWorkProject  23.9.11-
Classes | Public Member Functions | Friends | List of all members
AnyPtr Class Reference

Smart pointer that can point to any type, and optionally takes ownership of the object pointer. More...

#include <AnyPtr.hpp>

Public Member Functions

 AnyPtr ()
 Construct empty null pointer.
 
template<typename ValueType >
 AnyPtr (ValueType *value)
 constructor - ownership of pointer is taken More...
 
template<typename ValueType >
 AnyPtr (const rw::core::Ptr< ValueType > &value)
 Construct from Ptr - shares ownership. More...
 
 AnyPtr (const AnyPtr &other)
 Copy constructor - ownership is shared. More...
 
 ~AnyPtr ()
 Destructor.
 
template<class S >
Ptr< S > cast () const
 Cast to a specific smart pointer type. More...
 
template<class S >
S * get () const
 The pointer stored in the object. More...
 
 operator void * () const
 Support for implicit conversion to bool.
 
template<class A >
bool operator== (const Ptr< A > &p) const
 Equality 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== (const AnyPtr &p) const
 Equality 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. More...
 
AnyPtroperator= (const AnyPtr &rhs)
 copy assignemt More...
 
bool isNull () const
 Check if pointer is null. More...
 
const std::type_info & type () const
 Get type info for the object pointed to. More...
 

Friends

template<typename ValueType >
ValueType * cast (AnyPtr *)
 

Detailed Description

Smart pointer that can point to any type, and optionally takes ownership of the object pointer.

Constructor & Destructor Documentation

◆ AnyPtr() [1/3]

AnyPtr ( ValueType *  value)
inline

constructor - ownership of pointer is taken

Parameters
value[in] a raw pointer.

◆ AnyPtr() [2/3]

AnyPtr ( const rw::core::Ptr< ValueType > &  value)
inline

Construct from Ptr - shares ownership.

Parameters
value[in] a smart pointer.

◆ AnyPtr() [3/3]

AnyPtr ( const AnyPtr other)
inline

Copy constructor - ownership is shared.

Parameters
other[in] other AnyPtr object.

Member Function Documentation

◆ cast()

Ptr<S> cast ( ) const
inline

Cast to a specific smart pointer type.

Returns
a Ptr object pointing to object if cast success, otherwise a NULL Ptr object is returned.

◆ get()

S* get ( ) const
inline

The pointer stored in the object.

Returns
raw pointer.

◆ isNull()

bool isNull ( ) const
inline

Check if pointer is null.

Returns
true is the smart pointer is null.

◆ operator=()

AnyPtr& operator= ( const AnyPtr rhs)
inline

copy assignemt

Parameters
rhs[in] the Ptr to copy.

◆ operator==() [1/3]

bool operator== ( const AnyPtr p) const
inline

Equality 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] any pointer to compare with
Returns
true if the referenced objects are the same

◆ operator==() [2/3]

bool operator== ( const Ptr< A > &  p) const
inline

Equality 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

◆ operator==() [3/3]

bool operator== ( void *  p) const
inline

Tests if the smart pointer points to the same instance as p.

Returns
true if equal, false otherwise.

◆ type()

const std::type_info& type ( ) const
inline

Get type info for the object pointed to.

Returns
type_info object.

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