CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/CondCore/Utilities/interface/InspectorPythonWrapper.h

Go to the documentation of this file.
00001 #include <boost/python.hpp>
00002 #include <boost/python/suite/indexing/vector_indexing_suite.hpp>
00003 #include "CondCore/DBCommon/interface/ClassID.h"
00004 
00005 
00006 namespace condPython {
00007   template<typename T>
00008   void defineWhat() {
00009     using namespace boost::python;
00010     typedef cond::ExtractWhat<T> What;
00011     class_<What>("What",init<>());
00012   }
00013 
00014 }
00015 
00016 namespace {
00017   
00018   template<typename Wrapper>
00019   void define() {
00020     using namespace boost::python;
00021     typedef typename Wrapper::Extractor Extractor;
00022     typedef typename Extractor::What What;
00023 
00024     condPython::defineWhat<typename Extractor::Class>();
00025 
00026     class_<Extractor>("Extractor", init<>())
00027       .def(init<What>())
00028       .def("what",Extractor::what)
00029       .def("values",&Extractor::values, return_value_policy<copy_const_reference>())
00030       ;
00031 
00032     class_<Wrapper>("Object",init<>()) 
00033       .def(init<cond::CondDB>())
00034       .def("load",&Wrapper::load)
00035       .def("dump",&Wrapper::dump)
00036       .def("dumpXML",&Wrapper::dumpXML)
00037       .def("plot",&Wrapper::plot)
00038       .def("summary",&Wrapper::summary) 
00039       .def("extract",&Wrapper::extract)
00040       .def("trend_plot",&Wrapper::trend_plot)
00041       .def("summary_adv",&Wrapper::summary_adv)
00042       .def("dumpFile", &Wrapper::dumpFile)
00043       ; 
00044   }
00045 }
00046 
00047 
00048 #define PYTHON_WRAPPER(_class,_name) \
00049 namespace { typedef cond::PayLoadInspector< _class > PythonWrapper;} \
00050  BOOST_PYTHON_MODULE(plugin ## _name ## PyInterface) { define<PythonWrapper>(); } \
00051 namespace { const char * pluginName_="plugin"  #_name "PyInterface"; }\
00052  PYTHON_ID(PythonWrapper::Class, pluginName_, _name)
00053 
00054