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