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