CMS 3D CMS Logo

PrintLoadingPlugins.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Services
4 // Class : PrintLoadingPlugins
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author:
10 // Created: Thu Dec 13 15:00:49 EST 2007
11 //
12 
13 // system include files
14 
15 // user include files
17 
23 
25 
26 #include <algorithm>
27 #include <functional>
28 #include <iostream>
29 #include <string>
30 #include <map>
31 
33 public:
35  virtual ~PrintLoadingPlugins();
36 
38 
39  void askedToLoad(const std::string&, const std::string&);
40 
41  // ---------- const member functions ---------------------
42 
43  // ---------- static member functions --------------------
44  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
45 
46  // ---------- member functions ---------------------------
47 
48 private:
49  PrintLoadingPlugins(const PrintLoadingPlugins&) = delete; // stop default
50 
51  const PrintLoadingPlugins& operator=(const PrintLoadingPlugins&) = delete; // stop default
52 
53  // ---------- member data --------------------------------
54 };
55 
56 //
57 // constants, enums and typedefs
58 //
59 
60 //
61 // static data member definitions
62 //
63 
64 //
65 // constructors and destructor
66 //
67 using namespace edmplugin;
68 
70  using std::placeholders::_1;
71  using std::placeholders::_2;
73 
74  pm->askedToLoadCategoryWithPlugin_.connect(std::bind(std::mem_fn(&PrintLoadingPlugins::askedToLoad), this, _1, _2));
75 
76  pm->goingToLoad_.connect(std::bind(std::mem_fn(&PrintLoadingPlugins::goingToLoad), this, _1));
77 }
78 
79 // PrintLoadingPlugins::PrintLoadingPlugins(const PrintLoadingPlugins& rhs)
80 // {
81 // // do actual copying here;
82 // }
83 
85 
88  descriptions.add("PrintLoadingPlugins", desc);
89  descriptions.setComment("This service logs each request to load a plugin.");
90 }
91 
92 //
93 // assignment operators
94 //
95 // const PrintLoadingPlugins& PrintLoadingPlugins::operator=(const PrintLoadingPlugins& rhs)
96 // {
97 // //An exception safe implementation is
98 // PrintLoadingPlugins temp(rhs);
99 // swap(rhs);
100 //
101 // return *this;
102 // }
103 
104 //
105 // member functions
106 //
107 
108 namespace {
109  struct PICompare {
110  bool operator()(const PluginInfo& iLHS, const PluginInfo& iRHS) const { return iLHS.name_ < iRHS.name_; }
111  };
112 } // namespace
113 
114 void PrintLoadingPlugins::askedToLoad(const std::string& iCategory, const std::string& iPlugin) {
116 
118 
119  PluginManager::CategoryToInfos::const_iterator itFound = category.find(iCategory);
120 
121  std::string libname("Not found");
122 
123  if (itFound != category.end()) {
124  PluginInfo i;
125 
126  i.name_ = iPlugin;
127 
128  typedef std::vector<PluginInfo>::const_iterator PIItr;
129 
130  std::pair<PIItr, PIItr> range = std::equal_range(itFound->second.begin(), itFound->second.end(), i, PICompare());
131 
132  if (range.second - range.first > 1) {
133  const boost::filesystem::path& loadable = range.first->loadable_;
134 
135  libname = loadable.string();
136  }
137 
138  edm::LogAbsolute("GetPlugin") << "Getting> '" << iCategory << "' " << iPlugin << "\n from " << libname
139  << std::endl;
140  }
141 }
142 
144 
145 {
146  edm::LogAbsolute("LoadLib") << "Loading> " << Loadable_.string() << std::endl;
147 }
148 
149 //
150 // const member functions
151 //
152 
153 //
154 // static member functions
155 //
156 
ConfigurationDescriptions.h
edmplugin
Definition: AlignmentAlgorithmPluginFactory.cc:9
edm::LogAbsolute
Definition: MessageLogger.h:469
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
taus_updatedMVAIds_cff.category
category
Definition: taus_updatedMVAIds_cff.py:30
PrintLoadingPlugins::operator=
const PrintLoadingPlugins & operator=(const PrintLoadingPlugins &)=delete
mps_fire.i
i
Definition: mps_fire.py:355
MessageLogger.h
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
PrintLoadingPlugins
Definition: PrintLoadingPlugins.cc:32
edmplugin::PluginManager::get
static PluginManager * get()
Definition: PluginManager.cc:307
edmplugin::PluginManager::categoryToInfos
const CategoryToInfos & categoryToInfos() const
Definition: PluginManager.h:80
edmplugin::PluginManager
Definition: PluginManager.h:45
PrintLoadingPluginsMaker
edm::serviceregistry::NoArgsMaker< PrintLoadingPlugins > PrintLoadingPluginsMaker
Definition: PrintLoadingPlugins.cc:157
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
edmplugin::PluginManager::CategoryToInfos
std::map< std::string, Infos > CategoryToInfos
Definition: PluginManager.h:51
PluginInfo.h
PrintLoadingPlugins::PrintLoadingPlugins
PrintLoadingPlugins()
Definition: PrintLoadingPlugins.cc:69
PrintLoadingPlugins::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: PrintLoadingPlugins.cc:86
DEFINE_FWK_SERVICE_MAKER
#define DEFINE_FWK_SERVICE_MAKER(concrete, maker)
Definition: ServiceMaker.h:109
PrintLoadingPlugins::~PrintLoadingPlugins
virtual ~PrintLoadingPlugins()
Definition: PrintLoadingPlugins.cc:84
ParameterSetDescription.h
edmplugin::PluginInfo::name_
std::string name_
Definition: PluginInfo.h:29
ServiceMaker.h
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ConfigurationDescriptions::setComment
void setComment(std::string const &value)
Definition: ConfigurationDescriptions.cc:48
edm::serviceregistry::NoArgsMaker
Definition: ServiceMaker.h:61
Signal.h
edmplugin::PluginManager::askedToLoadCategoryWithPlugin_
edm::signalslot::Signal< void(const std::string &, const std::string &)> askedToLoadCategoryWithPlugin_
Definition: PluginManager.h:100
PluginManager.h
edm::signalslot::Signal::connect
void connect(U iFunc)
Definition: Signal.h:62
castor_dqm_sourceclient_file_cfg.path
path
Definition: castor_dqm_sourceclient_file_cfg.py:37
PrintLoadingPlugins::askedToLoad
void askedToLoad(const std::string &, const std::string &)
Definition: PrintLoadingPlugins.cc:114
edmplugin::PluginManager::goingToLoad_
edm::signalslot::Signal< void(const boost::filesystem::path &)> goingToLoad_
Definition: PluginManager.h:98
edmplugin::PluginInfo
Definition: PluginInfo.h:28
PrintLoadingPlugins::goingToLoad
void goingToLoad(const boost::filesystem::path &)
Definition: PrintLoadingPlugins.cc:143