MrSID Decode SDK for LiDAR Reference Manual  1.1.4.4709
Scoped< TYPE > Class Template Reference

Scoped is a wrapper class around Object that gives it block scoping. More...

#include <Object.h>

Public Member Functions

 ~Scoped (void)
 Releases the object when Scoped<> goes out of scope. More...
 
 Scoped (void)
 Create an object on the heap. More...
 
 Scoped (TYPE *object)
 Manage an existing object. More...
 
Scopedoperator= (TYPE *object)
 Assignment operator. More...
 
Scopedoperator= (const TYPE *object)
 
 Scoped (const Scoped &object)
 Copy constructor. More...
 
Scopedoperator= (const Scoped &object)
 Assignment operator. More...
 
TYPE * operator-> (void)
 Make Scoped behave like a pointer to TYPE. More...
 
const TYPE * operator-> (void) const
 
TYPE & operator* (void)
 Make Scoped behave like a pointer to TYPE. More...
 
const TYPE & operator* (void) const
 
 operator TYPE *& (void)
 Make Scoped behave like a pointer to TYPE. More...
 
 operator const TYPE *& (void) const
 

Detailed Description

template<typename TYPE>
class Scoped< TYPE >

Scoped is convenience class that give block scoping to reference counted Objects. Scoped<TYPE> tries to act like a TYPE *.

As a convenience class you don't have to use it. Some people find it easier to manage the reference counting themselves.

Example: Without Scoped:

{
FileIO *file = FileIO::create();
try
{
file->init(path, mode);
// use the file object
if(return early)
{
file->release();
return;
}
// use the file object some more
file->release();
}
catch(...)
{
file->release();
throw;
}
}

With Scoped:

{
file->init(path, mode);
// use the file object
if(return early)
return;
// use the file object some more
}
Note
be careful when using this outside of blocked scope. The = operator increments the count which can lead to memory leaks.

Definition at line 152 of file Object.h.

Constructor & Destructor Documentation

template<typename TYPE>
Scoped< TYPE >::~Scoped ( void  )
inline

Definition at line 156 of file Object.h.

References RELEASE().

template<typename TYPE>
Scoped< TYPE >::Scoped ( void  )
inline

Definition at line 159 of file Object.h.

template<typename TYPE>
Scoped< TYPE >::Scoped ( TYPE *  object)
inline

This constructor does not reatin() object, use operator= if you want to retain the object.

Note
Use Scoped<TYPE> object(NULL) to get an empty wrapper.

Definition at line 169 of file Object.h.

template<typename TYPE>
Scoped< TYPE >::Scoped ( const Scoped< TYPE > &  object)
inline

Retain the object.

Definition at line 200 of file Object.h.

Member Function Documentation

template<typename TYPE>
Scoped< TYPE >::operator const TYPE *& ( void  ) const
inline

Definition at line 226 of file Object.h.

template<typename TYPE>
Scoped< TYPE >::operator TYPE *& ( void  )
inline

(use the reference with care)

Definition at line 225 of file Object.h.

template<typename TYPE>
TYPE& Scoped< TYPE >::operator* ( void  )
inline

Definition at line 221 of file Object.h.

template<typename TYPE>
const TYPE& Scoped< TYPE >::operator* ( void  ) const
inline

Definition at line 222 of file Object.h.

template<typename TYPE>
TYPE* Scoped< TYPE >::operator-> ( void  )
inline

Definition at line 218 of file Object.h.

template<typename TYPE>
const TYPE* Scoped< TYPE >::operator-> ( void  ) const
inline

Definition at line 219 of file Object.h.

template<typename TYPE>
Scoped& Scoped< TYPE >::operator= ( TYPE *  object)
inline

The current object is released and the new object is retained.

Definition at line 176 of file Object.h.

References RELEASE(), and RETAIN().

template<typename TYPE>
Scoped& Scoped< TYPE >::operator= ( const TYPE *  object)
inline

Definition at line 185 of file Object.h.

References RELEASE(), and RETAIN().

template<typename TYPE>
Scoped& Scoped< TYPE >::operator= ( const Scoped< TYPE > &  object)
inline

The current object is released and the new object is retained.

Definition at line 207 of file Object.h.

References RELEASE(), and RETAIN().


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

LizardTech