![]() |
TSDuck v3.46-4930
MPEG Transport Stream Toolkit
|
#include <tsComPtr.h>
Public Member Functions | |
| ComPtr (::IUnknown *obj, const IID &interface_id, Report &report=(ts::CerrReport::Instance())) | |
| ComPtr (COMCLASS *p=nullptr, ::HRESULT hr=S_OK) | |
| ComPtr (ComPtr< COMCLASS > &&p) | |
| ComPtr (const ::IID &class_id, const ::IID &interface_id, Report &report=(ts::CerrReport::Instance())) | |
| ComPtr (const ComPtr< COMCLASS > &p) | |
| ~ComPtr () | |
| template<class COMSUBCLASS> requires std::derived_from<COMSUBCLASS, COMCLASS> | |
| ComPtr< COMCLASS > & | assign (const ComPtr< COMSUBCLASS > &p) |
| ComPtr< COMCLASS > & | bindToObject (::IMoniker *moniker, const IID &interface_id, Report &report=(ts::CerrReport::Instance())) |
| UString | className () const |
| ComPtr< COMCLASS > & | createInstance (const ::IID &class_id, const ::IID &interface_id, Report &report=(ts::CerrReport::Instance())) |
| COMCLASS ** | creator () |
| bool | expose (const ::IID &iid) const |
| bool | isNull () const |
| COMCLASS & | operator* () const |
| COMCLASS * | operator-> () const |
| ComPtr< COMCLASS > & | operator= (COMCLASS *p) |
| ComPtr< COMCLASS > & | operator= (ComPtr< COMCLASS > &&p) |
| ComPtr< COMCLASS > & | operator= (const ComPtr< COMCLASS > &p) |
| COMCLASS * | pointer () const |
| ComPtr< COMCLASS > & | queryInterface (::IUnknown *obj, const IID &interface_id, Report &report=(ts::CerrReport::Instance())) |
| int | refCount () const |
| void | release () |
Managed pointers for COM objects, auto-released (Windows-specific).
| COMCLASS | A COM interface or object class. |
If TS_COM_INSTRUMENTATION is defined and the application is compiled in debug mode, the ComPtr class produces abundant trace messages on the standard error.
Trace line format:
With:
| ts::ComPtr< COMCLASS >::ComPtr | ( | COMCLASS * | p = nullptr, |
| ::HRESULT | hr = S_OK ) |
| ts::ComPtr< COMCLASS >::ComPtr | ( | const ComPtr< COMCLASS > & | p | ) |
| ts::ComPtr< COMCLASS >::ComPtr | ( | ComPtr< COMCLASS > && | p | ) |
| ts::ComPtr< COMCLASS >::ComPtr | ( | const ::IID & | class_id, |
| const ::IID & | interface_id, | ||
| Report & | report = (ts::CerrReport::Instance()) ) |
Constructor using CoCreateInstance(). If the COM object is successfully created, it becomes managed and its reference count is unchanged (== 1).
| [in] | class_id | Class id of the COM object to create. |
| [in] | interface_id | Id of the interface we request in the object. |
| [in] | report | Where to report errors. |
Example:
| ts::ComPtr< COMCLASS >::ComPtr | ( | ::IUnknown * | obj, |
| const IID & | interface_id, | ||
| Report & | report = (ts::CerrReport::Instance()) ) |
| ts::ComPtr< COMCLASS >::~ComPtr | ( | ) |
Destructor. The COM object is released (its reference count is decremented).
| bool ts::ComPtr< COMCLASS >::isNull | ( | ) | const |
Check if null pointer.
| COMCLASS * ts::ComPtr< COMCLASS >::pointer | ( | ) | const |
| COMCLASS & ts::ComPtr< COMCLASS >::operator* | ( | ) | const |
| COMCLASS * ts::ComPtr< COMCLASS >::operator-> | ( | ) | const |
| COMCLASS ** ts::ComPtr< COMCLASS >::creator | ( | ) |
| void ts::ComPtr< COMCLASS >::release | ( | ) |
Release the COM object, its reference count is decremented. The pointer becomes null.
| int ts::ComPtr< COMCLASS >::refCount | ( | ) | const |
Get the reference count to the object. WARNING: This should be used for test or debug purpose only. Since there is no direct way to get the reference count of a COM object, we perform an AddRef / Release operation. The reference count is returned by Release().
| ComPtr< COMCLASS > & ts::ComPtr< COMCLASS >::assign | ( | const ComPtr< COMSUBCLASS > & | p | ) |
| ComPtr< COMCLASS > & ts::ComPtr< COMCLASS >::operator= | ( | const ComPtr< COMCLASS > & | p | ) |
| ComPtr< COMCLASS > & ts::ComPtr< COMCLASS >::operator= | ( | ComPtr< COMCLASS > && | p | ) |
| ComPtr< COMCLASS > & ts::ComPtr< COMCLASS >::operator= | ( | COMCLASS * | p | ) |
| ComPtr< COMCLASS > & ts::ComPtr< COMCLASS >::createInstance | ( | const ::IID & | class_id, |
| const ::IID & | interface_id, | ||
| Report & | report = (ts::CerrReport::Instance()) ) |
Assign using CoCreateInstance(). If the COM object is successfully created, it becomes managed and its reference count is unchanged (== 1).
| [in] | class_id | Class id of the COM object to create. |
| [in] | interface_id | Id of the interface we request in the object. |
| [in] | report | Where to report errors. |
| ComPtr< COMCLASS > & ts::ComPtr< COMCLASS >::queryInterface | ( | ::IUnknown * | obj, |
| const IID & | interface_id, | ||
| Report & | report = (ts::CerrReport::Instance()) ) |
Assign using IUnknown::QueryInterface If the COM interface is successfully retrieved, it becomes managed and its reference count is unchanged (== 1).
| [in] | obj | A COM object. |
| [in] | interface_id | Id of the interface we request in the object. |
| [in] | report | Where to report errors. |
| ComPtr< COMCLASS > & ts::ComPtr< COMCLASS >::bindToObject | ( | ::IMoniker * | moniker, |
| const IID & | interface_id, | ||
| Report & | report = (ts::CerrReport::Instance()) ) |
Assign using IMoniker::BindToObject If the COM interface is successfully retrieved, it becomes managed and its reference count is unchanged (== 1).
| [in] | moniker | The moniker to use. |
| [in] | interface_id | Id of the interface we request in the object. |
| [in] | report | Where to report errors. |
| bool ts::ComPtr< COMCLASS >::expose | ( | const ::IID & | iid | ) | const |
Check if the object exposes an interface.
| [in] | iid | Id of the interface we request in the object. |
| UString ts::ComPtr< COMCLASS >::className | ( | ) | const |
Get the "class name" (formatted GUID) of this object. Warning: Very slow, eat CPU time, use with care.