gatb.core-API-0.0.0
LocalObject Class Reference

Local usage of SmartPointer instance. More...

#include <ISmartPointer.hpp>

Public Member Functions

 LocalObject (ISmartPointer *ptr)
 
 ~LocalObject ()
 
ISmartPointergetPtr ()
 

Detailed Description

Local usage of SmartPointer instance.

Small utility for locally getting a reference on a smart pointer. It creates a local (ie created in the execution stack) object that takes a reference on a smart pointer and get rid of it when the execution is out of the statements block holding the local object.

Note that the LocalObject class is very close to the std::auto_ptr. The first one uses inheritance, the second uses templates.

Sample:

void foo ()
{
{
// we create an instance of a class that inherits from SmartPointer and link it to a LocalObject
LocalObject object (new MyClass ());
// we can access the referenced instance
object.getPtr ();
}
// Here, the MyClass instance should have been automatically deleted.
}
See also
LOCAL

Constructor & Destructor Documentation

LocalObject ( ISmartPointer ptr)
inline

Constructor.

Parameters
[in]ptr: the instance we want locally manage.
~LocalObject ( )
inline

Destructor.

Member Function Documentation

ISmartPointer* getPtr ( )
inline

Getter on the referenced instance.

Returns
the referenced SmartPointer instance.

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