summaryrefslogtreecommitdiff
path: root/libopie2/opiecore/osmartpointer.h
Side-by-side diff
Diffstat (limited to 'libopie2/opiecore/osmartpointer.h') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/osmartpointer.h33
1 files changed, 14 insertions, 19 deletions
diff --git a/libopie2/opiecore/osmartpointer.h b/libopie2/opiecore/osmartpointer.h
index e9cee0c..f2f6464 100644
--- a/libopie2/opiecore/osmartpointer.h
+++ b/libopie2/opiecore/osmartpointer.h
@@ -5,3 +5,3 @@
Copyright (C) The Opie Team <opie-devel@handhelds.org>
- =.
+ =.
.=l.
@@ -50,18 +50,13 @@ protected:
//! reference count member
- long m_RefCount;
+ unsigned long m_RefCount;
public:
//! first reference must be added after "new" via Pointer()
- ORefCount() : m_RefCount(0)
- {}
- virtual ~ORefCount() {}
+ ORefCount();
+ virtual ~ORefCount();
//! add a reference
- void Incr() {
- ++m_RefCount;
- }
+ void Incr();
//! delete a reference
- void Decr() {
- --m_RefCount;
- }
+ void Decr();
//! is it referenced
- bool Shared() { return (m_RefCount > 0); }
+ bool Shared();
};
@@ -72,3 +67,3 @@ template<class T> class OSmartPointer {
/*!
- * this object must contain Incr(), Decr() and Shared()
+ * this object must contain Incr(), Decr() and Shared()
* methode as public members. The best way is, that it will be a child
@@ -96,6 +91,6 @@ public:
//! Pointer copy
- OSmartPointer(const OSmartPointer<T>& p)
+ OSmartPointer(const OSmartPointer<T>& p)
{ if (ptr = p.ptr) ptr->Incr(); }
//! pointer copy by assignment
- OSmartPointer<T>& operator= (const OSmartPointer<T>& p)
+ OSmartPointer<T>& operator= (const OSmartPointer<T>& p)
{
@@ -104,3 +99,3 @@ public:
// decouple reference
- if (ptr) { ptr->Decr(); if (!ptr->Shared()) delete ptr; }
+ if (ptr) { ptr->Decr(); if (!ptr->Shared()) delete ptr; }
// establish new reference
@@ -122,3 +117,3 @@ public:
operator T* () const { return ptr; }
-
+
//! deref: fails for NULL pointer
@@ -132,3 +127,3 @@ public:
const T* operator-> ()const {return ptr; }
-
+
//! supports "if (pointer)"
@@ -137,3 +132,3 @@ public:
operator bool () { return ptr != NULL;}
-
+
//! support if (!pointer)"