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 
ConfigurationDescriptions.h
edmplugin
Definition: AlignmentAlgorithmPluginFactory.cc:9
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
taus_updatedMVAIds_cff.category
category
Definition: taus_updatedMVAIds_cff.py:31
PrintLoadingPlugins::operator=
const PrintLoadingPlugins & operator=(const PrintLoadingPlugins &)=delete
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
PrintLoadingPlugins
Definition: PrintLoadingPlugins.cc:32
edmplugin::PluginManager::get
static PluginManager * get()
Definition: PluginManager.cc:306
edmplugin::PluginManager::categoryToInfos
const CategoryToInfos & categoryToInfos() const
Definition: PluginManager.h:82
edmplugin::PluginManager
Definition: PluginManager.h:45
PrintLoadingPluginsMaker
edm::serviceregistry::NoArgsMaker< PrintLoadingPlugins > PrintLoadingPluginsMaker
Definition: PrintLoadingPlugins.cc:156
edmplugin::PluginManager::goingToLoad_
edm::signalslot::Signal< void(const std::filesystem::path &)> goingToLoad_
Definition: PluginManager.h:100
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:68
PrintLoadingPlugins::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: PrintLoadingPlugins.cc:85
PrintLoadingPlugins::goingToLoad
void goingToLoad(const std::filesystem::path &)
Definition: PrintLoadingPlugins.cc:142
DEFINE_FWK_SERVICE_MAKER
#define DEFINE_FWK_SERVICE_MAKER(concrete, maker)
Definition: ServiceMaker.h:100
PrintLoadingPlugins::~PrintLoadingPlugins
virtual ~PrintLoadingPlugins()
Definition: PrintLoadingPlugins.cc:83
ParameterSetDescription.h
edmplugin::PluginInfo::name_
std::string name_
Definition: PluginInfo.h:29
ServiceMaker.h
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
edm::ConfigurationDescriptions::setComment
void setComment(std::string const &value)
Definition: ConfigurationDescriptions.cc:48
edm::serviceregistry::NoArgsMaker
Definition: ServiceMaker.h:61
edm::LogAbsolute
Log< level::System, true > LogAbsolute
Definition: MessageLogger.h:134
Signal.h
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edmplugin::PluginManager::askedToLoadCategoryWithPlugin_
edm::signalslot::Signal< void(const std::string &, const std::string &)> askedToLoadCategoryWithPlugin_
Definition: PluginManager.h:102
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
PluginManager.h
edm::signalslot::Signal::connect
void connect(U iFunc)
Definition: Signal.h:64
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:113
edmplugin::PluginInfo
Definition: PluginInfo.h:28