Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
Gray::cRefPtr< TYPE > Class Template Reference

#include <cRefPtr.h>

Inheritance diagram for Gray::cRefPtr< TYPE >:
Gray::cPtrFacade< cRefBase > Gray::cSingletonPtr< cNetSystem > Gray::cSingletonPtr< Gray::cLogAppendConsole > Gray::cSingletonPtr< GrayLib::cXObjMgrPack >

Public Member Functions

 cRefPtr () noexcept
 
 cRefPtr (const TYPE *p2)
 
 cRefPtr (const THIS_t &ref)
 
 cRefPtr (const TYPE *p2, TIMESYSD_t dwWaitMS)
 
 ~cRefPtr ()
 
bool isValidPtr () const
 
bool isCorruptPtr () const
 
void put_Ptr (TYPE *p)
 
void ReleasePtr ()
 
int get_RefCount () const
 
THIS_toperator= (const TYPE *p2)
 
THIS_toperator= (const THIS_t &ref)
 
template<class _TYPE_2 >
 operator cRefPtr< _TYPE_2 > () const
 
- Public Member Functions inherited from Gray::cPtrFacade< cRefBase >
 cPtrFacade (cRefBase *p=nullptr) noexcept
 
 cPtrFacade (THIS_t &&ref) noexcept
 
bool isValidPtr () const noexcept
 
cRefBase ** get_PPtr ()
 
cRefBaseget_Ptr () const noexcept
 
void put_Ptr (cRefBase *p) noexcept
 
void ReleasePtr () noexcept
 
void AttachPtr (cRefBase *p) noexcept
 
cRefBaseDetachPtr () noexcept
 
THIS_toperator= (cRefBase *p) noexcept
 
THIS_toperator= (THIS_t &&ref) noexcept
 
 operator cRefBase * () const noexcept
 
cRefBaseget_Ref () const
 
cRefBaseoperator* () const
 
cRefBaseoperator-> () const
 
bool operator! () const noexcept
 Comparison ops. More...
 
bool operator!= (cRefBase *p2) const noexcept
 
bool operator== (cRefBase *p2) const noexcept
 

Protected Member Functions

void IncRefFirst ()
 

Additional Inherited Members

- Protected Attributes inherited from Gray::cPtrFacade< cRefBase >
cRefBasem_p
 Pointer to some object of TYPE. More...
 

Detailed Description

template<class TYPE = cRefBase>
class Gray::cRefPtr< TYPE >

Template for a type specific Smart (reference counted) Pointer Smart pointer to an object. like "com_ptr_t" _com_ptr_t or cComPtr. https://msdn.microsoft.com/en-us/library/hh279674.aspx Just a ref to the object of some type. TYPE must be based on cRefBase similar to boost::shared_ptr<TYPE>

Todo:
something like USE_IUNK_TRACE ??

Constructor & Destructor Documentation

◆ cRefPtr() [1/4]

template<class TYPE = cRefBase>
Gray::cRefPtr< TYPE >::cRefPtr ( )
inlinenoexcept

◆ cRefPtr() [2/4]

template<class TYPE = cRefBase>
Gray::cRefPtr< TYPE >::cRefPtr ( const TYPE p2)
inline
Note
default = assignment will auto destroy previous and use this constructor.

◆ cRefPtr() [3/4]

template<class TYPE = cRefBase>
Gray::cRefPtr< TYPE >::cRefPtr ( const THIS_t ref)
inline

create my own copy constructor.

◆ cRefPtr() [4/4]

template<class TYPE = cRefBase>
Gray::cRefPtr< TYPE >::cRefPtr ( const TYPE p2,
TIMESYSD_t  dwWaitMS 
)
inline

This is to fake out cThreadLockRef in single thread mode.

  • dwWaitMS = ignored.

◆ ~cRefPtr()

template<class TYPE = cRefBase>
Gray::cRefPtr< TYPE >::~cRefPtr ( )
inline

Member Function Documentation

◆ get_RefCount()

template<class TYPE = cRefBase>
int Gray::cRefPtr< TYPE >::get_RefCount ( ) const
inline

◆ IncRefFirst()

template<class TYPE = cRefBase>
void Gray::cRefPtr< TYPE >::IncRefFirst ( )
inlineprotected
Note
IncRefCount can throw !

◆ isCorruptPtr()

template<class TYPE = cRefBase>
bool Gray::cRefPtr< TYPE >::isCorruptPtr ( ) const
inline

is this really pointing to what it is supposed to be pointing to. type check. Mostly just for _DEBUG usage.

◆ isValidPtr()

template<class TYPE = cRefBase>
bool Gray::cRefPtr< TYPE >::isValidPtr ( ) const
inline

Not nullptr?

◆ operator cRefPtr< _TYPE_2 >()

template<class TYPE = cRefBase>
template<class _TYPE_2 >
Gray::cRefPtr< TYPE >::operator cRefPtr< _TYPE_2 > ( ) const
inline

explicit ref type conversion - to remove redundant casts will work only for properly related types

◆ operator=() [1/2]

template<class TYPE = cRefBase>
THIS_t& Gray::cRefPtr< TYPE >::operator= ( const THIS_t ref)
inline

Copy assignment operator.

Note
we need a ref assignment because we need to prevent new objects from being destroyed before assigned.

◆ operator=() [2/2]

template<class TYPE = cRefBase>
THIS_t& Gray::cRefPtr< TYPE >::operator= ( const TYPE p2)
inline

◆ put_Ptr()

template<class TYPE = cRefBase>
void Gray::cRefPtr< TYPE >::put_Ptr ( TYPE p)
inline

Attach the pointer and add a ref.

◆ ReleasePtr()

template<class TYPE = cRefBase>
void Gray::cRefPtr< TYPE >::ReleasePtr ( )
inline

just set this to nullptr.


The documentation for this class was generated from the following file: