CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PluginCapabilities.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: PluginManager
4 // Class : PluginCapabilities
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: Chris Jones
10 // Created: Fri Apr 6 12:36:24 EDT 2007
11 //
12 
13 // system include files
14 
15 // user include files
20 
21 namespace edmplugin {
22 //
23 // constants, enums and typedefs
24 //
25 
26 //
27 // static data member definitions
28 //
29 
30 //
31 // constructors and destructor
32 //
34 {
36 }
37 
38 // PluginCapabilities::PluginCapabilities(const PluginCapabilities& rhs)
39 // {
40 // // do actual copying here;
41 // }
42 
44 {
45 }
46 
47 //
48 // assignment operators
49 //
50 // const PluginCapabilities& PluginCapabilities::operator=(const PluginCapabilities& rhs)
51 // {
52 // //An exception safe implementation is
53 // PluginCapabilities temp(rhs);
54 // swap(rhs);
55 //
56 // return *this;
57 // }
58 
59 //
60 // member functions
61 //
62 bool
64 {
65  void* sym;
66  if( not iLoadable.symbol("SEAL_CAPABILITIES",sym) ) {
67  return false;
68  }
69 
70  const char** names;
71  int size;
72  //reinterpret_cast<void (*)(const char**&,int&)>(sym)(names,size);
73  reinterpret_cast<void (*)(const char**&,int&)>(reinterpret_cast<unsigned long>(sym))(names,size);
74 
76  for(int i=0; i < size; ++i) {
77  std::string name(names[i]);
78  classToLoadable_[name]=iLoadable.path();
79 
80  //NOTE: can't use newPlugin(name) to do the work since it assumes
81  // we haven't yet returned from PluginManager::load method
82  info.name_ = name;
83  info.loadable_ = iLoadable.path();
84  this->newPluginAdded_(category(),info);
85  }
86  return true;
87 }
88 
89 void
91 {
92  if(classToLoadable_.end() == classToLoadable_.find(iName) ) {
94  iName);
95  //read the items from the 'capabilities' symbol
96  if(not tryToFind(lib) ) {
97  throw cms::Exception("PluginNotFound")<<"The dictionary for class '"<<iName <<"' is supposed to be in file\n '"
98  <<lib.path().string()<<"'\n but no dictionaries are in that file.\n"
99  "It appears like the cache is wrong. Please do 'EdmPluginRefresh "<<lib.path().string()<<"'.";
100  }
101 
102  if(classToLoadable_.end() == classToLoadable_.find(iName)) {
103  throw cms::Exception("PluginNotFound")<<"The dictionary for class '"<<iName<<"' is supposed to be in file\n '"
104  <<lib.path().string()<<"'\n but was not found.\n"
105  "It appears like the cache is wrong. Please do 'EdmPluginRefresh "<<lib.path().string()<<"'.";
106  }
107  }
108 }
109 
110 bool
112 {
113  if(classToLoadable_.end() == classToLoadable_.find(iName) ) {
115  iName);
116  if( 0 == lib) {
117  return false;
118  }
119  //read the items from the 'capabilities' symbol
120  if(not tryToFind(*lib) ) {
121  throw cms::Exception("PluginNotFound")<<"The dictionary for class '"<<iName <<"' is supposed to be in file\n '"
122  <<lib->path().string()<<"'\n but no dictionaries are in that file.\n"
123  "It appears like the cache is wrong. Please do 'EdmPluginRefresh "<<lib->path().string()<<"'.";
124  }
125 
126  if(classToLoadable_.end() == classToLoadable_.find(iName)) {
127  throw cms::Exception("PluginNotFound")<<"The dictionary for class '"<<iName<<"' is supposed to be in file\n '"
128  <<lib->path().string()<<"'\n but was not found.\n"
129  "It appears like the cache is wrong. Please do 'EdmPluginRefresh "<<lib->path().string()<<"'.";
130  }
131  }
132  return true;
133 }
134 //
135 // const member functions
136 //
137 std::vector<PluginInfo>
139 {
141  std::vector<PluginInfo> infos;
142  infos.reserve(classToLoadable_.size());
143 
144  for(std::map<std::string, boost::filesystem::path>::const_iterator it = classToLoadable_.begin();
145  it != classToLoadable_.end();
146  ++it) {
147  info.name_ = it->first;
148  info.loadable_ = it->second;
149  infos.push_back(info);
150  }
151  return infos;
152 }
153 
154 const std::string&
156 {
157  static const std::string s_cat("Capability");
158  return s_cat;
159 }
160 
161 //
162 // static member functions
163 //
166  [[cms::thread_safe]] static PluginCapabilities s_instance;
167  return &s_instance;
168 }
169 
170 }
bool symbol(const std::string &iSymbolName, void *&iSymbol) const
int i
Definition: DBlmapReader.cc:9
static const TGPicture * info(bool iBackgroundIsBlack)
const SharedLibrary * tryToLoad(const std::string &iCategory, const std::string &iPlugin)
static const HistoName names[]
bool tryToFind(const SharedLibrary &iLoadable)
Check to see if any capabilities are in the file, returns &#39;true&#39; if found.
virtual const std::string & category() const
returns the name of the category to which this plugin factory belongs
edm::signalslot::Signal< void(const std::string &, const PluginInfo &)> newPluginAdded_
signal containing plugin category, and plugin info for newly added plugin
virtual std::vector< PluginInfo > available() const
return info about all plugins which are already available in the program
static PluginCapabilities * get()
bool tryToLoad(const std::string &iName)
std::map< std::string, boost::filesystem::path > classToLoadable_
std::string name_
Definition: PluginInfo.h:29
void load(const std::string &iName)
boost::filesystem::path loadable_
Definition: PluginInfo.h:30
const SharedLibrary & load(const std::string &iCategory, const std::string &iPlugin)
const boost::filesystem::path & path() const
Definition: SharedLibrary.h:38
static PluginManager * get()
tuple size
Write out results.