summaryrefslogtreecommitdiff
path: root/libopie2
authoralwin <alwin>2004-03-12 19:18:29 (UTC)
committer alwin <alwin>2004-03-12 19:18:29 (UTC)
commit874d5a34eca296263dcd1adf857aebe9981825a1 (patch) (side-by-side diff)
treea7b60a4d2a4de379ee4370dada0a76a8b2b3b4ee /libopie2
parent590587e74b908460a275b1f58654bcf4cce5d175 (diff)
downloadopie-874d5a34eca296263dcd1adf857aebe9981825a1.zip
opie-874d5a34eca296263dcd1adf857aebe9981825a1.tar.gz
opie-874d5a34eca296263dcd1adf857aebe9981825a1.tar.bz2
renaming
Diffstat (limited to 'libopie2') (more/less context) (show whitespace changes)
-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
@@ -8,137 +8,138 @@
.>+-=
_;:, .> :=|. This program is free software; you can
.> <`_, > . <= redistribute it and/or modify it under
:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
.="- .-=="i, .._ License as published by the Free Software
- . .-<_> .<> Foundation; either version 2 of the License,
._= =} : or (at your option) any later version.
.%`+i> _;_.
.i_,=:_. -<s. This program is distributed in the hope that
+ . -:. = it will be useful, but WITHOUT ANY WARRANTY;
: .. .:, . . . without even the implied warranty of
=_ + =;=|` MERCHANTABILITY or FITNESS FOR A
_.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.= = ; Library General Public License for more
++= -. .` .: details.
: = ...= . :.=-
-. .:....=;==+<; You should have received a copy of the GNU
-_. . . )=. = Library General Public License along with
-- :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
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;
}
//! delete a reference
void Decr() {
--m_RefCount;
}
//! is it referenced
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
* class of RefCount
*/
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
if (ptr) { ptr->Decr(); if (!ptr->Shared()) delete ptr; }
// 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();
if (!ptr->Shared()) delete ptr;
}
if (ptr=p) ptr->Incr();
return *this;
}
//! cast to conventional pointer
operator T* () const { return ptr; }
//! deref: fails for NULL pointer
T& operator* () {return *ptr; }
//! deref: fails for NULL pointer
const T& operator* ()const {return *ptr; }
//! deref with method call
T* operator-> () {return ptr; }
//! deref with const method call
const T* operator-> ()const {return ptr; }
//! supports "if (pointer)"
operator bool () const { return (ptr != NULL); }
//! "if (pointer)" as non const
operator bool () { return ptr != NULL;}
//! support if (!pointer)"
bool operator! () const { return (ptr == NULL); }
//! support if (!pointer)" as non const
bool operator! () { return (ptr == NULL); }
};
}
#endif
+