Owning smart-pointer base class for COM dispatch proxy objects. More...
#include <COMProxy.hpp>


Public Member Functions | |
| COMProxy ()=default | |
| Default ctor; leaves the internal pointer null. | |
| COMProxy (::IDispatch *subject) | |
Constrcuts the proxy from a raw IDispatch*, taking ownership. | |
| COMProxy (unique_com_ptr<::IDispatch > subject) | |
Constructs the proxy by narrowing an owning IDispatch pointer to T. | |
| COMProxy (COMProxy &&)=default | |
| Move ctor; transfers ownership of the COM pointer. | |
| COMProxy & | operator= (COMProxy &&)=default |
| Move assignment; transfers ownership of the COM pointer. | |
Owning smart-pointer base class for COM dispatch proxy objects.
COMProxy<T> publicly inherits unique_com_ptr<T>, making every instantiated proxy type an owning smart pointer. Proxy types are declared as type aliases:
T must be a "DispatchWrapper" struct, i.e. a struct that:
using type = ::RawDispatchType.The type typedef is consumed by query_interface<T>, which uses __uuidof(T::type) to call QueryInterface with the correct interface identifier.
Three ctors are provided:
IDispatch*: convenience overload that wraps the pointer in a unique_com_ptr<IDispatch> and delegates to the owning ctor.unique_com_ptr<IDispatch>: takes ownership of the supplied generic pointer and narrows it to T via query_interface<T>.Copy construction and copy assignment are implicitly deleted by the unique_ptr base, preventing accidental duplication of COM reference counts. Move construction and move assignment are defaulted.
| T | A DispatchWrapper struct that publicly inherits a COM dispatch type and declares using type = <raw dispatch type>. |
Definition at line 57 of file COMProxy.hpp.
|
default |
Default ctor; leaves the internal pointer null.
A null proxy compares equal to nullptr via the inherited unique_ptr::operator bool(). It must be populated by move-assignment before any COM methods are invoked through it.
|
inlineexplicit |
Constrcuts the proxy from a raw IDispatch*, taking ownership.
Wraps subject in a unique_com_ptr<IDispatch> and delegates to the owning ctor, which calls query_interface<T> to narrow the pointer to T.
| subject | Raw IDispatch pointer obtained from a COM call. Ownership is transferred to the proxy; the caller must not call Release() on it afterwards. |
| std::invalid_argument | if subject is null. |
| std::runtime_error | if QueryInterface forT::type` fails. |
Definition at line 83 of file COMProxy.hpp.
|
inlineexplicit |
Constructs the proxy by narrowing an owning IDispatch pointer to T.
Calls query_interface<T>(std::move(subject)) which invokes QueryInterface with __uuidof(T::type). The resulting unique_com_ptr<T> is stored in the unique_ptr base.
| subject | Owning pointer to a generic IDispatch COM object. Ownership is transferred; the caller's handle is left null after construction. |
| std::invalid_argument | if subject is null. |
| std::runtime_error | if QueryInterface for T::type fails. |
Definition at line 99 of file COMProxy.hpp.
References pacemaker::inca::detail::query_interface().

Move ctor; transfers ownership of the COM pointer.
Move assignment; transfers ownership of the COM pointer.