src/misc/countedptr.hpp
author KUDr
Sat, 13 Jan 2007 13:33:36 +0000
changeset 5633 e1905dacc378
child 6481 85ad87daf4b0
permissions -rw-r--r--
(svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
5633
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
     1
/* $Id$ */
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
     2
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
     3
#ifndef COUNTEDPTR_HPP
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
     4
#define COUNTEDPTR_HPP
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
     5
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
     6
#if 0 // reenable when needed
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
     7
/** @file CCountedPtr - smart pointer implementation */
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
     8
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
     9
/** CCountedPtr - simple reference counting smart pointer.
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    10
 *
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    11
 *     One of the standard ways how to maintain object's lifetime.
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    12
 *
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    13
 *     See http://ootips.org/yonat/4dev/smart-pointers.html for more
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    14
 *   general info about smart pointers.
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    15
 *
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    16
 *     This class implements ref-counted pointer for objects/interfaces that
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    17
 *   support AddRef() and Release() methods.
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    18
 */
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    19
template <class Tcls_>
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    20
class CCountedPtr {
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    21
	/** redefine the template argument to make it visible for derived classes */
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    22
public:
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    23
	typedef Tcls_ Tcls;
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    24
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    25
protected:
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    26
	/** here we hold our pointer to the target */
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    27
	Tcls* m_pT;
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    28
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    29
public:
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    30
	/** default (NULL) construct or construct from a raw pointer */
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    31
	FORCEINLINE CCountedPtr(Tcls* pObj = NULL) : m_pT(pObj) {AddRef();};
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    32
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    33
	/** copy constructor (invoked also when initializing from another smart ptr) */
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    34
	FORCEINLINE CCountedPtr(const CCountedPtr& src) : m_pT(src.m_pT) {AddRef();};
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    35
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    36
	/** destructor releasing the reference */
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    37
	FORCEINLINE ~CCountedPtr() {Release();};
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    38
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    39
protected:
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    40
	/** add one ref to the underlaying object */
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    41
	FORCEINLINE void AddRef() {if (m_pT != NULL) m_pT->AddRef();}
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    42
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    43
public:
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    44
	/** release smart pointer (and decrement ref count) if not null */
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    45
	FORCEINLINE void Release() {if (m_pT != NULL) {m_pT->Release(); m_pT = NULL;}}
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    46
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    47
	/** dereference of smart pointer - const way */
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    48
	FORCEINLINE const Tcls* operator -> () const {assert(m_pT != NULL); return m_pT;};
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    49
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    50
	/** dereference of smart pointer - non const way */
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    51
	FORCEINLINE Tcls* operator -> () {assert(m_pT != NULL); return m_pT;};
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    52
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    53
	/** raw pointer casting operator - const way */
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    54
	FORCEINLINE operator const Tcls*() const {assert(m_pT == NULL); return m_pT;}
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    55
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    56
	/** raw pointer casting operator - non-const way */
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    57
	FORCEINLINE operator Tcls*() {assert(m_pT == NULL); return m_pT;}
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    58
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    59
	/** operator & to support output arguments */
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    60
	FORCEINLINE Tcls** operator &() {assert(m_pT == NULL); return &m_pT;}
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    61
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    62
	/** assignment operator from raw ptr */
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    63
	FORCEINLINE CCountedPtr& operator = (Tcls* pT) {Assign(pT); return *this;}
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    64
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    65
	/** assignment operator from another smart ptr */
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    66
	FORCEINLINE CCountedPtr& operator = (CCountedPtr& src) {Assign(src.m_pT); return *this;}
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    67
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    68
	/** assignment operator helper */
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    69
	FORCEINLINE void Assign(Tcls* pT);
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    70
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    71
	/** one way how to test for NULL value */
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    72
	FORCEINLINE bool IsNull() const {return m_pT == NULL;}
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    73
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    74
	/** another way how to test for NULL value */
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    75
	FORCEINLINE bool operator == (const CCountedPtr& sp) const {return m_pT == sp.m_pT;}
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    76
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    77
	/** yet another way how to test for NULL value */
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    78
	FORCEINLINE bool operator != (const CCountedPtr& sp) const {return m_pT != sp.m_pT;}
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    79
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    80
	/** assign pointer w/o incrementing ref count */
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    81
	FORCEINLINE void Attach(Tcls* pT) {Release(); m_pT = pT;}
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    82
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    83
	/** detach pointer w/o decrementing ref count */
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    84
	FORCEINLINE Tcls* Detach() {Tcls* pT = m_pT; m_pT = NULL; return pT;}
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    85
};
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    86
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    87
template <class Tcls_>
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    88
FORCEINLINE void CCountedPtr<Tcls_>::Assign(Tcls* pT)
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    89
{
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    90
	// if they are the same, we do nothing
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    91
	if (pT != m_pT) {
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    92
		if (pT) pT->AddRef();        // AddRef new pointer if any
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    93
		Tcls* pTold = m_pT;          // save original ptr
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    94
		m_pT = pT;                   // update m_pT to new value
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    95
		if (pTold) pTold->Release(); // release old ptr if any
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    96
	}
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    97
}
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    98
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
    99
#endif /* 0 */
e1905dacc378 (svn r8092) -Codechange: header files with miscellaneous template classes (smart pointers, blob, array, hashtable, etc.) moved from src/yapf to src/misc as they can now be used anywhere.
KUDr
parents:
diff changeset
   100
#endif /* COUNTEDPTR_HPP */