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.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/libopie2/opiecore/osmartpointer.h b/libopie2/opiecore/osmartpointer.h
index 9000e71..8f9da7f 100644
--- a/libopie2/opiecore/osmartpointer.h
+++ b/libopie2/opiecore/osmartpointer.h
@@ -19,48 +19,49 @@ _;:, .> :=|. This program is free software; you can
=_ + =;=|` 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 _OSmartPointer_h
#define _OSmartPointer_h
/*!
* \file OSmartPointer.h
* \brief smart pointer and reference counter
* \author Rajko Albrecht
*
*/
namespace Opie {
+namespace Core {
//! simple reference counter class
class ORefCount {
protected:
//! reference count member
long m_RefCount;
public:
//! first reference must be added after "new" via Pointer()
ORefCount() : m_RefCount(0)
{}
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
@@ -119,27 +120,28 @@ public:
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