GlobalObjects
Loading...
Searching...
No Matches
glo::Forgetter< T > Class Template Reference

Especially for GenericPersistent or derived classes of Persistent the Forget method for std::shared_ptr. More...

#include <GloTypes.h>

Public Member Functions

void operator() (T *ptr)
 

Detailed Description

template<typename T>
class glo::Forgetter< T >

Especially for GenericPersistent or derived classes of Persistent the Forget method for std::shared_ptr.

Objects of the type GenericPersistent or derived classes of Persistent have a reference counter and must not be removed from memory using the destructor. Objects with a reference counter may only be instantiated once. When passing to another instance, the reference counter is incremented using Persistent::remember(). If the now owning instance no longer needs the object, the reference counter is decremented using Persistent::forget(). If the reference counter runs to 0, the destructor is called.
This error-prone method can be avoided by using the std::shared_ptr if the Forgetter is passed when instantiating a persistent object.

Example (PersClass is the persistent class):

std::shared_ptr<PersClass> t_NewPersObject( new PersClass(), glo::Forgetter<PersClass>() );
Especially for GenericPersistent or derived classes of Persistent the Forget method for std::shared_p...
Definition GloTypes.h:1234
See also
glo::Persistent::remember(), glo::Persistent::forget().

Member Function Documentation

◆ operator()()

template<typename T >
void glo::Forgetter< T >::operator() ( T * ptr)
inline

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