Microsoft DirectX 8.0 |
Implements the IUnknown interface. Most Component Object Model (COM) objects in Microsoft® DirectShow® derive from CUnknown.
Declaration: Combase.h
If you implement a COM object, you might want to derive it from CUnknown. Deriving from CUknown provides a thread-safe implementation, and saves you the trouble of implementing IUnknown.
For a detailed discussion of how to use this base class, see How to Implement IUnknown. What follows is a brief summary:
Protected Member Variables m_cRef Reference count. Public Methods CUnknown Constructor method. ~CUnknown Destructor method. Virtual. GetOwner Retrieves a pointer to the controlling IUnknown. INonDelegatingUnknown Methods NonDelegatingAddRef Increments the reference count. NonDelegatingQueryInterface Retrieves an interface pointer and increments the reference count. NonDelegatingRelease Decrements the reference count.
Reference count.
Syntax
volatile LONG m_cRef;
Remarks
Use this member variable if you override the NonDelegatingAddRef or NonDelegatingRelease method.
Constructor method.
Syntax
CUnknown( const TCHAR *pName, LPUNKNOWN pUnk );
Parameters
- pName
- String containing the name of the object; used in the CBaseObject constructor for debugging.
- pUnk
- Pointer to the owner of this object. If the object is aggregated, pass a pointer to the aggregating object's IUnknown interface. Otherwise, set this parameter to NULL.
Remarks
The object is initialized with a reference count of zero.
Destructor method.
Syntax
virtual ~CUnknown(void);
Retrieves a pointer to the IUnknown interface of the owning component. For an aggregated component, the owner is the outer component. Otherwise, the component owns itself.
Syntax
LPUNKNOWN GetOwner(void);
Return Value
Returns a pointer to the controlling IUnknown interface.
Increments the reference count on the object. Implements the INonDelegatingUnknown::NonDelegatingAddRef method.
Syntax
ULONG NonDelegatingAddRef(void);
Return Value
Returns the reference count.
Retrieves an interface pointer and increments the reference count. Implements the INonDelegatingUnknown::NonDelegatingQueryInterface method.
Syntax
HRESULT NonDelegatingQueryInterface( REFIID riid, void **ppv );
Parameters
- riid
- Identifier of the interface.
- ppv
- Address of a pointer to receive the interface.
Return Value
Returns one of the HRESULT values shown in the following table.
S_OK Success. E_NOINTERFACE Object does not support this interface. E_POINTER NULL pointer argument.
Remarks
The CUnknown class exposes only the IUknown interface. Override this method to expose additional interfaces. For information on how to override this method, see How to Implement IUnknown.
Decrements the reference count on the object. Implements the INonDelegatingUnknown::NonDelegatingRelease method.
Syntax
ULONG NonDelegatingRelease(void);
Return Value
Returns the reference count.
Remarks
When the reference count reaches zero, the object deletes itself.