CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
22 
23 #include "boost/bind.hpp"
24 #include "boost/mem_fn.hpp"
26 
27 #include <algorithm>
28 #include <iostream>
29 #include <string>
30 #include <map>
31 
32 //
33 // constants, enums and typedefs
34 //
35 
36 //
37 // static data member definitions
38 //
39 
40 //
41 // constructors and destructor
42 //
43 using namespace edmplugin;
44 
46 {
48 
49  pm->askedToLoadCategoryWithPlugin_.connect(boost::bind(boost::mem_fn(&PrintLoadingPlugins::askedToLoad),this, _1,_2));
50 
51  pm->goingToLoad_.connect(boost::bind(boost::mem_fn(&PrintLoadingPlugins::goingToLoad),this, _1));
52 
53 
54 
55 }
56 
57 // PrintLoadingPlugins::PrintLoadingPlugins(const PrintLoadingPlugins& rhs)
58 // {
59 // // do actual copying here;
60 // }
61 
63 {
64 }
65 
68  descriptions.add("PrintLoadingPlugins", desc);
69  descriptions.setComment("This service logs each request to load a plugin.");
70 }
71 
72 //
73 // assignment operators
74 //
75 // const PrintLoadingPlugins& PrintLoadingPlugins::operator=(const PrintLoadingPlugins& rhs)
76 // {
77 // //An exception safe implementation is
78 // PrintLoadingPlugins temp(rhs);
79 // swap(rhs);
80 //
81 // return *this;
82 // }
83 
84 //
85 // member functions
86 //
87 
88  namespace{
89  struct PICompare {
90  bool operator()(const PluginInfo& iLHS,
91  const PluginInfo& iRHS) const {
92  return iLHS.name_ < iRHS.name_;
93  }
94  };
95  }
96 
98  const std::string& iPlugin)
99 {
101 
103 
104  PluginManager::CategoryToInfos::const_iterator itFound = category.find(iCategory);
105 
106  std::string libname("Not found");
107 
108  if(itFound != category.end()) {
109 
110  PluginInfo i;
111 
112  i.name_ = iPlugin;
113 
114  typedef std::vector<PluginInfo>::const_iterator PIItr;
115 
116  std::pair<PIItr,PIItr> range = std::equal_range(itFound->second.begin(),itFound->second.end(),i,PICompare());
117 
118  if(range.second - range.first > 1){
119 
120  const boost::filesystem::path& loadable = range.first->loadable_;
121 
122  libname = loadable.string();
123 
124  }
125 
126  edm::LogAbsolute("GetPlugin")<<"Getting> '"<<iCategory<< "' "<<iPlugin
127  <<"\n from "<<libname <<std::endl;
128  }
129 
130 }
131 
133 
134 {
135  edm::LogAbsolute("LoadLib")<<"Loading> "<<Loadable_.string()<< std::endl;
136 }
137 
138 
139 //
140 // const member functions
141 //
142 
143 //
144 // static member functions
145 //
const CategoryToInfos & categoryToInfos() const
Definition: PluginManager.h:82
int i
Definition: DBlmapReader.cc:9
void askedToLoad(const std::string &, const std::string &)
std::map< std::string, Infos > CategoryToInfos
Definition: PluginManager.h:54
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)
static PluginManager * get()
void connect(U iFunc)
Definition: Signal.h:63