Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-06-11 04:37:11

0001 //<<<<<< INCLUDES                                                       >>>>>>
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")(
0030       kFilesCommandOpt,
0031       "list the file from which a plugin will come")(kAllFilesCommandOpt,
0032                                                      "list all the files to which a plugin is registered")
0033       //(kAllCommandOpt,"when no paths given, try to update caches for all known directories [default is to only scan the first directory]")
0034       ;
0035 
0036   variables_map vm;
0037   try {
0038     store(command_line_parser(argc, argv).options(desc).run(), vm);
0039     notify(vm);
0040   } catch (const error& iException) {
0041     std::cerr << iException.what();
0042     return 1;
0043   }
0044 
0045   if (vm.count(kHelpOpt)) {
0046     std::cout << desc << std::endl;
0047     return 0;
0048   }
0049 
0050   bool printFiles = false;
0051   if (vm.count(kFilesOpt)) {
0052     printFiles = true;
0053   }
0054 
0055   bool printAllFiles = false;
0056   if (vm.count(kAllFilesOpt)) {
0057     printFiles = true;
0058     printAllFiles = true;
0059   }
0060 
0061   int returnValue = EXIT_SUCCESS;
0062   try {
0063     //dump all know plugins
0064     PluginManager::configure(standard::config());
0065 
0066     typedef edmplugin::PluginManager::CategoryToInfos CatToInfos;
0067 
0068     const CatToInfos& catToInfos = edmplugin::PluginManager::get()->categoryToInfos();
0069     // map every module to its library.  Code copied from EdmPluginDump
0070     for (CatToInfos::const_iterator it = catToInfos.begin(), itEnd = catToInfos.end(); it != itEnd; ++it) {
0071       std::cout << "Category " << it->first << ":" << std::endl;
0072       std::string prevPluginName;
0073       for (edmplugin::PluginManager::Infos::const_iterator itInfo = it->second.begin(), itInfoEnd = it->second.end();
0074            itInfo != itInfoEnd;
0075            ++itInfo) {
0076         std::string pluginName = itInfo->name_;
0077         if (pluginName != prevPluginName) {
0078           std::cout << "  " << pluginName << std::endl;
0079           if (printFiles) {
0080             std::cout << "   " << itInfo->loadable_.string() << std::endl;
0081           }
0082           prevPluginName = pluginName;
0083         } else if (printAllFiles) {
0084           std::cout << "   " << itInfo->loadable_.string() << std::endl;
0085         }
0086       }
0087     }
0088   } catch (std::exception& iException) {
0089     std::cerr << "Caught exception " << iException.what() << std::endl;
0090     returnValue = EXIT_FAILURE;
0091   }
0092 
0093   return returnValue;
0094 }