Artec 3D Scanning SDK  2.0
Public Types | Public Member Functions | Protected Attributes | List of all members
artec::sdk::base::TRef< T > Class Template Reference

This class is intended for safe manipulation of supported classes in terms of their time frame. More...

#include <artec/sdk/base/TRef.h>

+ Inheritance diagram for artec::sdk::base::TRef< T >:

Public Types

typedef T base
 

Public Member Functions

 TRef (T *p=NULL)
 
 TRef (const TRef< T > &p)
 
 TRef (TRef< T > &&p)
 
 ~TRef ()
 
 operator bool () const
 
T * operator-> () const
 
 operator T * () const
 
const T & operator* () const
 
T & operator* ()
 
TRef< T > & operator= (T *p)
 
TRef< T > & operator= (const TRef< T > &p)
 
TRef< T > & operator= (TRef< T > &&p)
 Move operator. More...
 
T ** operator& ()
 
bool operator== (T *p) const
 
bool operator!= (T *p) const
 
void attach (T *p)
 Attach to the interface pointer without calling addref() for it. More...
 
T * detach ()
 Detach the interface pointer without calling release() for it. More...
 
void release ()
 

Protected Attributes

T * tObject_
 

Detailed Description

template<class T>
class artec::sdk::base::TRef< T >

This class is intended for safe manipulation of supported classes in terms of their time frame.

Those classes should implement IRef interface that provides reference counting support. TRef objects should hold pointers to the instances of such classes. Below is an example of how to create an instance of an IFrameMesh implementation: TRef<IFrameMesh> mesh; createFrameMesh( &mesh ); Operator &() is overloaded so that the createFrameMesh() function can fill the passed TRef with a newly created instance. At the very moment of definition TRef object has a count of references equal to 1.

TRef instance represents a smart pointer paradigm, so the ->() operator is also overloaded in order for the object to be used as a normal pointer: bool isTextured = mesh->isTextured();

TRef can also be used as a deletion controller: { TRef<IFrameMesh> mesh; createFrameMesh( &mesh ); bool isTextured = mesh->isTextured(); } At this point, the TRef object is to be deleted. This will causes deletion of the FrameMesh instance, once the number of references counts downs to 0.

Note that all objects in the API should be created using the appropriate createXXX() functions. So, in order to use this technique, one should create an IRef implementation and the createXXX() function as it is not permitted to use clauses like the following one: TRef<IMyObject> mine( new MyObject ); This leads to memory leak as the count of references will equal 2 (1 from the object constructor and 1 from the TRef constructor. If you need to initialize TRef directly, do it as follows: TRef<IMyObject> object; object.attach( new MyObject() );

Examples:
parallel-capture-sample.cpp, project-sample.cpp, scanning-and-process-sample.cpp, and simple-capture-sample.cpp.

Definition at line 59 of file TRef.h.

Member Typedef Documentation

template<class T>
typedef T artec::sdk::base::TRef< T >::base

Definition at line 62 of file TRef.h.

Constructor & Destructor Documentation

template<class T>
artec::sdk::base::TRef< T >::TRef ( T *  p = NULL)
inline

Definition at line 64 of file TRef.h.

template<class T>
artec::sdk::base::TRef< T >::TRef ( const TRef< T > &  p)
inline

Definition at line 71 of file TRef.h.

template<class T>
artec::sdk::base::TRef< T >::TRef ( TRef< T > &&  p)
inline

Definition at line 79 of file TRef.h.

template<class T>
artec::sdk::base::TRef< T >::~TRef ( )
inline

Definition at line 85 of file TRef.h.

Member Function Documentation

template<class T>
void artec::sdk::base::TRef< T >::attach ( T *  p)
inline

Attach to the interface pointer without calling addref() for it.

Definition at line 170 of file TRef.h.

template<class T>
T* artec::sdk::base::TRef< T >::detach ( )
inline

Detach the interface pointer without calling release() for it.

Definition at line 179 of file TRef.h.

template<class T>
artec::sdk::base::TRef< T >::operator bool ( ) const
inline

Definition at line 91 of file TRef.h.

template<class T>
artec::sdk::base::TRef< T >::operator T * ( ) const
inline

Definition at line 95 of file TRef.h.

template<class T>
bool artec::sdk::base::TRef< T >::operator!= ( T *  p) const
inline

Definition at line 164 of file TRef.h.

template<class T>
T** artec::sdk::base::TRef< T >::operator& ( )
inline

Definition at line 148 of file TRef.h.

template<class T>
const T& artec::sdk::base::TRef< T >::operator* ( ) const
inline

Definition at line 97 of file TRef.h.

template<class T>
T& artec::sdk::base::TRef< T >::operator* ( )
inline

Definition at line 99 of file TRef.h.

template<class T>
T* artec::sdk::base::TRef< T >::operator-> ( ) const
inline

Definition at line 93 of file TRef.h.

template<class T>
TRef<T>& artec::sdk::base::TRef< T >::operator= ( T *  p)
inline

Definition at line 101 of file TRef.h.

template<class T>
TRef<T>& artec::sdk::base::TRef< T >::operator= ( const TRef< T > &  p)
inline

Definition at line 116 of file TRef.h.

template<class T>
TRef<T>& artec::sdk::base::TRef< T >::operator= ( TRef< T > &&  p)
inline

Move operator.

Definition at line 132 of file TRef.h.

template<class T>
bool artec::sdk::base::TRef< T >::operator== ( T *  p) const
inline

Definition at line 159 of file TRef.h.

template<class T>
void artec::sdk::base::TRef< T >::release ( )
inline

Definition at line 186 of file TRef.h.

Member Data Documentation

template<class T>
T* artec::sdk::base::TRef< T >::tObject_
protected

Definition at line 196 of file TRef.h.


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