File indexing completed on 2024-04-06 12:05:33
0001 #include <cstdlib>
0002 #include <iostream>
0003 #include <string>
0004
0005 #include "DetectorDescription/Core/interface/DDCompactView.h"
0006 #include "DetectorDescription/Parser/interface/DDLParser.h"
0007 #include "DetectorDescription/Parser/interface/DDLSAX2FileHandler.h"
0008 #include "DetectorDescription/Parser/interface/FIPConfiguration.h"
0009 #include "DetectorDescription/RegressionTest/interface/DDErrorDetection.h"
0010 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0011 #include "FWCore/PluginManager/interface/PluginManager.h"
0012 #include "FWCore/PluginManager/interface/standard.h"
0013 #include "FWCore/Utilities/interface/Exception.h"
0014 #include <boost/program_options.hpp>
0015 #include <boost/exception/diagnostic_information.hpp>
0016
0017 int main(int argc, char* argv[]) {
0018 try {
0019 edmplugin::PluginManager::configure(edmplugin::standard::config());
0020 } catch (cms::Exception& e) {
0021 edm::LogInfo("DDErrorReport") << "Attempting to configure the plugin manager. Exception message: " << e.what();
0022 return 1;
0023 }
0024
0025
0026 std::string descString("DDErrorReport");
0027 descString += " [options] configurationFileName\n";
0028 descString += "Allowed options";
0029 boost::program_options::options_description desc(descString);
0030 desc.add_options()("help,h", "Print this help message")(
0031 "file,f",
0032 boost::program_options::value<std::string>(),
0033 "XML configuration file name. "
0034 "Default is DetectorDescription/RegressionTest/test/configuration.xml")("path,p",
0035 "Specifies filename is a full path and "
0036 "not to use FileInPath to find file. "
0037 " This option is ignored if a filename "
0038 "is not specified");
0039
0040 boost::program_options::positional_options_description p;
0041 p.add("file", -1);
0042
0043 boost::program_options::variables_map vm;
0044 try {
0045 store(boost::program_options::command_line_parser(argc, argv).options(desc).positional(p).run(), vm);
0046 notify(vm);
0047 } catch (boost::program_options::error const& iException) {
0048 std::cerr << "Exception from command line processing: " << iException.what() << "\n";
0049 std::cerr << desc << std::endl;
0050 return 1;
0051 }
0052
0053 if (vm.count("help")) {
0054 std::cout << desc << std::endl;
0055 return 0;
0056 }
0057
0058 bool fullPath = false;
0059 std::string configfile("DetectorDescription/RegressionTest/test/configuration.xml");
0060 try {
0061 if (vm.count("file")) {
0062 configfile = vm["file"].as<std::string>();
0063 if (vm.count("path")) {
0064 fullPath = true;
0065 }
0066 }
0067 } catch (boost::exception& e) {
0068 edm::LogInfo("DDErrorReport") << "Attempting to parse the options. Exception message: "
0069 << boost::diagnostic_information(e);
0070 return 1;
0071 }
0072
0073 DDCompactView cpv;
0074 DDLParser myP(cpv);
0075 myP.getDDLSAX2FileHandler()->setUserNS(false);
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086 FIPConfiguration fp(cpv);
0087 try {
0088 fp.readConfig(configfile, fullPath);
0089 } catch (cms::Exception& e) {
0090 edm::LogInfo("DDErrorReport") << "Attempting to read config. Exception message: " << e.what();
0091 return 1;
0092 }
0093
0094 int parserResult = myP.parse(fp);
0095 if (parserResult != 0) {
0096 std::cout << " problem encountered during parsing. exiting ... " << std::endl;
0097 exit(1);
0098 }
0099 std::cout << "Parsing completed. Start checking for errors." << std::endl;
0100
0101 DDErrorDetection ed(cpv);
0102
0103 bool noErrors = ed.noErrorsInTheReport(cpv);
0104 if (noErrors && fullPath) {
0105 std::cout << "DDErrorReport did not find any errors and is finished." << std::endl;
0106 } else {
0107 ed.report(cpv, std::cout);
0108 if (!noErrors) {
0109 return 1;
0110 }
0111 }
0112 return 0;
0113 }