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