File indexing completed on 2024-04-06 12:13:00
0001 #ifndef FWCore_PyBind11ParameterSet_PyBind11ProcessDesc_h
0002 #define FWCore_PyBind11ParameterSet_PyBind11ProcessDesc_h
0003
0004 #include "FWCore/PythonParameterSet/interface/Python11ParameterSet.h"
0005
0006 #include <memory>
0007 #include <string>
0008 #include <vector>
0009
0010 namespace edm {
0011 class ParameterSet;
0012 class ProcessDesc;
0013 }
0014
0015 class PyBind11InterpreterSentry {
0016 public:
0017 PyBind11InterpreterSentry(bool ownsInterpreter);
0018 ~PyBind11InterpreterSentry();
0019
0020 pybind11::object mainModule;
0021
0022 private:
0023 bool const ownsInterpreter_;
0024 };
0025
0026 class PyBind11ProcessDesc {
0027 public:
0028 PyBind11ProcessDesc();
0029
0030
0031
0032
0033
0034
0035
0036 PyBind11ProcessDesc(std::string const& config, bool isFile);
0037
0038 PyBind11ProcessDesc(std::string const& config, bool isFile, const std::vector<std::string>& args);
0039
0040 ~PyBind11ProcessDesc();
0041
0042 Python11ParameterSet newPSet() const { return Python11ParameterSet(); }
0043
0044 Python11ParameterSet& pset() { return theProcessPSet; }
0045
0046 std::string dump() const;
0047
0048
0049 std::unique_ptr<edm::ParameterSet> parameterSet() const;
0050
0051
0052
0053 std::unique_ptr<edm::ProcessDesc> processDesc() const;
0054
0055 private:
0056 void prepareToRead();
0057 void read(std::string const& config, bool isFile);
0058 void readFile(std::string const& fileName);
0059 void readString(std::string const& pyConfig);
0060
0061 Python11ParameterSet theProcessPSet;
0062 PyBind11InterpreterSentry theInterpreter;
0063 };
0064
0065 #endif