Class CObjectPtr#

Class Documentation#

class CObjectPtr#

Object smart pointer. Implements destruction of the object.

Public Functions

inline CObjectPtr(IInterfaceAccess *pInterface = nullptr)#

Construct a new CObjectPtr object.

Parameters:

pInterface[in] Pointer to the interface to wrap or nullptr when no interface is to be wrapped yet.

inline CObjectPtr(const CObjectPtr &rptrInterface)#

Copy construct a new CInterfacePtr object.

Parameters:

rptrInterface[in] Reference to the CInterfacePtr object to copy from.

inline CObjectPtr(CObjectPtr &&rptrInterface) noexcept#

Move construct a new CInterfacePtr object.

Parameters:

rptrInterface[in] Reference to the CInterfacePtr object to move from.

inline virtual ~CObjectPtr()#

Destructor.

inline CObjectPtr &operator=(IInterfaceAccess *pInterface)#

Assignment operator.

Parameters:

pInterface[in] Pointer to the interface to wrap or nullptr to clear the wrapping.

Returns:

Returns *this

inline CObjectPtr &operator=(const CObjectPtr &rptrInterface)#

Assignment operator.

Parameters:

rptrInterface[in] Reference to the CInterfacePtr object to copy from.

Returns:

Returns *this

inline CObjectPtr &operator=(CObjectPtr &&rptrInterface) noexcept#

Move operator.

Parameters:

rptrInterface[in] Reference to the CInterfacePtr object to move from.

Returns:

Returns *this

inline operator IInterfaceAccess*()#

Get a pointer to the interface.

inline operator const IInterfaceAccess*() const#

Get a pointer to the interface.

inline operator CInterfacePtr() const#

Get a pointer to the interface.

inline operator bool() const#

Is there a valid interface?

Returns:

Returns ‘true’ when an interface is wrapped; ‘false’ otherwise.

inline bool IsValid() const#

Return whether there is a valid interface.

Returns:

Returns ‘true’ when an interface is wrapped; ‘false’ otherwise.

template<typename TIfc>
inline TIfc *GetInterface() const#

Gets an interface by using the IInterfaceAccess::GetInterface function.

Template Parameters:

TIfc – The interface type to request.

Returns:

Returns a pointer to the requested interface if the object has itregistered, nullptr otherwise

inline void Assign(IInterfaceAccess *pObject)#

Assign the object to this object pointer and increment the lifetime counter.

Parameters:

pObject[in] Interface pointer to the object.

inline void Clear()#

Destroy the object and clear the interface.

inline void Attach(IInterfaceAccess *pObject)#

Attach an object which is managed by lifetime. The lifetime counter is not increased.

Remark

Attachment only succeeds when the object exposes the IObjectLifetime pointer.

Parameters:

pObject[in] Pointer to the object.

inline CInterfacePtr Detach()#

Detach the pointer without change the object lifetime. The internal pointer will beeome NULL.

Attention

Detaching the pointer means it is not managed any more. A call to IObjectLifetime::Decrement needs to be done manually.

Returns:

The detached interface pointer.