#include <PluginFactoryBase.h>
Public Types | |
typedef std::map< std::string, PMakers > | Plugins |
typedef std::vector< std::pair < void *, std::string > > | PMakers |
Public Member Functions | |
virtual std::vector< PluginInfo > | available () const |
return info about all plugins which are already available in the program | |
virtual const std::string & | category () const =0 |
returns the name of the category to which this plugin factory belongs | |
PluginFactoryBase () | |
virtual | ~PluginFactoryBase () |
Public Attributes | |
edm::signalslot::Signal< void(const std::string &, const PluginInfo &)> | newPluginAdded_ |
signal containing plugin category, and plugin info for newly added plugin | |
Protected Member Functions | |
void | fillAvailable (std::vector< PluginInfo > &iReturn) const |
void | fillInfo (const PMakers &makers, PluginInfo &iInfo, std::vector< PluginInfo > &iReturn) const |
Plugins::const_iterator | findPMaker (const std::string &iName) const |
void | finishedConstruction () |
void | newPlugin (const std::string &iName) |
void | registerPMaker (void *iPMaker, const std::string &iName) |
Plugins::const_iterator | tryToFindPMaker (const std::string &iName) const |
Protected Attributes | |
Plugins | m_plugins |
Private Member Functions | |
void | checkProperLoadable (const std::string &iName, const std::string &iLoadedFrom) const |
const PluginFactoryBase & | operator= (const PluginFactoryBase &) |
PluginFactoryBase (const PluginFactoryBase &) |
Definition at line 33 of file PluginFactoryBase.h.
typedef std::map<std::string, PMakers > edmplugin::PluginFactoryBase::Plugins |
Definition at line 41 of file PluginFactoryBase.h.
typedef std::vector<std::pair<void*, std::string> > edmplugin::PluginFactoryBase::PMakers |
Definition at line 40 of file PluginFactoryBase.h.
edmplugin::PluginFactoryBase::PluginFactoryBase | ( | ) | [inline] |
Definition at line 37 of file PluginFactoryBase.h.
{}
PluginFactoryBase::~PluginFactoryBase | ( | ) | [virtual] |
Definition at line 41 of file PluginFactoryBase.cc.
{ }
edmplugin::PluginFactoryBase::PluginFactoryBase | ( | const PluginFactoryBase & | ) | [private] |
std::vector< PluginInfo > PluginFactoryBase::available | ( | ) | const [virtual] |
return info about all plugins which are already available in the program
Reimplemented in edmplugin::PluginCapabilities.
Definition at line 165 of file PluginFactoryBase.cc.
References fillAvailable(), and m_plugins.
{ std::vector<PluginInfo> returnValue; returnValue.reserve(m_plugins.size()); fillAvailable(returnValue); return returnValue; }
virtual const std::string& edmplugin::PluginFactoryBase::category | ( | ) | const [pure virtual] |
returns the name of the category to which this plugin factory belongs
Implemented in edmplugin::PluginCapabilities, and edmplugin::PluginFactory< R *(Args...)>.
Referenced by checkProperLoadable(), findPMaker(), newPlugin(), and tryToFindPMaker().
void PluginFactoryBase::checkProperLoadable | ( | const std::string & | iName, |
const std::string & | iLoadedFrom | ||
) | const [private] |
Definition at line 141 of file PluginFactoryBase.cc.
References category(), Exception, edmplugin::PluginManager::get(), reco::get(), edmplugin::PluginManager::isAvailable(), and edmplugin::PluginManager::staticallyLinkedLoadingFileName().
Referenced by findPMaker(), and tryToFindPMaker().
{ //should check to see if this is from the proper loadable if it // was not statically linked if (iLoadedFrom != PluginManager::staticallyLinkedLoadingFileName() && PluginManager::isAvailable()) { if( iLoadedFrom != PluginManager::get()->loadableFor(category(),iName).string() ) { throw cms::Exception("WrongPluginLoaded")<<"The plugin '"<<iName<<"' should have been loaded from\n '" <<PluginManager::get()->loadableFor(category(),iName).string() <<"'\n but instead it was already loaded from\n '" <<iLoadedFrom<<"'\n because some other plugin was loaded from the latter loadables.\n" "To work around the problem the plugin '"<<iName<<"' should only be defined in one of these loadables."; } } }
void PluginFactoryBase::fillAvailable | ( | std::vector< PluginInfo > & | iReturn | ) | const [protected] |
Definition at line 129 of file PluginFactoryBase.cc.
References fillInfo(), info, m_plugins, and edmplugin::PluginInfo::name_.
Referenced by available().
{ PluginInfo info; for( Plugins::const_iterator it = m_plugins.begin(); it != m_plugins.end(); ++it) { info.name_ = it->first; fillInfo(it->second, info, iReturn); } }
void PluginFactoryBase::fillInfo | ( | const PMakers & | makers, |
PluginInfo & | iInfo, | ||
std::vector< PluginInfo > & | iReturn | ||
) | const [protected] |
Definition at line 117 of file PluginFactoryBase.cc.
References edmplugin::PluginInfo::loadable_.
Referenced by fillAvailable().
{
for(PMakers::const_iterator it = makers.begin();
it != makers.end();
++it) {
iInfo.loadable_ = it->second;
iReturn.push_back(iInfo);
}
}
PluginFactoryBase::Plugins::const_iterator PluginFactoryBase::findPMaker | ( | const std::string & | iName | ) | const [protected] |
Definition at line 77 of file PluginFactoryBase.cc.
References category(), checkProperLoadable(), Exception, reco::get(), m_plugins, and AlCaHLTBitMon_QueryRunRegistry::string.
Referenced by edmplugin::PluginFactory< R *(Args...)>::create().
{ //do we already have it? Plugins::const_iterator itFound = m_plugins.find(iName); if(itFound == m_plugins.end()) { std::string lib = PluginManager::get()->load(this->category(),iName).path().string(); itFound = m_plugins.find(iName); if(itFound == m_plugins.end()) { throw cms::Exception("PluginCacheError")<<"The plugin '"<<iName<<"' should have been in loadable\n '" <<lib<<"'\n but was not there. This means the plugin cache is incorrect. Please run 'EdmPluginRefresh "<<lib<<"'"; } } else { checkProperLoadable(iName,itFound->second.front().second); } return itFound; }
void PluginFactoryBase::finishedConstruction | ( | ) | [protected] |
call this as the last line in the constructor of inheriting classes this is done so that the virtual table will be properly initialized when the routine is called
Definition at line 61 of file PluginFactoryBase.cc.
References reco::get().
Referenced by edmplugin::PluginCapabilities::PluginCapabilities().
{ PluginFactoryManager::get()->addFactory(this); }
void PluginFactoryBase::newPlugin | ( | const std::string & | iName | ) | [protected] |
Definition at line 67 of file PluginFactoryBase.cc.
References category(), info, edmplugin::PluginInfo::loadable_, edmplugin::PluginManager::loadingFile(), edmplugin::PluginInfo::name_, newPluginAdded_, and getHLTPrescaleColumns::path.
Referenced by registerPMaker().
{ PluginInfo info; info.loadable_=boost::filesystem::path(PluginManager::loadingFile()); info.name_=iName; newPluginAdded_(category(),info); }
const PluginFactoryBase& edmplugin::PluginFactoryBase::operator= | ( | const PluginFactoryBase & | ) | [private] |
void PluginFactoryBase::registerPMaker | ( | void * | iPMaker, |
const std::string & | iName | ||
) | [protected] |
Definition at line 159 of file PluginFactoryBase.cc.
References edmplugin::PluginManager::loadingFile(), m_plugins, and newPlugin().
Referenced by edmplugin::PluginFactory< R *(Args...)>::registerPMaker().
{ m_plugins[iName].push_back(std::pair<void*,std::string>(iPMaker,PluginManager::loadingFile())); newPlugin(iName); }
PluginFactoryBase::Plugins::const_iterator PluginFactoryBase::tryToFindPMaker | ( | const std::string & | iName | ) | const [protected] |
Definition at line 96 of file PluginFactoryBase.cc.
References category(), checkProperLoadable(), Exception, reco::get(), m_plugins, edmplugin::SharedLibrary::path(), and AlCaHLTBitMon_QueryRunRegistry::string.
Referenced by edmplugin::PluginFactory< R *(Args...)>::tryToCreate().
{ //do we already have it? Plugins::const_iterator itFound = m_plugins.find(iName); if(itFound == m_plugins.end()) { const SharedLibrary* slib = PluginManager::get()->tryToLoad(this->category(),iName); if(0!=slib) { std::string lib = slib->path().string(); itFound = m_plugins.find(iName); if(itFound == m_plugins.end()) { throw cms::Exception("PluginCacheError")<<"The plugin '"<<iName<<"' should have been in loadable\n '" <<lib<<"'\n but was not there. This means the plugin cache is incorrect. Please run 'EdmPluginRefresh "<<lib<<"'"; } } } else { checkProperLoadable(iName,itFound->second.front().second); } return itFound; }
Plugins edmplugin::PluginFactoryBase::m_plugins [protected] |
Definition at line 83 of file PluginFactoryBase.h.
Referenced by available(), fillAvailable(), findPMaker(), registerPMaker(), and tryToFindPMaker().
edm::signalslot::Signal<void(const std::string&, const PluginInfo&)> edmplugin::PluginFactoryBase::newPluginAdded_ [mutable] |
signal containing plugin category, and plugin info for newly added plugin
Definition at line 52 of file PluginFactoryBase.h.
Referenced by newPlugin(), and edmplugin::PluginCapabilities::tryToFind().