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 
117  const PluginManager::CategoryToInfos& category = pm->categoryToInfos();
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 
const CategoryToInfos & categoryToInfos() const
Definition: PluginManager.h:83
#define DEFINE_FWK_SERVICE_MAKER(concrete, maker)
Definition: ServiceMaker.h:109
edm::serviceregistry::NoArgsMaker< PrintLoadingPlugins > PrintLoadingPluginsMaker
edm::signalslot::Signal< void(const std::string &, const std::string &)> askedToLoadCategoryWithPlugin_
void askedToLoad(const std::string &, const std::string &)
const PrintLoadingPlugins & operator=(const PrintLoadingPlugins &)=delete
void setComment(std::string const &value)
void goingToLoad(const boost::filesystem::path &)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
edm::signalslot::Signal< void(const boost::filesystem::path &)> goingToLoad_
std::string name_
Definition: PluginInfo.h:29
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void connect(U iFunc)
Definition: Signal.h:62