aboutsummaryrefslogtreecommitdiff
path: root/src/libjin/Common/Object.h
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2018-08-06 16:22:00 +0800
committerchai <chaifix@163.com>2018-08-06 16:22:00 +0800
commit89e7a9ecfad9a54633eb3ebbab1d1f13ad78826f (patch)
tree1ba8a806af1b8e7750d6b637c296f08e13cf268e /src/libjin/Common/Object.h
parentea9769944a2db3abe15f537dab67e16fdfc20bef (diff)
*update
Diffstat (limited to 'src/libjin/Common/Object.h')
-rw-r--r--src/libjin/Common/Object.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/libjin/Common/Object.h b/src/libjin/Common/Object.h
new file mode 100644
index 0000000..9ac1b5a
--- /dev/null
+++ b/src/libjin/Common/Object.h
@@ -0,0 +1,49 @@
+#ifndef __JIN_COMMON_OBJECT_H
+#define __JIN_COMMON_OBJECT_H
+
+namespace jin
+{
+
+ class Object
+ {
+ private:
+
+ // The reference count.
+ int count;
+
+ public:
+
+ /**
+ * Constructor. Sets reference count to one.
+ **/
+ Object();
+
+ /**
+ * Destructor.
+ **/
+ virtual ~Object() = 0;
+
+ /**
+ * Gets the reference count of this Object.
+ * @returns The reference count.
+ **/
+ int getReferenceCount() const;
+
+ /**
+ * Retains the Object, i.e. increases the
+ * reference count by one.
+ **/
+ void retain();
+
+ /**
+ * Releases one reference to the Object, i.e. decrements the
+ * reference count by one, and potentially deletes the Object
+ * if there are no more references.
+ **/
+ void release();
+
+ }; // Object
+
+}
+
+#endif \ No newline at end of file