CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Friends
edmplugin::PluginCapabilities Class Reference

#include <PluginCapabilities.h>

Inheritance diagram for edmplugin::PluginCapabilities:
edmplugin::PluginFactoryBase

Public Member Functions

std::vector< PluginInfoavailable () const override
 return info about all plugins which are already available in the program More...
 
const std::string & category () const override
 returns the name of the category to which this plugin factory belongs More...
 
void load (const std::string &iName)
 
const PluginCapabilitiesoperator= (const PluginCapabilities &)=delete
 
 PluginCapabilities (const PluginCapabilities &)=delete
 
bool tryToFind (const SharedLibrary &iLoadable)
 Check to see if any capabilities are in the file, returns 'true' if found. More...
 
bool tryToLoad (const std::string &iName)
 
 ~PluginCapabilities () override
 
- Public Member Functions inherited from edmplugin::PluginFactoryBase
const PluginFactoryBaseoperator= (const PluginFactoryBase &)=delete
 
 PluginFactoryBase ()
 
 PluginFactoryBase (const PluginFactoryBase &)=delete
 
virtual ~PluginFactoryBase ()
 

Static Public Member Functions

static PluginCapabilitiesget ()
 

Private Member Functions

 PluginCapabilities ()
 

Private Attributes

std::map< std::string, std::filesystem::path > classToLoadable_
 

Friends

class DummyFriend
 

Additional Inherited Members

- Public Types inherited from edmplugin::PluginFactoryBase
typedef tbb::concurrent_unordered_map< std::string, PMakersPlugins
 
typedef tbb::concurrent_vector< PluginMakerInfo, edm::zero_allocator< PluginMakerInfo > > PMakers
 
- Public Attributes inherited from edmplugin::PluginFactoryBase
edm::signalslot::Signal< void(const std::string &, const PluginInfo &)> newPluginAdded_
 signal containing plugin category, and plugin info for newly added plugin More...
 
- Protected Member Functions inherited from edmplugin::PluginFactoryBase
void fillAvailable (std::vector< PluginInfo > &iReturn) const
 
void fillInfo (const PMakers &makers, PluginInfo &iInfo, std::vector< PluginInfo > &iReturn) const
 
void * findPMaker (const std::string &iName) const
 
void finishedConstruction ()
 
void newPlugin (const std::string &iName)
 
void registerPMaker (void *iPMaker, const std::string &iName)
 
void * tryToFindPMaker (const std::string &iName) const
 

Detailed Description

Definition at line 32 of file PluginCapabilities.h.

Constructor & Destructor Documentation

◆ PluginCapabilities() [1/2]

edmplugin::PluginCapabilities::PluginCapabilities ( const PluginCapabilities )
delete

◆ ~PluginCapabilities()

PluginCapabilities::~PluginCapabilities ( )
override

Definition at line 41 of file PluginCapabilities.cc.

41 {}

◆ PluginCapabilities() [2/2]

PluginCapabilities::PluginCapabilities ( )
private

Member Function Documentation

◆ available()

std::vector< PluginInfo > PluginCapabilities::available ( ) const
overridevirtual

return info about all plugins which are already available in the program

Reimplemented from edmplugin::PluginFactoryBase.

Definition at line 133 of file PluginCapabilities.cc.

133  {
135  std::vector<PluginInfo> infos;
136  infos.reserve(classToLoadable_.size());
137 
138  for (std::map<std::string, std::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  }

References classToLoadable_, info(), and submitPVValidationJobs::infos.

◆ category()

const std::string & PluginCapabilities::category ( ) const
overridevirtual

returns the name of the category to which this plugin factory belongs

Implements edmplugin::PluginFactoryBase.

Definition at line 148 of file PluginCapabilities.cc.

148  {
149  static const std::string s_cat("Capability");
150  return s_cat;
151  }

References AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by load(), tryToFind(), and tryToLoad().

◆ get()

PluginCapabilities * PluginCapabilities::get ( )
static

◆ load()

void PluginCapabilities::load ( const std::string &  iName)

Definition at line 83 of file PluginCapabilities.cc.

83  {
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  }

References category(), classToLoadable_, Exception, edmplugin::PluginManager::get(), mps_check::lib, edmplugin::PluginManager::load(), and tryToFind().

Referenced by edm::service::LoadAllDictionaries::LoadAllDictionaries().

◆ operator=()

const PluginCapabilities& edmplugin::PluginCapabilities::operator= ( const PluginCapabilities )
delete

◆ tryToFind()

bool PluginCapabilities::tryToFind ( const SharedLibrary iLoadable)

Check to see if any capabilities are in the file, returns 'true' if found.

Definition at line 58 of file PluginCapabilities.cc.

58  {
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  }

References category(), classToLoadable_, mps_fire::i, info(), Skims_PA_cff::name, names, edmplugin::PluginFactoryBase::newPluginAdded_, edmplugin::SharedLibrary::path(), findQualityFiles::size, AlCaHLTBitMon_QueryRunRegistry::string, and edmplugin::SharedLibrary::symbol().

Referenced by load(), main(), and tryToLoad().

◆ tryToLoad()

bool PluginCapabilities::tryToLoad ( const std::string &  iName)

Definition at line 105 of file PluginCapabilities.cc.

105  {
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  }

References category(), classToLoadable_, Exception, edmplugin::PluginManager::get(), mps_check::lib, tryToFind(), and edmplugin::PluginManager::tryToLoad().

Friends And Related Function Documentation

◆ DummyFriend

friend class DummyFriend
friend

Definition at line 33 of file PluginCapabilities.h.

Member Data Documentation

◆ classToLoadable_

std::map<std::string, std::filesystem::path> edmplugin::PluginCapabilities::classToLoadable_
private

Definition at line 60 of file PluginCapabilities.h.

Referenced by available(), load(), tryToFind(), and tryToLoad().

mps_fire.i
i
Definition: mps_fire.py:428
edmplugin::PluginManager::load
const SharedLibrary & load(const std::string &iCategory, const std::string &iPlugin)
Definition: PluginManager.cc:226
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:153
edmplugin::PluginManager::get
static PluginManager * get()
Definition: PluginManager.cc:306
names
const std::string names[nVars_]
Definition: PhotonIDValueMapProducer.cc:124
CMS_THREAD_SAFE
#define CMS_THREAD_SAFE
Definition: thread_safety_macros.h:4
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:77
edmplugin::PluginCapabilities::classToLoadable_
std::map< std::string, std::filesystem::path > classToLoadable_
Definition: PluginCapabilities.h:60
mps_check.lib
lib
Definition: mps_check.py:21
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
PluginCapabilities
SharedLibrary
Exception
Definition: hltDiff.cc:245
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
edmplugin::PluginFactoryBase::finishedConstruction
void finishedConstruction()
Definition: PluginFactoryBase.cc:57
PluginInfo
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
submitPVValidationJobs.infos
dictionary infos
Definition: submitPVValidationJobs.py:221
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:262