diff options
Diffstat (limited to 'lib/base')
| -rw-r--r-- | lib/base/init.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/base/init.h b/lib/base/init.h index 465bac40..6ffd04c7 100644 --- a/lib/base/init.h +++ b/lib/base/init.h @@ -3,6 +3,7 @@ #include <list> #include <utility> +#include <lib/base/object.h> class eAutoInit; @@ -94,4 +95,35 @@ public: } }; +template<class T1> class +eAutoInitPtr: protected eAutoInit +{ + ePtr<T1> t; + void initNow() + { + t = new T1(); + } + void closeNow() + { + t = 0; + } +public: + operator T1*() + { + return t; + } + T1 *operator->() + { + return t; + } + eAutoInitPtr(int runl, char *description): eAutoInit(runl, description) + { + eInit::add(rl, this); + } + ~eAutoInitPtr() + { + eInit::remove(rl, this); + } +}; + #endif |
