Confdump Agent  1.4.0
WbemServices.hpp
Go to the documentation of this file.
00001 /* 
00002  * Confdump-Agent - Dump static and runtime system configuration
00003  * Copyright (C) 2009-2012  Straton IT, SAS
00004  * 
00005  * This program is free software: you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License version 3 as
00007  * published by the Free Software Foundation.
00008  * 
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  * 
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 
00018 #ifndef INCLUDED_CONFDUMP_SYSTEM_WMI_WBEMSERVICES_HPP
00019 #define INCLUDED_CONFDUMP_SYSTEM_WMI_WBEMSERVICES_HPP
00020 
00021 #include "boost/range.hpp"
00022 #include "boost/iterator/iterator_facade.hpp"
00023 
00024 #include "QString"
00025 
00026 #include "Confdump/System/Wmi/ComContext.hpp"
00027 #include "Confdump/System/Wmi/WmiLists.hpp"
00028 #include "Confdump/System/Wmi/Query.hpp"
00029 
00030 struct IWbemServices;
00031 struct IEnumWbemClassObject;
00032 struct IWbemClassObject;
00033 
00034 namespace Confdump
00035 {
00036 namespace System
00037 {
00038 namespace Wmi
00039 {
00040 
00070 class WbemQueryIterator
00071  : public boost::iterator_facade<
00072     WbemQueryIterator,
00073     boost::shared_ptr<IWbemClassObject>,
00074     boost::forward_traversal_tag,
00075     boost::shared_ptr<IWbemClassObject> >
00076 {
00077 public:
00079     WbemQueryIterator();
00081     explicit WbemQueryIterator( boost::shared_ptr<IEnumWbemClassObject> enumerator );
00082     ~WbemQueryIterator();
00083 
00084 private:
00085     friend class boost::iterator_core_access;
00086     template <class> friend class node_iter;
00087 
00093     bool equal( const WbemQueryIterator &other ) const;
00099     void increment();
00104     boost::shared_ptr<IWbemClassObject> dereference() const { return element_; }
00105 
00106     boost::shared_ptr<IEnumWbemClassObject> enumerator_;
00107     boost::shared_ptr<IWbemClassObject> element_;
00108 };
00109 
00115 class WbemServices
00116 {
00117 public:
00122     WbemServices( ComContext::Guard comGuard );
00123     ~WbemServices();
00124 
00134     void connect();
00135 
00144     void setWmiNamespace( QString ns );
00145 
00157     boost::iterator_range<WbemQueryIterator> execQuery( const Query & );
00158 
00169     boost::iterator_range<WbemQueryIterator> listAllClasses();
00170 
00171 private:
00172     WbemServices();
00173 
00175     ComContext::Guard comGuard_;
00176     boost::shared_ptr<IWbemServices> services_;
00177     QString wmiNamespace_;
00178     WmiLists wmiLists_;
00179 };
00180 
00181 }
00182 }
00183 }
00184 
00185 #endif /* INCLUDED_CONFDUMP_SYSTEM_WMI_WBEMSERVICES_HPP */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends