template< class T, const IID* piid >
class CComQIPtr
Parameters
T A COM interface specifying the type of pointer to be stored.
piid A pointer to the IID of T.
ATL uses CComQIPtr and CComPtr to manage COM interface pointers. Both classes perform automatic reference counting through calls to AddRef and Release. Overloaded operators handle pointer operations. CComQIPtr additionally supports automatic querying of interfaces though QueryInterface.
For an example of using CComQIPtr and CComPtr, see the CComPtr class overview.
Note Do not use CComQIPtr<IUnknown, &IID_IUnknown>. Rather, use CComPtr<IUnknown>.
#include <atlbase.h>
See Also CComPtr::CComPtr, CComQIPtr::CComQIPtr
Methods | |
CComQIPtr | Constructor. Initializes the member pointer. |
Release | Decrements the reference count on the object pointed to by the member pointer. |
Operators | |
operator T* | Converts a CComQIPtr object to a T*. |
operator * | Returns the dereferenced value of the member pointer. |
operator & | Returns the address of the member pointer. |
operator -> | Returns the member pointer. |
operator = | Assigns a pointer to the member pointer. |
operator ! | Returns TRUE or FALSE, depending on whether the member pointer is NULL. |
Data Members | |
p | The managed COM interface pointer of type T*. |
CComQIPtr( );
CComQIPtr( T* lp );
CComQIPtr( const CComQIPtr< T, piid >& lp );
CComQIPtr( IUnknown* lp );
Parameters
lp [in] Used to initialize the interface pointer, p.
T [in] A COM interface.
piid [in] A pointer to the IID of T.
Remarks
The default constructor sets p to NULL. The copy constructor sets p to the member pointer of lp and calls AddRef through p.
If you pass a pointer type derived from T, the constructor sets p to the T* parameter and calls AddRef. If you pass a pointer type not derived from T, the constructor calls QueryInterface to set p to an interface pointer corresponding to piid.
The destructor calls Release through p.
CComQIPtr Overview | Class Members
void Release( );
Remarks
Calls IUnknown::Release through p and sets p to NULL.
CComQIPtr Overview | Class Members
operator T*( );
Remarks
Converts a CComQIPtr object to a T*.
CComQIPtr Overview | Class Members
T& operator *( );
Remarks
Returns the dereferenced value of the interface pointer, p.
Note The operation will assert if p is NULL.
CComQIPtr Overview | Class Members
T** operator &( );
Remarks
Returns the address of the interface pointer, p.
Note The operation will assert if p is non-NULL.
CComQIPtr Overview | Class Members
T* operator ->( );
Remarks
Returns the interface pointer, p.
Note The operation will assert if p is NULL.
CComQIPtr Overview | Class Members
T* operator =( T* lp );
T* operator =( const CComQIPtr< T, piid >& lp );
T* operator =( IUnknown* lp );
Remarks
When assigning a pointer type derived from T, the operator sets p to the given T*. When assigning a CComQIPtr, the operator sets p to the member pointer of lp.
When assigning a pointer type not derived from T, the operator calls QueryInterface to set p to an interface pointer corresponding to piid, where piid is one of the class template parameters. If QueryInterface fails, p is set to NULL.
CComQIPtr Overview | Class Members
BOOL operator !( );
Remarks
Returns TRUE if p is NULL; otherwise, FALSE.
CComQIPtr Overview | Class Members
T* p;
Remarks
Points to the specified COM interface.