CMS 3D CMS Logo

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
21 
22 namespace edmplugin {
23  //
24  // constants, enums and typedefs
25  //
26 
27  //
28  // static data member definitions
29  //
30 
31  //
32  // constructors and destructor
33  //
35 
36  // PluginCapabilities::PluginCapabilities(const PluginCapabilities& rhs)
37  // {
38  // // do actual copying here;
39  // }
40 
42 
43  //
44  // assignment operators
45  //
46  // const PluginCapabilities& PluginCapabilities::operator=(const PluginCapabilities& rhs)
47  // {
48  // //An exception safe implementation is
49  // PluginCapabilities temp(rhs);
50  // swap(rhs);
51  //
52  // return *this;
53  // }
54 
55  //
56  // member functions
57  //
59  void* sym;
60  if (not iLoadable.symbol("SEAL_CAPABILITIES", sym)) {
61  return false;
62  }
63 
64  const char** names;
65  int size;
66  //reinterpret_cast<void (*)(const char**&,int&)>(sym)(names,size);
67  reinterpret_cast<void (*)(const char**&, int&)>(reinterpret_cast<unsigned long>(sym))(names, size);
68 
70  for (int i = 0; i < size; ++i) {
72  classToLoadable_[name] = iLoadable.path();
73 
74  //NOTE: can't use newPlugin(name) to do the work since it assumes
75  // we haven't yet returned from PluginManager::load method
76  info.name_ = name;
77  info.loadable_ = iLoadable.path();
78  this->newPluginAdded_(category(), info);
79  }
80  return true;
81  }
82 
84  if (classToLoadable_.end() == classToLoadable_.find(iName)) {
85  const SharedLibrary& lib = PluginManager::get()->load(category(), iName);
86  //read the items from the 'capabilities' symbol
87  if (not tryToFind(lib)) {
88  throw cms::Exception("PluginNotFound")
89  << "The dictionary for class '" << iName << "' is supposed to be in file\n '" << lib.path().string()
90  << "'\n but no dictionaries are in that file.\n"
91  "It appears like the cache is wrong. Please do 'EdmPluginRefresh "
92  << lib.path().string() << "'.";
93  }
94 
95  if (classToLoadable_.end() == classToLoadable_.find(iName)) {
96  throw cms::Exception("PluginNotFound")
97  << "The dictionary for class '" << iName << "' is supposed to be in file\n '" << lib.path().string()
98  << "'\n but was not found.\n"
99  "It appears like the cache is wrong. Please do 'EdmPluginRefresh "
100  << lib.path().string() << "'.";
101  }
102  }
103  }
104 
106  if (classToLoadable_.end() == classToLoadable_.find(iName)) {
107  const SharedLibrary* lib = PluginManager::get()->tryToLoad(category(), iName);
108  if (nullptr == lib) {
109  return false;
110  }
111  //read the items from the 'capabilities' symbol
112  if (not tryToFind(*lib)) {
113  throw cms::Exception("PluginNotFound")
114  << "The dictionary for class '" << iName << "' is supposed to be in file\n '" << lib->path().string()
115  << "'\n but no dictionaries are in that file.\n"
116  "It appears like the cache is wrong. Please do 'EdmPluginRefresh "
117  << lib->path().string() << "'.";
118  }
119 
120  if (classToLoadable_.end() == classToLoadable_.find(iName)) {
121  throw cms::Exception("PluginNotFound")
122  << "The dictionary for class '" << iName << "' is supposed to be in file\n '" << lib->path().string()
123  << "'\n but was not found.\n"
124  "It appears like the cache is wrong. Please do 'EdmPluginRefresh "
125  << lib->path().string() << "'.";
126  }
127  }
128  return true;
129  }
130  //
131  // const member functions
132  //
133  std::vector<PluginInfo> PluginCapabilities::available() const {
135  std::vector<PluginInfo> infos;
136  infos.reserve(classToLoadable_.size());
137 
138  for (std::map<std::string, boost::filesystem::path>::const_iterator it = classToLoadable_.begin();
139  it != classToLoadable_.end();
140  ++it) {
141  info.name_ = it->first;
142  info.loadable_ = it->second;
143  infos.push_back(info);
144  }
145  return infos;
146  }
147 
149  static const std::string s_cat("Capability");
150  return s_cat;
151  }
152 
153  //
154  // static member functions
155  //
157  CMS_THREAD_SAFE static PluginCapabilities s_instance;
158  return &s_instance;
159  }
160 
161 } // namespace edmplugin
edmplugin
Definition: AlignmentAlgorithmPluginFactory.cc:9
mps_fire.i
i
Definition: mps_fire.py:355
edmplugin::PluginCapabilities::get
static PluginCapabilities * get()
Definition: PluginCapabilities.cc:156
edmplugin::PluginManager::load
const SharedLibrary & load(const std::string &iCategory, const std::string &iPlugin)
Definition: PluginManager.cc:227
edmplugin::PluginCapabilities::~PluginCapabilities
~PluginCapabilities() override
Definition: PluginCapabilities.cc:41
PluginCapabilities.h
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:152
SharedLibrary.h
edmplugin::SharedLibrary::path
const boost::filesystem::path & path() const
Definition: SharedLibrary.h:36
edmplugin::PluginManager::get
static PluginManager * get()
Definition: PluginManager.cc:307
edmplugin::PluginCapabilities::PluginCapabilities
PluginCapabilities()
Definition: PluginCapabilities.cc:34
names
const std::string names[nVars_]
Definition: PhotonIDValueMapProducer.cc:122
CMS_THREAD_SAFE
#define CMS_THREAD_SAFE
Definition: thread_safety_macros.h:4
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edmplugin::PluginCapabilities::category
const std::string & category() const override
returns the name of the category to which this plugin factory belongs
Definition: PluginCapabilities.cc:148
edmplugin::PluginFactoryBase::newPluginAdded_
edm::signalslot::Signal< void(const std::string &, const PluginInfo &)> newPluginAdded_
signal containing plugin category, and plugin info for newly added plugin
Definition: PluginFactoryBase.h:75
edmplugin::PluginCapabilities::available
std::vector< PluginInfo > available() const override
return info about all plugins which are already available in the program
Definition: PluginCapabilities.cc:133
edmplugin::PluginCapabilities
Definition: PluginCapabilities.h:32
MessageLogger_cfi.infos
infos
Definition: MessageLogger_cfi.py:67
thread_safety_macros.h
edmplugin::PluginCapabilities::tryToLoad
bool tryToLoad(const std::string &iName)
Definition: PluginCapabilities.cc:105
mps_check.lib
lib
Definition: mps_check.py:21
PluginManager.h
edmplugin::PluginCapabilities::classToLoadable_
std::map< std::string, boost::filesystem::path > classToLoadable_
Definition: PluginCapabilities.h:61
Exception
Definition: hltDiff.cc:246
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
Exception.h
edmplugin::PluginFactoryBase::finishedConstruction
void finishedConstruction()
Definition: PluginFactoryBase.cc:56
edmplugin::PluginCapabilities::tryToFind
bool tryToFind(const SharedLibrary &iLoadable)
Check to see if any capabilities are in the file, returns 'true' if found.
Definition: PluginCapabilities.cc:58
edmplugin::SharedLibrary
Definition: SharedLibrary.h:29
edmplugin::PluginInfo
Definition: PluginInfo.h:28
edmplugin::PluginCapabilities::load
void load(const std::string &iName)
Definition: PluginCapabilities.cc:83
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
edmplugin::PluginManager::tryToLoad
const SharedLibrary * tryToLoad(const std::string &iCategory, const std::string &iPlugin)
Definition: PluginManager.cc:263
edmplugin::SharedLibrary::symbol
bool symbol(const std::string &iSymbolName, void *&iSymbol) const
Definition: SharedLibrary.cc:71