Fawkes API
Fawkes Development Version
|
RefPtr<> is a reference-counting shared smartpointer. More...
#include <refptr.h>
Public Member Functions | |
RefPtr () | |
Default constructor. More... | |
~RefPtr () | |
Destructor - decrements reference count. More... | |
RefPtr (T_CppObject *cpp_object) | |
Constructor that takes ownership. More... | |
RefPtr (const RefPtr< T_CppObject > &src) | |
Copy constructor This increments the shared reference count. More... | |
template<class T_CastFrom > | |
RefPtr (const RefPtr< T_CastFrom > &src) | |
Copy constructor (from different, but castable type). More... | |
void | swap (RefPtr< T_CppObject > &other) |
Swap the contents of two RefPtr<>. More... | |
RefPtr< T_CppObject > & | operator= (const RefPtr< T_CppObject > &src) |
Copy from another RefPtr. More... | |
template<class T_CastFrom > | |
RefPtr< T_CppObject > & | operator= (const RefPtr< T_CastFrom > &src) |
Copy from different, but castable type). More... | |
RefPtr< T_CppObject > & | operator= (T_CppObject *ptr) |
Assign object and claim ownership. More... | |
bool | operator== (const RefPtr< T_CppObject > &src) const |
Tests whether the RefPtr<> point to the same underlying instance. More... | |
bool | operator!= (const RefPtr< T_CppObject > &src) const |
Tests whether the RefPtr<> do not point to the same underlying instance. More... | |
T_CppObject * | operator-> () const |
Dereferencing. More... | |
T_CppObject * | operator* () const |
Get underlying pointer. More... | |
operator bool () const | |
Test whether the RefPtr<> points to any underlying instance. More... | |
void | clear () |
Set underlying instance to 0, decrementing reference count of existing instance appropriately. More... | |
void | reset () |
Reset pointer. More... | |
RefPtr (T_CppObject *cpp_object, int *refcount, Mutex *refmutex) | |
For use only in the internal implementation of sharedptr. More... | |
int * | refcount_ptr () const |
For use only in the internal implementation of sharedptr. More... | |
int | use_count () const |
Get current reference count. More... | |
Mutex * | refmutex_ptr () const |
For use only in the internal implementation of sharedptr. More... | |
Static Public Member Functions | |
template<class T_CastFrom > | |
static RefPtr< T_CppObject > | cast_dynamic (const RefPtr< T_CastFrom > &src) |
Dynamic cast to derived class. More... | |
template<class T_CastFrom > | |
static RefPtr< T_CppObject > | cast_static (const RefPtr< T_CastFrom > &src) |
Static cast to derived class. More... | |
template<class T_CastFrom > | |
static RefPtr< T_CppObject > | cast_const (const RefPtr< T_CastFrom > &src) |
Cast to non-const. More... | |
Related Functions | |
(Note that these are not member functions.) | |
template<class T_CppObject > | |
void | swap (RefPtr< T_CppObject > &lrp, RefPtr< T_CppObject > &rrp) |
Swap refptr instances. More... | |
RefPtr<> is a reference-counting shared smartpointer.
Reference counting means that a shared reference count is incremented each time a RefPtr is copied, and decremented each time a RefPtr is destroyed, for instance when it leaves its scope. When the reference count reaches zero, the contained object is deleted
Fawkes uses RefPtr so that you don't need to remember to delete the object explicitly, or know when a method expects you to delete the object that it returns.
Note that RefPtr is thread-safe.
|
inline |
Default constructor.
Afterwards it will be null and use of -> will cause a segmentation fault.
Definition at line 263 of file refptr.h.
Referenced by fawkes::RefPtr< Roomba500 >::cast_const().
|
inline |
|
inlineexplicit |
|
inline |
|
inline |
|
inlineexplicit |
|
inlinestatic |
Cast to non-const.
The RefPtr can't be cast with the usual notation so instead you can use
src | source refptr to cast |
|
inlinestatic |
Dynamic cast to derived class.
The RefPtr can't be cast with the usual notation so instead you can use
src | source refptr to cast |
|
inlinestatic |
Static cast to derived class.
Like the dynamic cast; the notation is
src | source refptr to cast |
|
inline |
Set underlying instance to 0, decrementing reference count of existing instance appropriately.
Definition at line 457 of file refptr.h.
Referenced by Roomba500Thread::finalize(), Roomba500Thread::init(), fawkes::OpenRaveEnvironment::run_graspplanning(), JacoOpenraveThread::set_target(), JacoOpenraveThread::set_target_ang(), and JacoGotoThread::stop().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
For use only in the internal implementation of sharedptr.
Get reference count pointer. Warning: This is for internal use only. Do not manually modify the reference count with this pointer.
Definition at line 224 of file refptr.h.
Referenced by fawkes::RefPtr< Roomba500 >::cast_const(), fawkes::RefPtr< Roomba500 >::cast_dynamic(), and fawkes::RefPtr< Roomba500 >::cast_static().
|
inline |
For use only in the internal implementation of sharedptr.
Get reference mutex.
Definition at line 235 of file refptr.h.
Referenced by fawkes::RefPtr< Roomba500 >::cast_const(), fawkes::RefPtr< Roomba500 >::cast_dynamic(), and fawkes::RefPtr< Roomba500 >::cast_static().
|
inline |
Reset pointer.
Set underlying instance to 0, decrementing reference count of existing instance appropriately.
Definition at line 464 of file refptr.h.
Referenced by fawkes::YamlConfiguration::fam_event(), PointCloudDBRetrieveThread::finalize(), PointCloudDBMergeThread::finalize(), LaserClusterThread::finalize(), Bumblebee2Thread::finalize(), KatanaActThread::finalize(), LaserLinesThread::finalize(), TabletopObjectsThread::finalize(), and fawkes::GossipGroupManager::leave_group().
|
inline |
Swap the contents of two RefPtr<>.
This method swaps the internal pointers to T_CppObject. This can be done safely without involving a reference/unreference cycle and is therefore highly efficient.
other | other instance to swap with. |
Definition at line 367 of file refptr.h.
Referenced by fawkes::RefPtr< Roomba500 >::swap().
|
inline |
Get current reference count.
Definition at line 229 of file refptr.h.
Referenced by OpenNiPclOnlyThread::loop(), and Bumblebee2Thread::loop().