CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_4/src/FWCore/PythonParameterSet/src/PythonModule.h

Go to the documentation of this file.
00001 #ifndef FWCore_PythonParameterSet_PythonModule_h
00002 #define FWCore_PythonParameterSet_PythonModule_h
00003 
00004 #include "FWCore/PythonParameterSet/interface/BoostPython.h"
00005 #include "FWCore/PythonParameterSet/interface/PythonParameterSet.h"
00006 #include "FWCore/PythonParameterSet/interface/PythonProcessDesc.h"
00007 
00008 #include "DataFormats/Provenance/interface/EventRange.h"
00009 #include "DataFormats/Provenance/interface/LuminosityBlockID.h"
00010 #include "DataFormats/Provenance/interface/LuminosityBlockRange.h"
00011 #include "DataFormats/Provenance/interface/EventID.h"
00012 #include "FWCore/Utilities/interface/ESInputTag.h"
00013 #include "FWCore/Utilities/interface/Exception.h"
00014 #include "FWCore/Utilities/interface/InputTag.h"
00015 
00016 #include <string>
00017 
00018 // This is to give some special handling to cms::Exceptions thrown
00019 // in C++ code called by python. Only at the very top level do
00020 // we need the exception message returned by the function "what".
00021 // We only need the central message here as this will get converted
00022 // back into a cms::Exception again when control rises back into
00023 // the C++ code.  If necessary it would probably be possible to
00024 // improve these messages even more by adding something in the python
00025 // to add module type and label context to the messages being caught
00026 // here. At this point we did not think it worth the time to implement.
00027 namespace {
00028   void translator(cms::Exception const& ex) {
00029     PyErr_SetString(PyExc_RuntimeError, ex.message().c_str());
00030   }
00031 }
00032 
00033 BOOST_PYTHON_MODULE(libFWCoreParameterSet)
00034 {
00035   boost::python::register_exception_translator<cms::Exception>(translator);
00036 
00037   boost::python::class_<edm::InputTag>("InputTag", boost::python::init<std::string>())
00038       .def(boost::python::init<std::string, std::string, std::string>())
00039       .def(boost::python::init<std::string, std::string>())
00040       .def("label",    &edm::InputTag::label, boost::python::return_value_policy<boost::python::copy_const_reference>())
00041       .def("instance", &edm::InputTag::instance, boost::python::return_value_policy<boost::python::copy_const_reference>())
00042       .def("process",  &edm::InputTag::process, boost::python::return_value_policy<boost::python::copy_const_reference>())
00043   ;
00044 
00045    boost::python::class_<edm::ESInputTag>("ESInputTag", boost::python::init<std::string>())
00046    .def(boost::python::init<std::string, std::string>())
00047    .def("module",    &edm::ESInputTag::module, boost::python::return_value_policy<boost::python::copy_const_reference>())
00048    .def("data",  &edm::ESInputTag::data, boost::python::return_value_policy<boost::python::copy_const_reference>())
00049    ;
00050 
00051    boost::python::class_<edm::EventID>("EventID", boost::python::init<unsigned int, unsigned int, unsigned int>())
00052       .def("run",   &edm::EventID::run)
00053       .def("luminosityBlock", &edm::EventID::luminosityBlock)
00054       .def("event", &edm::EventID::event)
00055   ;
00056 
00057   boost::python::class_<edm::LuminosityBlockID>("LuminosityBlockID", boost::python::init<unsigned int, unsigned int>())
00058       .def("run",    &edm::LuminosityBlockID::run)
00059       .def("luminosityBlock", &edm::LuminosityBlockID::luminosityBlock)
00060   ;
00061 
00062   boost::python::class_<edm::FileInPath>("FileInPath", boost::python::init<std::string>())
00063       .def("fullPath",     &edm::FileInPath::fullPath)
00064       .def("relativePath", &edm::FileInPath::relativePath)
00065       .def("isLocal",      &edm::FileInPath::isLocal)
00066   ;
00067 
00068   boost::python::class_<edm::LuminosityBlockRange>("LuminosityBlockRange", boost::python::init<unsigned int, unsigned int, unsigned int, unsigned int>())
00069       .def("start",    &edm::LuminosityBlockRange::startRun)
00070       .def("startSub", &edm::LuminosityBlockRange::startLumi)
00071       .def("end",      &edm::LuminosityBlockRange::endRun)
00072       .def("endSub",   &edm::LuminosityBlockRange::endLumi)
00073   ;
00074 
00075   boost::python::class_<edm::EventRange>("EventRange", boost::python::init<unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int>())
00076       .def("start",     &edm::EventRange::startRun)
00077       .def("startLumi", &edm::EventRange::startLumi)
00078       .def("startSub",  &edm::EventRange::startEvent)
00079       .def("end",       &edm::EventRange::endRun)
00080       .def("endLumi",   &edm::EventRange::endLumi)
00081       .def("endSub",    &edm::EventRange::endEvent)
00082   ;
00083 
00084   boost::python::class_<PythonParameterSet>("ParameterSet")
00085     .def("addInt32", &PythonParameterSet::addParameter<int>)
00086     .def("getInt32", &PythonParameterSet::getParameter<int>)
00087     .def("addVInt32", &PythonParameterSet::addParameters<int>)
00088     .def("getVInt32", &PythonParameterSet::getParameters<int>)
00089     .def("addUInt32", &PythonParameterSet::addParameter<unsigned int>)
00090     .def("getUInt32", &PythonParameterSet::getParameter<unsigned int>)
00091     .def("addVUInt32", &PythonParameterSet::addParameters<unsigned int>)
00092     .def("getVUInt32", &PythonParameterSet::getParameters<unsigned int>)
00093     .def("addInt64", &PythonParameterSet::addParameter<long long>)
00094     .def("getInt64", &PythonParameterSet::getParameter<long long>)
00095     .def("addUInt64", &PythonParameterSet::addParameter<unsigned long long>)
00096     .def("getUInt64", &PythonParameterSet::getParameter<unsigned long long>)
00097     .def("addVInt64", &PythonParameterSet::addParameters<long long>)
00098     .def("getVInt64", &PythonParameterSet::getParameters<long long>)
00099     .def("addVUInt64", &PythonParameterSet::addParameters<unsigned long long>)
00100     .def("getVUInt64", &PythonParameterSet::getParameters<unsigned long long>)
00101     .def("addDouble", &PythonParameterSet::addParameter<double>)
00102     .def("getDouble", &PythonParameterSet::getParameter<double>)
00103     .def("addVDouble", &PythonParameterSet::addParameters<double>)
00104     .def("getVDouble", &PythonParameterSet::getParameters<double>)
00105     .def("addBool", &PythonParameterSet::addParameter<bool>)
00106     .def("getBool", &PythonParameterSet::getParameter<bool>)
00107     .def("addString", &PythonParameterSet::addParameter<std::string>)
00108     .def("getString", &PythonParameterSet::getParameter<std::string>)
00109     .def("addVString", &PythonParameterSet::addParameters<std::string>)
00110     .def("getVString", &PythonParameterSet::getParameters<std::string>)
00111     .def("addInputTag", &PythonParameterSet::addParameter<edm::InputTag>)
00112     .def("getInputTag", &PythonParameterSet::getParameter<edm::InputTag>)
00113     .def("addVInputTag", &PythonParameterSet::addParameters<edm::InputTag>)
00114     .def("getVInputTag", &PythonParameterSet::getParameters<edm::InputTag>)
00115     .def("addESInputTag", &PythonParameterSet::addParameter<edm::ESInputTag>)
00116     .def("getESInputTag", &PythonParameterSet::getParameter<edm::ESInputTag>)
00117     .def("addVESInputTag", &PythonParameterSet::addParameters<edm::ESInputTag>)
00118     .def("getVESInputTag", &PythonParameterSet::getParameters<edm::ESInputTag>)
00119     .def("addEventID", &PythonParameterSet::addParameter<edm::EventID>)
00120     .def("getEventID", &PythonParameterSet::getParameter<edm::EventID>)
00121     .def("addVEventID", &PythonParameterSet::addParameters<edm::EventID>)
00122     .def("getVEventID", &PythonParameterSet::getParameters<edm::EventID>)
00123     .def("addLuminosityBlockID", &PythonParameterSet::addParameter<edm::LuminosityBlockID>)
00124     .def("getLuminosityBlockID", &PythonParameterSet::getParameter<edm::LuminosityBlockID>)
00125     .def("addVLuminosityBlockID", &PythonParameterSet::addParameters<edm::LuminosityBlockID>)
00126     .def("getVLuminosityBlockID", &PythonParameterSet::getParameters<edm::LuminosityBlockID>)
00127     .def("addLuminosityBlockRange", &PythonParameterSet::addParameter<edm::LuminosityBlockRange>)
00128     .def("getLuminosityBlockRange", &PythonParameterSet::getParameter<edm::LuminosityBlockRange>)
00129     .def("addVLuminosityBlockRange", &PythonParameterSet::addParameters<edm::LuminosityBlockRange>)
00130     .def("getVLuminosityBlockRange", &PythonParameterSet::getParameters<edm::LuminosityBlockRange>)
00131     .def("addEventRange", &PythonParameterSet::addParameter<edm::EventRange>)
00132     .def("getEventRange", &PythonParameterSet::getParameter<edm::EventRange>)
00133     .def("addVEventRange", &PythonParameterSet::addParameters<edm::EventRange>)
00134     .def("getVEventRange", &PythonParameterSet::getParameters<edm::EventRange>)
00135     .def("addPSet", &PythonParameterSet::addPSet)
00136     .def("getPSet", &PythonParameterSet::getPSet)
00137     .def("addVPSet", &PythonParameterSet::addVPSet)
00138     .def("getVPSet", &PythonParameterSet::getVPSet)
00139     .def("addFileInPath", &PythonParameterSet::addParameter<edm::FileInPath>)
00140     .def("getFileInPath", &PythonParameterSet::getParameter<edm::FileInPath>)
00141     .def("newInputTag", &PythonParameterSet::newInputTag)
00142     .def("newESInputTag", &PythonParameterSet::newESInputTag)
00143     .def("newEventID", &PythonParameterSet::newEventID)
00144     .def("newLuminosityBlockID", &PythonParameterSet::newLuminosityBlockID)
00145     .def("newLuminosityBlockRange", &PythonParameterSet::newLuminosityBlockRange)
00146     .def("newEventRange", &PythonParameterSet::newEventRange)
00147     .def("addNewFileInPath", &PythonParameterSet::addNewFileInPath)
00148     .def("newPSet", &PythonParameterSet::newPSet)
00149     .def("dump", &PythonParameterSet::dump)
00150   ;
00151 
00152   boost::python::class_<PythonProcessDesc>("ProcessDesc", boost::python::init<>())
00153     .def(boost::python::init<std::string>())
00154     .def("newPSet", &PythonProcessDesc::newPSet)
00155     .def("dump", &PythonProcessDesc::dump)
00156   ;
00157 }
00158 #endif