Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:46:48

0001 #ifndef FWCore_Framework_CmsRunParser_h
0002 #define FWCore_Framework_CmsRunParser_h
0003 
0004 #include "boost/program_options.hpp"
0005 
0006 #include <variant>
0007 
0008 namespace edm {
0009   class CmsRunParser {
0010   public:
0011     using MapOrExit = std::variant<boost::program_options::variables_map, int>;
0012     CmsRunParser(const char* name);
0013     MapOrExit parse(int argc, const char* argv[]) const;
0014     //variant helpers
0015     static bool hasVM(const MapOrExit& output) {
0016       return std::holds_alternative<boost::program_options::variables_map>(output);
0017     }
0018     static boost::program_options::variables_map getVM(const MapOrExit& output) {
0019       return std::get<boost::program_options::variables_map>(output);
0020     }
0021     static bool hasExit(const MapOrExit& output) { return std::holds_alternative<int>(output); }
0022     static int getExit(const MapOrExit& output) { return std::get<int>(output); }
0023 
0024   private:
0025     boost::program_options::options_description desc_;
0026     boost::program_options::options_description all_options_;
0027     boost::program_options::positional_options_description pos_options_;
0028 
0029   public:
0030     //Command line parameters
0031     static inline const char* const kParameterSetOpt = "parameter-set";
0032     static inline const char* const kPythonOpt = "pythonOptions";
0033     static inline const char* const kPythonOptDefault = "CMSRUN_PYTHONOPT_DEFAULT";
0034     static inline const char* const kCmdCommandOpt = "command,c";
0035     static inline const char* const kCmdOpt = "command";
0036     static inline const char* const kJobreportCommandOpt = "jobreport,j";
0037     static inline const char* const kJobreportOpt = "jobreport";
0038     static inline const char* const kEnableJobreportCommandOpt = "enablejobreport,e";
0039     static inline const char* const kEnableJobreportOpt = "enablejobreport";
0040     static inline const char* const kJobModeCommandOpt = "mode,m";
0041     static inline const char* const kJobModeOpt = "mode";
0042     static inline const char* const kNumberOfThreadsCommandOpt = "numThreads,n";
0043     static inline const char* const kNumberOfThreadsOpt = "numThreads";
0044     static inline const char* const kSizeOfStackForThreadCommandOpt = "sizeOfStackForThreadsInKB,s";
0045     static inline const char* const kSizeOfStackForThreadOpt = "sizeOfStackForThreadsInKB";
0046     static inline const char* const kHelpOpt = "help";
0047     static inline const char* const kHelpCommandOpt = "help,h";
0048     static inline const char* const kStrictOpt = "strict";
0049   };
0050 }  // namespace edm
0051 
0052 #endif