Narrows a generic IDispatch pointer to a typed DispatchWrapper.
Calls QueryInterface on the supplied IDispatch using __uuidof(T::type), where T::type is the raw COM dispatch type that the DispatchWrapper T inherits from. On success the function returns an owning unique_com_ptr<T>; on failure it throws a standard exception so that COM errors surface immediately with context, rather that propagating as a null pointer that crashes later.
This function is called exclusively from COMProxy<T>'s owning ctor and is not part of the public API.
- Template Parameters
-
| T | A DispatchWrapper struct that publicly inherits a COM dispatch type and declares using type = <raw dispatch type>. __uuidof(T::type) must be a valid expression. |
- Parameters
-
| src | Owning pointer to the source IDispatch object. Ownership is consumed unconditionally: the pointer is released either because QueryInterface succeeded and the new typed pointer takes over, or because src goes out of scope on the exception path. |
- Returns
- Owning
unique_com_ptr<T> pointing to the same underlying COM object narrowed to the T interface.
- Exceptions
-
| std::invalid_argument | if src is null |
| std::runtime_error | if QueryInterface returns a failing HRESULT; the message includes the demangled name of T. |
- See also
- pacemaker::inca::detail::COMProxy
-
pacemaker::inca::detail::unique_com_ptr
Definition at line 40 of file utils.hpp.
Referenced by COMProxy< T >::COMProxy().