another try to fix ScanSetup
[enigma2.git] / lib / base / init.h
index 465bac4..6ffd04c 100644 (file)
@@ -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