-rw-r--r-- | libopie2/opiecore/osmartpointer.h (renamed from libopie2/opiecore/osmart_pointer.h) | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/libopie2/opiecore/osmart_pointer.h b/libopie2/opiecore/osmartpointer.h index 2a2518f..9000e71 100644 --- a/libopie2/opiecore/osmart_pointer.h +++ b/libopie2/opiecore/osmartpointer.h @@ -28,30 +28,30 @@ _;:, .> :=|. This program is free software; you can Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifndef _osmart_pointer_h -#define _osmart_pointer_h +#ifndef _OSmartPointer_h +#define _OSmartPointer_h /*! - * \file osmart_pointer.h + * \file OSmartPointer.h * \brief smart pointer and reference counter * \author Rajko Albrecht * */ namespace Opie { //! simple reference counter class -class oref_count { +class ORefCount { protected: //! reference count member long m_RefCount; public: //! first reference must be added after "new" via Pointer() - oref_count() : m_RefCount(0) + ORefCount() : m_RefCount(0) {} - virtual ~oref_count() {} + virtual ~ORefCount() {} //! add a reference void Incr() { ++m_RefCount; } @@ -63,9 +63,9 @@ public: bool Shared() { return (m_RefCount > 0); } }; //! reference counting wrapper class -template<class T> class osmart_pointer { +template<class T> class OSmartPointer { //! pointer to object /*! * this object must contain Incr(), Decr() and Shared() * methode as public members. The best way is, that it will be a child @@ -73,29 +73,29 @@ template<class T> class osmart_pointer { */ T *ptr; public: //! standart constructor - osmart_pointer() { ptr = NULL; } + OSmartPointer() { ptr = NULL; } //! standart destructor /*! * release the reference, if it were the last reference, destroys * ptr */ - ~osmart_pointer() + ~OSmartPointer() { if (ptr){ ptr->Decr(); if (!ptr->Shared()) delete ptr; } } //! construction - osmart_pointer(T* t) { if (ptr = t) ptr->Incr(); } + OSmartPointer(T* t) { if (ptr = t) ptr->Incr(); } //! Pointer copy - osmart_pointer(const osmart_pointer<T>& p) + OSmartPointer(const OSmartPointer<T>& p) { if (ptr = p.ptr) ptr->Incr(); } //! pointer copy by assignment - osmart_pointer<T>& operator= (const osmart_pointer<T>& p) + OSmartPointer<T>& operator= (const OSmartPointer<T>& p) { // already same: nothing to do if (ptr == p.ptr) return *this; // decouple reference @@ -103,9 +103,9 @@ public: // establish new reference if (ptr = p.ptr) ptr->Incr(); return *this; } - osmart_pointer<T>& operator= (T*p) + OSmartPointer<T>& operator= (T*p) { if (ptr==p)return *this; if (ptr) { ptr->Decr(); @@ -141,4 +141,5 @@ public: } #endif + |