CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions
edmplugin::PluginFactoryBase Class Referenceabstract

#include <PluginFactoryBase.h>

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

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 More...
 
virtual const std::string & category () const =0
 returns the name of the category to which this plugin factory belongs More...
 
 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 More...
 

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.

37 {}
PluginFactoryBase::~PluginFactoryBase ( )
virtual

Definition at line 41 of file PluginFactoryBase.cc.

42 {
43 }
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.

165  {
166  std::vector<PluginInfo> returnValue;
167  returnValue.reserve(m_plugins.size());
168  fillAvailable(returnValue);
169  return returnValue;
170 }
void fillAvailable(std::vector< PluginInfo > &iReturn) const
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(), edm::hlt::Exception, edmplugin::PluginManager::get(), edmplugin::PluginManager::isAvailable(), edmplugin::PluginManager::loadableFor(), and edmplugin::PluginManager::staticallyLinkedLoadingFileName().

Referenced by findPMaker(), and tryToFindPMaker().

142 {
143  //should check to see if this is from the proper loadable if it
144  // was not statically linked
145  if (iLoadedFrom != PluginManager::staticallyLinkedLoadingFileName() &&
147  if( iLoadedFrom != PluginManager::get()->loadableFor(category(),iName).string() ) {
148  throw cms::Exception("WrongPluginLoaded")<<"The plugin '"<<iName<<"' should have been loaded from\n '"
149  <<PluginManager::get()->loadableFor(category(),iName).string()
150  <<"'\n but instead it was already loaded from\n '"
151  <<iLoadedFrom<<"'\n because some other plugin was loaded from the latter loadables.\n"
152  "To work around the problem the plugin '"<<iName<<"' should only be defined in one of these loadables.";
153  }
154  }
155 }
const boost::filesystem::path & loadableFor(const std::string &iCategory, const std::string &iPlugin)
static const std::string & staticallyLinkedLoadingFileName()
if the value returned from loadingFile matches this string then the file is statically linked ...
virtual const std::string & category() const =0
returns the name of the category to which this plugin factory belongs
static PluginManager * get()
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().

129  {
131  for( Plugins::const_iterator it = m_plugins.begin();
132  it != m_plugins.end();
133  ++it) {
134  info.name_ = it->first;
135  fillInfo(it->second,
136  info, iReturn);
137  }
138 }
void fillInfo(const PMakers &makers, PluginInfo &iInfo, std::vector< PluginInfo > &iReturn) const
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().

119  {
120  for(PMakers::const_iterator it = makers.begin();
121  it != makers.end();
122  ++it) {
123  iInfo.loadable_ = it->second;
124  iReturn.push_back(iInfo);
125  }
126 }
PluginFactoryBase::Plugins::const_iterator PluginFactoryBase::findPMaker ( const std::string &  iName) const
protected

Definition at line 77 of file PluginFactoryBase.cc.

References category(), checkProperLoadable(), edm::hlt::Exception, edmplugin::PluginManager::get(), edmplugin::PluginManager::load(), m_plugins, and edmplugin::SharedLibrary::path().

Referenced by edmplugin::PluginFactory< R *(void)>::create(), edmplugin::PluginFactory< R *(Arg)>::create(), and edmplugin::PluginFactory< R *(Arg1, Arg2)>::create().

78 {
79  //do we already have it?
80  Plugins::const_iterator itFound = m_plugins.find(iName);
81  if(itFound == m_plugins.end()) {
82  std::string lib = PluginManager::get()->load(this->category(),iName).path().string();
83  itFound = m_plugins.find(iName);
84  if(itFound == m_plugins.end()) {
85  throw cms::Exception("PluginCacheError")<<"The plugin '"<<iName<<"' should have been in loadable\n '"
86  <<lib<<"'\n but was not there. This means the plugin cache is incorrect. Please run 'EdmPluginRefresh "<<lib<<"'";
87  }
88  } else {
89  checkProperLoadable(iName,itFound->second.front().second);
90  }
91  return itFound;
92 }
void checkProperLoadable(const std::string &iName, const std::string &iLoadedFrom) const
virtual const std::string & category() const =0
returns the name of the category to which this plugin factory belongs
const SharedLibrary & load(const std::string &iCategory, const std::string &iPlugin)
const boost::filesystem::path & path() const
Definition: SharedLibrary.h:40
static PluginManager * get()
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 edmplugin::PluginFactoryManager::addFactory(), and edmplugin::PluginFactoryManager::get().

Referenced by edmplugin::PluginCapabilities::PluginCapabilities().

62 {
64 }
void addFactory(const PluginFactoryBase *)
static PluginFactoryManager * get()
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 scaleCards::path.

Referenced by registerPMaker().

68 {
71  info.name_=iName;
72  newPluginAdded_(category(),info);
73 }
list path
Definition: scaleCards.py:51
static const std::string & loadingFile()
file name of the shared object being loaded
Definition: PluginManager.h:81
sigc::signal< void, const std::string &, const PluginInfo & > newPluginAdded_
signal containing plugin category, and plugin info for newly added plugin
virtual const std::string & category() const =0
returns the name of the category to which this plugin factory belongs
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 *(void)>::registerPMaker(), edmplugin::PluginFactory< R *(Arg)>::registerPMaker(), and edmplugin::PluginFactory< R *(Arg1, Arg2)>::registerPMaker().

159  {
160  m_plugins[iName].push_back(std::pair<void*,std::string>(iPMaker,PluginManager::loadingFile()));
161  newPlugin(iName);
162 }
static const std::string & loadingFile()
file name of the shared object being loaded
Definition: PluginManager.h:81
void newPlugin(const std::string &iName)
PluginFactoryBase::Plugins::const_iterator PluginFactoryBase::tryToFindPMaker ( const std::string &  iName) const
protected

Definition at line 96 of file PluginFactoryBase.cc.

References category(), checkProperLoadable(), edm::hlt::Exception, edmplugin::PluginManager::get(), m_plugins, edmplugin::SharedLibrary::path(), and edmplugin::PluginManager::tryToLoad().

Referenced by edmplugin::PluginFactory< R *(void)>::tryToCreate(), edmplugin::PluginFactory< R *(Arg)>::tryToCreate(), and edmplugin::PluginFactory< R *(Arg1, Arg2)>::tryToCreate().

97 {
98  //do we already have it?
99  Plugins::const_iterator itFound = m_plugins.find(iName);
100  if(itFound == m_plugins.end()) {
101  const SharedLibrary* slib = PluginManager::get()->tryToLoad(this->category(),iName);
102  if(0!=slib) {
103  std::string lib = slib->path().string();
104  itFound = m_plugins.find(iName);
105  if(itFound == m_plugins.end()) {
106  throw cms::Exception("PluginCacheError")<<"The plugin '"<<iName<<"' should have been in loadable\n '"
107  <<lib<<"'\n but was not there. This means the plugin cache is incorrect. Please run 'EdmPluginRefresh "<<lib<<"'";
108  }
109  }
110  } else {
111  checkProperLoadable(iName,itFound->second.front().second);
112  }
113  return itFound;
114 }
const SharedLibrary * tryToLoad(const std::string &iCategory, const std::string &iPlugin)
void checkProperLoadable(const std::string &iName, const std::string &iLoadedFrom) const
virtual const std::string & category() const =0
returns the name of the category to which this plugin factory belongs
static PluginManager * get()

Member Data Documentation

Plugins edmplugin::PluginFactoryBase::m_plugins
protected
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().