X-Git-Url: http://code.vuplus.com/gitweb/?p=vuplus_dvbapp;a=blobdiff_plain;f=lib%2Fbase%2Finit.h;h=4b40bea026b4614744e0ae213605efd436d246a5;hp=465bac40a5ae5db77e7c4e1c287b3c87fb07416a;hb=849b33656dc710cfa5f644a55680fd396ab1d8d7;hpb=d63d2c3c6cbbd574dda4f8b00ebe6c661735edd5 diff --git a/lib/base/init.h b/lib/base/init.h index 465bac4..4b40bea 100644 --- a/lib/base/init.h +++ b/lib/base/init.h @@ -3,6 +3,7 @@ #include #include +#include class eAutoInit; @@ -26,9 +27,9 @@ class eAutoInit virtual void closeNow()=0; protected: int rl; - char *description; + const char *description; public: - eAutoInit(int rl, char *description): rl(rl), description(description) + eAutoInit(int rl, const char *description): rl(rl), description(description) { } virtual ~eAutoInit(); @@ -53,7 +54,7 @@ public: { return t; } - eAutoInitP1(const T2 &arg, int runl, char *description): eAutoInit(runl, description), arg(arg) + eAutoInitP1(const T2 &arg, int runl, const char *description): eAutoInit(runl, description), arg(arg) { eInit::add(rl, this); } @@ -84,7 +85,7 @@ public: { return t; } - eAutoInitP0(int runl, char *description): eAutoInit(runl, description) + eAutoInitP0(int runl, const char *description): eAutoInit(runl, description) { eInit::add(rl, this); } @@ -94,4 +95,35 @@ public: } }; +template class +eAutoInitPtr: protected eAutoInit +{ + ePtr t; + void initNow() + { + t = new T1(); + } + void closeNow() + { + t = 0; + } +public: + operator T1*() + { + return t; + } + T1 *operator->() + { + return t; + } + eAutoInitPtr(int runl, const char *description): eAutoInit(runl, description) + { + eInit::add(rl, this); + } + ~eAutoInitPtr() + { + eInit::remove(rl, this); + } +}; + #endif