CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
dump.cc File Reference
#include <iostream>
#include <utility>
#include <cstdlib>
#include <string>
#include <set>
#include <boost/program_options.hpp>
#include "FWCore/PluginManager/interface/PluginManager.h"
#include "FWCore/PluginManager/interface/standard.h"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 18 of file dump.cc.

References edmplugin::PluginManager::categoryToInfos(), dtNoiseDBValidation_cfg::cerr, edmplugin::standard::config(), edmplugin::PluginManager::configure(), gather_cfg::cout, error, cppFunctionSkipper::exception, edmplugin::PluginManager::get(), kHelpCommandOpt, kHelpOpt, AlCaHLTBitMon_ParallelJobs::options, DTTTrigCorrFirst::run, and AlCaHLTBitMon_QueryRunRegistry::string.

19 {
20  using namespace boost::program_options;
21 
22  static const char* const kFilesOpt = "files";
23  static const char* const kFilesCommandOpt = "files,f";
24  static const char* const kAllFilesOpt = "all_files";
25  static const char* const kAllFilesCommandOpt = "all_files,a";
26  static const char* const kHelpOpt = "help";
27  static const char* const kHelpCommandOpt = "help,h";
28 
29  std::string descString(argv[0]);
30  descString += " [options]";
31  descString += "\nAllowed options";
32  options_description desc(descString);
33  desc.add_options()
34  (kHelpCommandOpt, "produce help message")
35  (kFilesCommandOpt
36  , "list the file from which a plugin will come")
37  (kAllFilesCommandOpt
38  , "list all the files to which a plugin is registered")
39  //(kAllCommandOpt,"when no paths given, try to update caches for all known directories [default is to only scan the first directory]")
40  ;
41 
42  variables_map vm;
43  try {
44  store(command_line_parser(argc,argv).options(desc).run(),vm);
45  notify(vm);
46  } catch(const error& iException) {
47  std::cerr <<iException.what();
48  return 1;
49  }
50 
51  if(vm.count(kHelpOpt)) {
52  std::cout << desc <<std::endl;
53  return 0;
54  }
55 
56  bool printFiles = false;
57  if(vm.count(kFilesOpt) ) {
58  printFiles = true;
59  }
60 
61  bool printAllFiles = false;
62  if(vm.count(kAllFilesOpt) ) {
63  printFiles = true;
64  printAllFiles = true;
65  }
66 
67  int returnValue = EXIT_SUCCESS;
68  try {
69  //dump all know plugins
70  PluginManager::configure(standard::config());
71 
73 
74  const CatToInfos& catToInfos = edmplugin::PluginManager::get()->categoryToInfos();
75  // map every module to its library. Code copied from EdmPluginDump
76  for (CatToInfos::const_iterator it = catToInfos.begin(), itEnd=catToInfos.end();
77  it != itEnd; ++it)
78  {
79  std::cout <<"Category "<<it->first<<":"<<std::endl;
80  std::string prevPluginName;
81  for (edmplugin::PluginManager::Infos::const_iterator itInfo = it->second.begin(), itInfoEnd = it->second.end();
82  itInfo != itInfoEnd; ++itInfo)
83  {
84  std::string pluginName = itInfo->name_;
85  if(pluginName != prevPluginName) {
86  std::cout <<" "<<pluginName<<std::endl;
87  if(printFiles) {
88  std::cout <<" "<<itInfo->loadable_.string()<<std::endl;
89  }
90  prevPluginName=pluginName;
91  }
92  else if(printAllFiles) {
93  std::cout <<" "<<itInfo->loadable_.string()<<std::endl;
94  }
95  }
96  }
97  }catch(std::exception& iException) {
98  std::cerr <<"Caught exception "<<iException.what()<<std::endl;
99  returnValue = EXIT_FAILURE;
100  }
101 
102  return returnValue;
103 }
const CategoryToInfos & categoryToInfos() const
Definition: PluginManager.h:71
std::map< std::string, Infos > CategoryToInfos
Definition: PluginManager.h:43
static const char *const kHelpCommandOpt
Definition: CmsShowMain.cc:94
tuple argc
Definition: dir2webdir.py:41
tuple cout
Definition: gather_cfg.py:121
static const char *const kHelpOpt
Definition: CmsShowMain.cc:93
static PluginManager * get()