CMS 3D CMS Logo

Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions

edmplugin::PluginFactoryBase Class Reference

#include <PluginFactoryBase.h>

Inheritance diagram for edmplugin::PluginFactoryBase:
edmplugin::PluginCapabilities edmplugin::PluginFactory< R *(Arg)> edmplugin::PluginFactory< R *(Arg1, Arg2)> edmplugin::PluginFactory< R *(void)>

List of all members.

Public Types

typedef std::map< std::string,
PMakers
Plugins
typedef std::vector< std::pair
< void *, std::string > > 
PMakers

Public Member Functions

virtual std::vector< PluginInfoavailable () 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

sigc::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 PluginFactoryBaseoperator= (const PluginFactoryBase &)
 PluginFactoryBase (const PluginFactoryBase &)

Detailed Description

Definition at line 33 of file PluginFactoryBase.h.


Member Typedef Documentation

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.


Constructor & Destructor Documentation

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]

Member Function Documentation

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]
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).native_file_string() ) {
      throw cms::Exception("WrongPluginLoaded")<<"The plugin '"<<iName<<"' should have been loaded from\n '"
      <<PluginManager::get()->loadableFor(category(),iName).native_file_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(), and m_plugins.

Referenced by edmplugin::PluginFactory< R *(Arg1, Arg2)>::create(), edmplugin::PluginFactory< R *(Arg)>::create(), and edmplugin::PluginFactory< R *(void)>::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().native_file_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]
const PluginFactoryBase& edmplugin::PluginFactoryBase::operator= ( const PluginFactoryBase ) [private]
void PluginFactoryBase::registerPMaker ( void *  iPMaker,
const std::string &  iName 
) [protected]
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, and edmplugin::SharedLibrary::path().

Referenced by edmplugin::PluginFactory< R *(Arg)>::tryToCreate(), edmplugin::PluginFactory< R *(Arg1, Arg2)>::tryToCreate(), and edmplugin::PluginFactory< R *(void)>::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().native_file_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;
}

Member Data Documentation

sigc::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().