Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00030
00031 #ifndef ICL_CORE_SINGLETON_LIFETIME_POLICIES_H_INCLUDED
00032 #define ICL_CORE_SINGLETON_LIFETIME_POLICIES_H_INCLUDED
00033
00034 #include <stdlib.h>
00035 #include <stdexcept>
00036
00037 namespace icl_core {
00038
00040 typedef void (*DestructionFuncPtr)();
00041
00047 template
00048 <class T>
00049 class SLPDefaultLifetime
00050 {
00051 public:
00052 static void scheduleDestruction(DestructionFuncPtr f)
00053 {
00054 atexit(f);
00055 }
00056
00057 static void onDeadReference()
00058 {
00059 throw std::logic_error("attempted to access a singleton instance after its destruction");
00060 }
00061 };
00062
00068 template
00069 <class T>
00070 class SLPNoDestroy
00071 {
00072 public:
00073 static void scheduleDestruction(DestructionFuncPtr)
00074 {
00075 }
00076
00077 static void onDeadReference()
00078 {
00079 }
00080 };
00081
00082 }
00083
00084 #endif