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 {
34 
35 public:
37  virtual ~PrintLoadingPlugins();
38 
40 
41  void askedToLoad(const std::string& ,const std::string& );
42 
43  // ---------- const member functions ---------------------
44 
45  // ---------- static member functions --------------------
46  static void fillDescriptions(edm::ConfigurationDescriptions & descriptions);
47 
48  // ---------- member functions ---------------------------
49 
50 private:
51 
52  PrintLoadingPlugins(const PrintLoadingPlugins&) = delete; // stop default
53 
54  const PrintLoadingPlugins& operator=(const PrintLoadingPlugins&) = delete; // stop default
55 
56  // ---------- member data --------------------------------
57 
58 };
59 
60 //
61 // constants, enums and typedefs
62 //
63 
64 //
65 // static data member definitions
66 //
67 
68 //
69 // constructors and destructor
70 //
71 using namespace edmplugin;
72 
74 {
75  using std::placeholders::_1;
76  using std::placeholders::_2;
78 
79  pm->askedToLoadCategoryWithPlugin_.connect(std::bind(std::mem_fn(&PrintLoadingPlugins::askedToLoad),this, _1,_2));
80 
81  pm->goingToLoad_.connect(std::bind(std::mem_fn(&PrintLoadingPlugins::goingToLoad),this, _1));
82 
83 
84 
85 }
86 
87 // PrintLoadingPlugins::PrintLoadingPlugins(const PrintLoadingPlugins& rhs)
88 // {
89 // // do actual copying here;
90 // }
91 
93 {
94 }
95 
98  descriptions.add("PrintLoadingPlugins", desc);
99  descriptions.setComment("This service logs each request to load a plugin.");
100 }
101 
102 //
103 // assignment operators
104 //
105 // const PrintLoadingPlugins& PrintLoadingPlugins::operator=(const PrintLoadingPlugins& rhs)
106 // {
107 // //An exception safe implementation is
108 // PrintLoadingPlugins temp(rhs);
109 // swap(rhs);
110 //
111 // return *this;
112 // }
113 
114 //
115 // member functions
116 //
117 
118  namespace{
119  struct PICompare {
120  bool operator()(const PluginInfo& iLHS,
121  const PluginInfo& iRHS) const {
122  return iLHS.name_ < iRHS.name_;
123  }
124  };
125  }
126 
128  const std::string& iPlugin)
129 {
131 
132  const PluginManager::CategoryToInfos& category = pm->categoryToInfos();
133 
134  PluginManager::CategoryToInfos::const_iterator itFound = category.find(iCategory);
135 
136  std::string libname("Not found");
137 
138  if(itFound != category.end()) {
139 
140  PluginInfo i;
141 
142  i.name_ = iPlugin;
143 
144  typedef std::vector<PluginInfo>::const_iterator PIItr;
145 
146  std::pair<PIItr,PIItr> range = std::equal_range(itFound->second.begin(),itFound->second.end(),i,PICompare());
147 
148  if(range.second - range.first > 1){
149 
150  const boost::filesystem::path& loadable = range.first->loadable_;
151 
152  libname = loadable.string();
153 
154  }
155 
156  edm::LogAbsolute("GetPlugin")<<"Getting> '"<<iCategory<< "' "<<iPlugin
157  <<"\n from "<<libname <<std::endl;
158  }
159 
160 }
161 
163 
164 {
165  edm::LogAbsolute("LoadLib")<<"Loading> "<<Loadable_.string()<< std::endl;
166 }
167 
168 
169 //
170 // const member functions
171 //
172 
173 //
174 // static member functions
175 //
176 
179 
const CategoryToInfos & categoryToInfos() const
Definition: PluginManager.h:82
#define DEFINE_FWK_SERVICE_MAKER(concrete, maker)
Definition: ServiceMaker.h:117
edm::serviceregistry::NoArgsMaker< PrintLoadingPlugins > PrintLoadingPluginsMaker
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 &)
edm::signalslot::Signal< void(const std::string &, const std::string &)> askedToLoadCategoryWithPlugin_
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:64
T get(const Candidate &c)
Definition: component.h:55