30template <
typename TObj>
34 static void addRef(TObj* pObj) {
if (pObj) pObj->addRef(); }
35 static void release(TObj* pObj) {
if (pObj) pObj->release(); }
41template <
typename TObj>
46 static void release(TObj* pObj) {
delete pObj; }
52template <
typename TObj>
57 static void release(TObj* pObj) {
delete []pObj; }
74template <
typename TObj,
typename THelper = TObjRelease<TObj> >
82 THelper::addRef(pObj);
83 THelper::release(
m_obj);
92 THelper::addRef(
m_obj);
94 TPtr(
const TObj* pObj,
bool bAttach =
false) :
m_obj(const_cast<TObj*>(pObj))
97 THelper::addRef(
m_obj);
101 THelper::release(
m_obj);
111 template<
class U,
typename UHelper>
friend class TPtr;
114 THelper::addRef(
m_obj);
150 operator const TObj *()
const
156 THelper::release(
m_obj);
172 THelper::release(
m_obj);
static void release(TObj *pObj)
static void addRef(TObj *pObj)
static void release(TObj *pObj)
static void addRef(TObj *pObj)
static void release(TObj *pObj)
static void addRef(TObj *pObj)
TPtr< U > staticCast() const
TPtr & operator=(TObj *pObj)
TPtr< U > dynamicCast() const
TPtr(const TPtr< U > &pOther)
TPtr & replace(TObj *pObj)
TPtr(const TObj *pObj, bool bAttach=false)