Browse Source

Reference Counting Template jetzt im Framework Namespace

kolja 6 years ago
parent
commit
a44010e985
1 changed files with 26 additions and 22 deletions
  1. 26 22
      ReferenceCounting.h

+ 26 - 22
ReferenceCounting.h

@@ -1,27 +1,31 @@
 #pragma once
-template< class T >
-class ReferenceCounting : public T
-{
-private:
-    int ref;
 
-public:
-    ReferenceCounting()
-        : T()
+namespace Framework
+{
+    template< class T >
+    class ReferenceCounting : public T
     {
-        ref = 1;
-    }
+    private:
+        int ref;
 
-    T *getThis()
-    {
-        ref++;
-        return this;
-    }
+    public:
+        ReferenceCounting()
+            : T()
+        {
+            ref = 1;
+        }
 
-    T *release()
-    {
-        if( !--ref )
-            delete this;
-        return 0;
-    }
-};
+        T *getThis()
+        {
+            ref++;
+            return this;
+        }
+
+        T *release()
+        {
+            if( !--ref )
+                delete this;
+            return 0;
+        }
+    };
+}