GlobalObjects
Loading...
Searching...
No Matches
glo::Forgeter< 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::Forgeter< 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 Forgeter is passed when instantiating a persistent object.

Example (PersClass is the persistent class):

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

Member Function Documentation

◆ operator()()

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

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