add stop service
[enigma2.git] / lib / base / init.h
index 465bac40a5ae5db77e7c4e1c287b3c87fb07416a..6ffd04c74e098ab96cffeaea1fe7a75132414c57 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