summaryrefslogtreecommitdiff
path: root/plugins/Skins/SkinLib/scope.h
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Skins/SkinLib/scope.h')
-rw-r--r--plugins/Skins/SkinLib/scope.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/plugins/Skins/SkinLib/scope.h b/plugins/Skins/SkinLib/scope.h
new file mode 100644
index 0000000000..2fad797b88
--- /dev/null
+++ b/plugins/Skins/SkinLib/scope.h
@@ -0,0 +1,37 @@
+#ifndef __PTR_H__
+# define __PTR_H__
+
+
+template<class T>
+class scope
+{
+public:
+ scope() : p(NULL) {}
+ scope(T t) : p(t) {}
+ ~scope() { release(); }
+
+ void release()
+ {
+ if (p != NULL)
+ delete p;
+ p = NULL;
+ }
+
+ T operator=(T t) { release(); p = t; return t; }
+ T operator->() const { return p; }
+ operator T() const { return p; }
+
+ T detach()
+ {
+ T ret = p;
+ p = NULL;
+ return ret;
+ }
+
+private:
+ T p;
+};
+
+
+
+#endif // __PTR_H__