File indexing completed on 2024-04-06 12:12:59
0001
0002
0003 #include <iostream>
0004 #include <utility>
0005 #include <cstdlib>
0006 #include <string>
0007 #include <set>
0008 #include <boost/program_options.hpp>
0009
0010 #include "FWCore/PluginManager/interface/PluginManager.h"
0011 #include "FWCore/PluginManager/interface/standard.h"
0012
0013 using namespace edmplugin;
0014
0015 int main(int argc, char** argv) {
0016 using namespace boost::program_options;
0017
0018 static const char* const kFilesOpt = "files";
0019 static const char* const kFilesCommandOpt = "files,f";
0020 static const char* const kAllFilesOpt = "all_files";
0021 static const char* const kAllFilesCommandOpt = "all_files,a";
0022 static const char* const kHelpOpt = "help";
0023 static const char* const kHelpCommandOpt = "help,h";
0024
0025 std::string descString(argv[0]);
0026 descString += " [options]";
0027 descString += "\nAllowed options";
0028 options_description desc(descString);
0029 desc.add_options()(kHelpCommandOpt, "produce help message")(kFilesCommandOpt,
0030 "list the file from which a plugin will come")(
0031 kAllFilesCommandOpt, "list all the files to which a plugin is registered")
0032
0033 ;
0034
0035 variables_map vm;
0036 try {
0037 store(command_line_parser(argc, argv).options(desc).run(), vm);
0038 notify(vm);
0039 } catch (const error& iException) {
0040 std::cerr << iException.what();
0041 return 1;
0042 }
0043
0044 if (vm.count(kHelpOpt)) {
0045 std::cout << desc << std::endl;
0046 return 0;
0047 }
0048
0049 bool printFiles = false;
0050 if (vm.count(kFilesOpt)) {
0051 printFiles = true;
0052 }
0053
0054 bool printAllFiles = false;
0055 if (vm.count(kAllFilesOpt)) {
0056 printFiles = true;
0057 printAllFiles = true;
0058 }
0059
0060 int returnValue = EXIT_SUCCESS;
0061 try {
0062
0063 PluginManager::configure(standard::config());
0064
0065 typedef edmplugin::PluginManager::CategoryToInfos CatToInfos;
0066
0067 const CatToInfos& catToInfos = edmplugin::PluginManager::get()->categoryToInfos();
0068
0069 for (CatToInfos::const_iterator it = catToInfos.begin(), itEnd = catToInfos.end(); it != itEnd; ++it) {
0070 std::cout << "Category " << it->first << ":" << std::endl;
0071 std::string prevPluginName;
0072 for (edmplugin::PluginManager::Infos::const_iterator itInfo = it->second.begin(), itInfoEnd = it->second.end();
0073 itInfo != itInfoEnd;
0074 ++itInfo) {
0075 std::string pluginName = itInfo->name_;
0076 if (pluginName != prevPluginName) {
0077 std::cout << " " << pluginName << std::endl;
0078 if (printFiles) {
0079 std::cout << " " << itInfo->loadable_.string() << std::endl;
0080 }
0081 prevPluginName = pluginName;
0082 } else if (printAllFiles) {
0083 std::cout << " " << itInfo->loadable_.string() << std::endl;
0084 }
0085 }
0086 }
0087 } catch (std::exception& iException) {
0088 std::cerr << "Caught exception " << iException.what() << std::endl;
0089 returnValue = EXIT_FAILURE;
0090 }
0091
0092 return returnValue;
0093 }