Scoped< TYPE > Class Template Reference
Scoped is a wrapper class around Object that gives it block scoping.
More...
#include <Object.h>
List of all members.
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);
if(return early)
{
file->release();
return;
}
file->release();
}
catch(...)
{
file->release();
throw;
}
}
With Scoped:
{
Scoped<FileIO> file;
file->init(path, mode);
if(return early)
return;
}
- 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
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.
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] |
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>
const TYPE& Scoped< TYPE >::operator* |
( |
void |
|
) |
const [inline] |
template<typename TYPE>
TYPE& Scoped< TYPE >::operator* |
( |
void |
|
) |
[inline] |
template<typename TYPE>
const TYPE* Scoped< TYPE >::operator-> |
( |
void |
|
) |
const [inline] |
template<typename TYPE>
TYPE* Scoped< TYPE >::operator-> |
( |
void |
|
) |
[inline] |
template<typename TYPE>
Scoped& Scoped< TYPE >::operator= |
( |
const TYPE * |
object |
) |
[inline] |
template<typename TYPE>
Scoped& Scoped< TYPE >::operator= |
( |
TYPE * |
object |
) |
[inline] |
The documentation for this class was generated from the following file: