Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

CComCachedTearOffObject Class

This class implements IUnknown for a tear-off interface.

template < 
   class contained 
> 
class CComCachedTearOffObject : public IUnknown,
   public CComObjectRootEx< contained::_ThreadModel::ThreadModelNoCS >
contained

Your tear-off class, derived from CComTearOffObjectBase and the interfaces you want your tear-off object to support.

Name

Description

CComCachedTearOffObject::AddRef

Increments the reference count for a CComCachedTearOffObject object.

CComCachedTearOffObject::FinalConstruct

Calls the m_contained::FinalConstruct (the tear-off class' method).

CComCachedTearOffObject::FinalRelease

Calls the m_contained::FinalRelease (the tear-off class' method).

CComCachedTearOffObject::QueryInterface

Returns a pointer to the IUnknown of the CComCachedTearOffObject object, or to the requested interface on your tear-off class (the class contained).

CComCachedTearOffObject::Release

Decrements the reference count for a CComCachedTearOffObject object and destroys it if the reference count is 0.

Name

Description

CComCachedTearOffObject::m_contained

A CComContainedObject object derived from your tear-off class (the class contained).

CComCachedTearOffObject implements IUnknown for a tear-off interface. This class differs from CComTearOffObject in that CComCachedTearOffObject has its own IUnknown, separate from the owner object's IUnknown (the owner is the object for which the tear-off is being created). CComCachedTearOffObject maintains its own reference count on its IUnknown and deletes itself once its reference count is zero. However, if you query for any of its tear-off interfaces, the reference count of the owner object's IUnknown will be incremented.

If the CComCachedTearOffObject object implementing the tear-off is already instantiated, and the tear-off interface is queried for again, the same CComCachedTearOffObject object is reused. In contrast, if a tear-off interface implemented by a CComTearOffObject is again queried for through the owner object, another CComTearOffObject will be instantiated.

The owner class must implement FinalRelease and call Release on the cached IUnknown for the CComCachedTearOffObject, which will decrement its reference count. This will cause CComCachedTearOffObject's FinalRelease to be called and delete the tear-off.

CComObjectRootBase

CComObjectRootEx

IUnknown

CComCachedTearOffObject

Header: atlcom.h

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.