Confdump Agent  1.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends
Public Member Functions | Private Member Functions | Private Attributes
Confdump::System::Wmi::WbemServices Class Reference

Access to a WMI (Wbem) server. More...

#include <WbemServices.hpp>

List of all members.

Public Member Functions

 WbemServices (ComContext::Guard comGuard)
 ~WbemServices ()
void connect ()
 Connect to a WMI server.
void setWmiNamespace (QString ns)
 Set the namespace to connect() to.
boost::iterator_range
< WbemQueryIterator
execQuery (const Query &)
 Run a WMI query.
boost::iterator_range
< WbemQueryIterator
listAllClasses ()
 Enumerate WMI classes in the current namespace.

Private Member Functions

 WbemServices ()

Private Attributes

ComContext::Guard comGuard_
 This ensures that COM stays initialized.
boost::shared_ptr< IWbemServices > services_
QString wmiNamespace_
WmiLists wmiLists_

Detailed Description

Access to a WMI (Wbem) server.

This encapsulates the requirement of COM initialization, allows to connect to a Wbem server and then to run a query.

Definition at line 115 of file WbemServices.hpp.


Constructor & Destructor Documentation

The (non-NULL!) ComContext::Guard will be kept alive while this object needs it and ensure that COM is initialized.

Definition at line 79 of file WbemServices.cpp.

Definition at line 85 of file WbemServices.cpp.


Member Function Documentation

Connect to a WMI server.

Connect to localhost, with the configured namespace (which defaults to CIMv2).

Exceptions:
NoSuchNamespace
WmiError
ComError

Definition at line 134 of file WbemServices.cpp.

References services_, and wmiNamespace_.

boost::iterator_range< WbemQueryIterator > Confdump::System::Wmi::WbemServices::execQuery ( const Query query)

Run a WMI query.

Returns:
A range that can be iterated through the standard begin()/end() accessors, or even fed directly to BOOST_FOREACH().
Precondition:
connect() has been called and did not throw.
Exceptions:
NoSuchClass
WmiError
ComError

Definition at line 148 of file WbemServices.cpp.

References Confdump::System::Wmi::Query::getClass(), Confdump::System::Wmi::Query::getQuery(), Confdump::System::Wmi::guardComObject(), Confdump::System::Wmi::NoSuchClass::hresult(), Confdump::System::Wmi::Win32Error::hresult(), Confdump::System::Wmi::WmiLists::isTableAllowed(), services_, Confdump::System::Wmi::throwOnWmiError(), wmiLists_, and wmiNamespace_.

Enumerate WMI classes in the current namespace.

Returns:
A range that can be iterated through the standard begin()/end() accessors, or even fed directly to BOOST_FOREACH().
Precondition:
connect() has been called and did not throw.
Exceptions:
WmiError
ComError

Definition at line 180 of file WbemServices.cpp.

References Confdump::System::Wmi::guardComObject(), services_, and Confdump::System::Wmi::throwOnWmiError().

Set the namespace to connect() to.

Default: CIMv2.

Exceptions:
RuntimeErrorif the namespace is not allowed (this a security feature to prevent any system modification that could be made by unknown WMI modules).

Definition at line 140 of file WbemServices.cpp.

References Confdump::System::Wmi::WmiLists::isNamespaceAllowed(), wmiLists_, and wmiNamespace_.


Member Data Documentation

This ensures that COM stays initialized.

Definition at line 175 of file WbemServices.hpp.

boost::shared_ptr<IWbemServices> Confdump::System::Wmi::WbemServices::services_ [private]

Definition at line 176 of file WbemServices.hpp.

Referenced by connect(), execQuery(), and listAllClasses().

Definition at line 178 of file WbemServices.hpp.

Referenced by execQuery(), and setWmiNamespace().

Definition at line 177 of file WbemServices.hpp.

Referenced by connect(), execQuery(), and setWmiNamespace().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends