Confdump Agent
1.4.0
|
COM management (un/initialize) More...
#include <ComContext.hpp>
Classes | |
class | GuardImpl |
Implementation of the Guard, use ComContext::Guard instead. More... | |
Public Types | |
typedef boost::shared_ptr < GuardImpl > | Guard |
A suitable Guard to keep around while you need COM. | |
Public Member Functions | |
Guard | getGuard () |
Returns a COM guard. | |
ComContext () | |
~ComContext () | |
Static Private Attributes | |
static boost::weak_ptr< GuardImpl > | instance_ |
COM management (un/initialize)
Magically ensures that COM is initialized and configured when you use it and uninitialized when you're done.
Just make sure to have a ComContext::Guard copy somewhere until you don't need COM anymore.
ComContext::Guard guard = ComContext().getGuard();
This class is not thread-safe.
How it works: the guards (a shared_ptr type) keep a reference count, when it drops to zero CoUninitialize() is called. Because COM cannot be initialized (or uninitialized) more than once at once in the current thread/program, getGuard() will make sure that all returned guards reference the same counter. So, the object referenced by the guards is in substance a singleton.
ComContext has no data members for now, but might get some in the future when it will allow to configure COM more finely (that's why getGuard() is not static).
Definition at line 59 of file ComContext.hpp.
typedef boost::shared_ptr<GuardImpl> Confdump::System::Wmi::ComContext::Guard |
A suitable Guard to keep around while you need COM.
Definition at line 61 of file ComContext.hpp.
Definition at line 46 of file ComContext.cpp.
Definition at line 50 of file ComContext.cpp.
Returns a COM guard.
COM will stay initialized while you have such a guard around.
ComError |
Definition at line 34 of file ComContext.cpp.
References instance_.
Referenced by Confdump::System::Win32Dumper::doQueryTable(), and Confdump::System::WmiDumper::initWbemServices().
boost::weak_ptr< ComContext::GuardImpl > Confdump::System::Wmi::ComContext::instance_ [static, private] |
The static (hence global) variable that ensures that all Guard instances reference the same counter.
Definition at line 98 of file ComContext.hpp.
Referenced by getGuard().