1 #ifndef Protium_DeletionPolicies_h_
2 #define Protium_DeletionPolicies_h_
61 static std::list<DeletionTracker*> TrackerList;
66 template <
typename Host,
typename Destroyer>
91 template <
typename Host,
typename Destroyer>
92 void SetPriority(Host* pDynObject,
unsigned int priority, Destroyer d){
94 std::list<DeletionTracker*>::iterator pos = std::upper_bound( TrackerList.begin(), TrackerList.end(), p,
DeletionTracker::Compare );
95 TrackerList.insert(pos, p);
100 template <
typename Host>
102 SetPriority<Host, typename Deleter< Host >::Type >(pDynObject, priority, d);
105 template <
class Host>
111 template <
class Host>
114 static void OnDeadReference() {
throw std::logic_error(
"Dead Singleton Reference Detected"); }
118 template <
class Host>
131 bool DeleteTwice<Host>::fDestroyed =
false;
133 template <
class Host>
141 static bool firstTime =
true;
166 template <
class Host>
169 template <
class Host>
170 bool DeleteRandom<Host>::fDead =
true;
172 template <
class Host>
173 bool DeleteRandom<Host>::fNeedsCallback =
true;
176 template <
class Host>
187 template <
unsigned int priority,
class Host>
200 template <
class Host>
203 template <
class Host>
206 template <
class Host>
214 typedef std::vector<exit_function_pointer_type>
Container;
219 static bool done =
false;
238 template<
template <
class>
class DestructionPolicy >
244 DestructionPolicy<Host>::ScheduleDestruction(pObj, pFun);
250 template<
template <
class>
class DestructionPolicy >
265 typename DeleteComposite::Composite<Host>::Container* DeleteComposite::Composite<Host>::fContainer = NULL;
272 #endif //File Guardian
static bool Compare(const DeletionTracker *lhs, const DeletionTracker *rhs)
For Comparing priority of deletion.
static bool fNeedsCallback
Abstract class to hold priority for deletion.
unsigned int fPriority
Priority of this class to be deleted (higher implies greater priority)
static void Delete(T *pObj)
Default deletion method.
void(* exit_function_pointer_type)()
Defines the type of functions to be called at exit.
std::vector< exit_function_pointer_type > Container
Destroyer fDestroyer
instance of destroyer
void operator()(T *)
To be used as a callback.
static void ScheduleDestruction(Host *, exit_function_pointer_type pFun)
virtual ~DeletionTracker()=0
Abstract definition.
DeletionTracker(unsigned int x)
Default constructor.
static void OnDeadReference()
static void GracefulDelete()
static Container * fContainer
static exit_function_pointer_type deleter
static void OnDeadReference()
~ConcreteDeletionTracker()
Calls the deletion method.
static void OnDeadReference()
void AtExitFn()
Gets added to the std::atexit queue every time a singleton get created. Called once for every singlet...
Host * fHost
Pointer to the host object.
static void ScheduleDestruction(Host *pObj, exit_function_pointer_type pFun)
static void atexitCallback()
static void ScheduleDestruction(Host *, exit_function_pointer_type pFun)
static void OnDeadReference()
ConcreteDeletionTracker(Host *p, unsigned int priority, Destroyer d)
Container::iterator iterator
static void OnDeadReference()
static void ScheduleDestruction(Host *, exit_function_pointer_type)
void SetPriority(Host *pDynObject, unsigned int priority, Destroyer d)
Helper function for putting an object into the deletion queue.
virtual ~DeleteWithFixedPriority()
static void OnDeadReference()
static void ScheduleDestruction(Host *pObj, exit_function_pointer_type pFun)
exit_function_pointer_type fFun
The Function to be called when the object is deleted.
static void ScheduleDestruction(Host *pObj, exit_function_pointer_type pFun)
static bool Insert(exit_function_pointer_type pFun)
static void OnDeadReference()
static void ScheduleDestruction(Host *, exit_function_pointer_type pFun)
void(* Type)(T *)
Convenience typedef.