summaryrefslogtreecommitdiffstats
path: root/source/ptr_cChunk.h
diff options
context:
space:
mode:
authorfaketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-01-19 19:12:39 +0100
committerfaketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-01-19 19:12:39 +0100
commit50a7722242197f9a3b4300e154c1e66d1177839a (patch)
treeebf80972e3fe85806c1df037579e9a20992b5766 /source/ptr_cChunk.h
parentFixed crashing bug in cClientHandle::~cClientHandle (diff)
downloadcuberite-50a7722242197f9a3b4300e154c1e66d1177839a.tar
cuberite-50a7722242197f9a3b4300e154c1e66d1177839a.tar.gz
cuberite-50a7722242197f9a3b4300e154c1e66d1177839a.tar.bz2
cuberite-50a7722242197f9a3b4300e154c1e66d1177839a.tar.lz
cuberite-50a7722242197f9a3b4300e154c1e66d1177839a.tar.xz
cuberite-50a7722242197f9a3b4300e154c1e66d1177839a.tar.zst
cuberite-50a7722242197f9a3b4300e154c1e66d1177839a.zip
Diffstat (limited to '')
-rw-r--r--source/ptr_cChunk.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/source/ptr_cChunk.h b/source/ptr_cChunk.h
new file mode 100644
index 000000000..c3556839c
--- /dev/null
+++ b/source/ptr_cChunk.h
@@ -0,0 +1,37 @@
+#pragma once
+
+#include "cChunk.h"
+
+class ptr_cChunk
+{
+public:
+ ptr_cChunk( cChunk* a_Ptr )
+ : m_Ptr( a_Ptr )
+ {
+ if( m_Ptr ) m_Ptr->AddReference();
+ }
+
+ ptr_cChunk( const ptr_cChunk& a_Clone )
+ : m_Ptr( a_Clone.m_Ptr )
+ {
+ if( m_Ptr ) m_Ptr->AddReference();
+ }
+
+ ~ptr_cChunk()
+ {
+ if( m_Ptr ) m_Ptr->RemoveReference();
+ }
+
+ cChunk* operator-> ()
+ {
+ return m_Ptr;
+ }
+
+ cChunk& operator* () { return *m_Ptr; }
+ bool operator!() { return !m_Ptr; }
+ bool operator==( const ptr_cChunk& a_Other ) { return m_Ptr == a_Other.m_Ptr; }
+ operator bool() { return m_Ptr != 0; }
+ operator cChunk*() { return m_Ptr; }
+private:
+ cChunk* m_Ptr;
+}; \ No newline at end of file