CComContainedObject Class

 

For the latest documentation on Visual Studio 2017 RC, see Visual Studio 2017 RC Documentation.

This class implements IUnknown by delegating to the owner object's IUnknown.

System_CAPS_ICON_important.jpg Important

This class and its members cannot be used in applications that execute in the Windows Runtime.

template<class Base>  
class CComContainedObject : public Base

Parameters

Base
Your class, derived from CComObjectRoot or CComObjectRootEx.

Public Constructors

NameDescription
CComContainedObject::CComContainedObjectThe constructor. Initializes the member pointer to the owner object's IUnknown.
CComContainedObject::~CComContainedObjectThe destructor.

Public Methods

NameDescription
CComContainedObject::AddRefIncrements the reference count on the owner object.
CComContainedObject::GetControllingUnknownRetrieves the owner object's IUnknown.
CComContainedObject::QueryInterfaceRetrieves a pointer to the interface requested on the owner object.
CComContainedObject::ReleaseDecrements the reference count on the owner object.

ATL uses CComContainedObject in classes CComAggObject, CComPolyObject, and CComCachedTearOffObject. CComContainedObject implements IUnknown by delegating to the owner object's IUnknown. (The owner is either the outer object of an aggregation, or the object for which a tear-off interface is being created.) CComContainedObject calls CComObjectRootEx's OuterQueryInterface, OuterAddRef, and OuterRelease, all inherited through Base.

Base

CComContainedObject

Header: atlcom.h

Increments the reference count on the owner object.

STDMETHOD_(ULONG, AddRef)();

Return Value

A value that may be useful for diagnostics or testing.

The constructor.

CComContainedObject(void* pv);

Parameters

pv
[in] The owner object's IUnknown.

Remarks

Sets the m_pOuterUnknown member pointer (inherited through the Base class) to pv.

The destructor.

~CComContainedObject();

Remarks

Frees all allocated resources.

Returns the m_pOuterUnknown member pointer (inherited through the Base class) that holds the owner object's IUnknown.

IUnknown* GetControllingUnknown();

Return Value

The owner object's IUnknown.

Remarks

This method may be virtual if Base has declared the DECLARE_GET_CONTROLLING_UNKNOWN macro.

Retrieves a pointer to the interface requested on the owner object.

STDMETHOD(QueryInterface)(REFIID iid, void** ppvObject);
template <class Q>
HRESULT STDMETHODCALLTYPE QueryInterface(Q** pp);

Parameters

iid
[in] The identifier of the interface being requested.

ppvObject
[out] A pointer to the interface pointer identified by iid. If the object does not support this interface, ppvObject is set to NULL.

pp
[out] A pointer to the interface pointer identified by type Q. If the object does not support this interface, pp is set to NULL.

Return Value

A standard HRESULT value.

Decrements the reference count on the owner object.

STDMETHOD_(ULONG, Release)();

Return Value

In debug builds, Release returns a value that may be useful for diagnostics or testing. In non-debug builds, Release always returns 0.

Class Overview

Show: