test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
dump.cc
Go to the documentation of this file.
1 //<<<<<< INCLUDES >>>>>>
2 
3 
4 #include <iostream>
5 #include <utility>
6 #include <cstdlib>
7 #include <string>
8 #include <set>
9 #include <boost/program_options.hpp>
10 
13 
14 
15 using namespace edmplugin;
16 
17 
18 int main (int argc, char **argv)
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
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:82
static PluginManager & configure(const Config &)
PluginManager::Config config()
Definition: standard.cc:21
std::map< std::string, Infos > CategoryToInfos
Definition: PluginManager.h:54
static const char *const kHelpCommandOpt
Definition: CmsShowMain.cc:98
tuple argc
Definition: dir2webdir.py:38
tuple cout
Definition: gather_cfg.py:145
static const char *const kHelpOpt
Definition: CmsShowMain.cc:97
static PluginManager * get()