CComObjectStack

template <class Base>
class CComObjectStack : public
Base

Parameters

Base Your class, typically derived from CComObjectRoot or CComObjectRootEx, as well as from any other interface you want to support on the object.

CComObjectStack is used to create a temporary COM object and provide the object a skeletal implementation of IUnknown. Typically, the object is used as a local variable within one function (that is, pushed onto the stack). Since the object is destroyed when the function finishes, reference counting is not performed to increase efficiency.

The following example shows how to create a COM object used inside a function:

void MyFunc ( ) 
{ 
  CComObjectStack<CMyObject> Tempobj; 
  ... 
} 

The temporary object Tempobj is pushed onto the stack and automatically disappears when the function finishes.

#include <atlcom.h>

See Also CComObjectGlobal, CComAggObject, CComObject,


CComObjectStack Class Members

Methods
AddRefReturns zero. In debug mode, calls _ASSERTE.
CComObjectStackConstructor.
QueryInterfaceReturns E_NOINTERFACE. In debug mode, calls _ASSERTE.
ReleaseReturns zero. In debug mode, calls _ASSERTE.
Data Members
m_hResFinalConstructContains the HRESULT returned during construction of the CComObjectStack object.

CComObjectStack Overview


Methods


CComObjectStack::AddRef

ULONG AddRef( );

Return Value

Returns zero.

Remarks

Returns zero. In debug mode, calls _ASSERTE.

CComObjectStack Overview | Class Members


CComObjectStack::CComObjectStack

CComObjectStack( );

Remarks

The constructor. Calls FinalConstruct and then sets m_hResFinalConstruct to the HRESULT returned by FinalConstruct. If you have not derived your base class from CComObjectRoot, you must supply your own FinalConstruct method. The destructor calls FinalRelease.

CComObjectStack Overview | Class Members

See Also CComObjectRootEx::FinalConstruct


CComObjectStack::QueryInterface

HRESULT QueryInterface( REFIID iid, void** ppvObject ) ;

Return Value

Returns E_NOINTERFACE.

Parameters

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

ppvObject [out] A pointer to the interface pointer identified by iid, or NULL if the interface is not found.

Remarks

Returns E_NOINTERFACE. In debug mode, calls _ASSERTE.

CComObjectStack Overview | Class Members


CComObjectStack::Release

ULONG Release( );

Return Value

Returns zero.

Remarks

Returns zero. In debug mode, calls _ASSERTE.

CComObjectStack Overview | Class Members


Data Members


CComObjectStack::m_hResFinalConstruct

HRESULT m_hResFinalConstruct;

Remarks

Contains the HRESULT returned from calling FinalConstruct during construction of the CComObjectStack object.

CComObjectStack Overview | Class Members

See Also CComObjectStack::CComObjectStack, CComObjectRootEx::FinalConstruct