CMS 3D CMS Logo

edmplugin::PluginCapabilities Class Reference

#include <FWCore/PluginManager/interface/PluginCapabilities.h>

Inheritance diagram for edmplugin::PluginCapabilities:

edmplugin::PluginFactoryBase

List of all members.

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
 returns the name of the category to which this plugin factory belongs
void load (const std::string &iName)
bool tryToFind (const SharedLibrary &iLoadable)
 Check to see if any capabilities are in the file, returns 'true' if found.
bool tryToLoad (const std::string &iName)
virtual ~PluginCapabilities ()

Static Public Member Functions

static PluginCapabilitiesget ()

Private Member Functions

const PluginCapabilitiesoperator= (const PluginCapabilities &)
 PluginCapabilities (const PluginCapabilities &)
 PluginCapabilities ()

Private Attributes

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

Friends

class DummyFriend


Detailed Description

Definition at line 33 of file PluginCapabilities.h.


Constructor & Destructor Documentation

PluginCapabilities::~PluginCapabilities (  )  [virtual]

Definition at line 44 of file PluginCapabilities.cc.

00045 {
00046 }

PluginCapabilities::PluginCapabilities (  )  [private]

Definition at line 34 of file PluginCapabilities.cc.

00035 {
00036   finishedConstruction();
00037 }

edmplugin::PluginCapabilities::PluginCapabilities ( const PluginCapabilities  )  [private]


Member Function Documentation

std::vector< PluginInfo > PluginCapabilities::available (  )  const [virtual]

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

Implements edmplugin::PluginFactoryBase.

Definition at line 139 of file PluginCapabilities.cc.

References info, HLT_VtxMuL3::infos, it, edmplugin::PluginInfo::loadable_, and edmplugin::PluginInfo::name_.

00140 {
00141   PluginInfo info;
00142   std::vector<PluginInfo> infos;
00143   infos.reserve(classToLoadable_.size());
00144   
00145   for(std::map<std::string, boost::filesystem::path>::const_iterator it = classToLoadable_.begin();
00146       it != classToLoadable_.end();
00147       ++it) {
00148     info.name_ = it->first;
00149     info.loadable_ = it->second;
00150     infos.push_back(info);
00151   }
00152   return infos;
00153 }

const std::string & PluginCapabilities::category (  )  const [virtual]

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

Implements edmplugin::PluginFactoryBase.

Definition at line 156 of file PluginCapabilities.cc.

00157 {
00158   static const std::string s_cat("Capability");
00159   return s_cat;
00160 }

PluginCapabilities * PluginCapabilities::get ( void   )  [static]

Definition at line 166 of file PluginCapabilities.cc.

References s_instance.

Referenced by edm::RootAutoLibraryLoader::loadAll(), edm::service::LoadAllDictionaries::LoadAllDictionaries(), edm::loadCap(), edm::loadLibraryForClass(), and edm::registerTypes().

00166                         {
00167   static PluginCapabilities s_instance;
00168   return &s_instance;
00169 }

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

Definition at line 91 of file PluginCapabilities.cc.

References category, Exception, DBSPlugin::get(), and edmplugin::SharedLibrary::path().

00092 {
00093   if(classToLoadable_.end() == classToLoadable_.find(iName) ) {
00094     const SharedLibrary& lib = PluginManager::get()->load(category(),
00095                                                           iName);
00096     //read the items from the 'capabilities' symbol
00097     if(not tryToFind(lib) ) {
00098       throw cms::Exception("PluginNotFound")<<"The dictionary for class '"<<iName <<"' is supposed to be in file\n '"
00099       <<lib.path().native_file_string()<<"'\n but no dictionaries are in that file.\n"
00100       "It appears like the cache is wrong.  Please do 'EdmPluginRefresh "<<lib.path().native_file_string()<<"'.";
00101     }
00102     
00103     if(classToLoadable_.end() == classToLoadable_.find(iName)) {
00104       throw cms::Exception("PluginNotFound")<<"The dictionary for class '"<<iName<<"' is supposed to be in file\n '"
00105       <<lib.path().native_file_string()<<"'\n but was not found.\n"
00106       "It appears like the cache is wrong.  Please do 'EdmPluginRefresh "<<lib.path().native_file_string()<<"'.";
00107     }
00108   }
00109 }

const PluginCapabilities& edmplugin::PluginCapabilities::operator= ( const PluginCapabilities  )  [private]

bool PluginCapabilities::tryToFind ( const SharedLibrary iLoadable  ) 

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

Definition at line 64 of file PluginCapabilities.cc.

References category, i, info, edmplugin::PluginInfo::loadable_, name, edmplugin::PluginInfo::name_, names, edmplugin::SharedLibrary::path(), size, edmplugin::SharedLibrary::symbol(), and void.

00065 {
00066   void* sym;
00067   if( not iLoadable.symbol("SEAL_CAPABILITIES",sym) ) {
00068     return false;
00069   }
00070   
00071   const char** names;
00072   int size;
00073   //reinterpret_cast<void (*)(const char**&,int&)>(sym)(names,size);
00074   ((void (*)(const char**&,int&))(sym))(names,size);
00075 
00076   PluginInfo info;
00077   for(int i=0; i < size; ++i) {
00078     std::string name(names[i]);
00079     classToLoadable_[name]=iLoadable.path();
00080     
00081     //NOTE: can't use newPlugin(name) to do the work since it assumes
00082     //  we haven't yet returned from PluginManager::load method
00083     info.name_ = name;
00084     info.loadable_ = iLoadable.path();
00085     this->newPluginAdded_(category(),info);
00086   }
00087   return true;
00088 }

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

Definition at line 112 of file PluginCapabilities.cc.

References category, Exception, DBSPlugin::get(), and edmplugin::SharedLibrary::path().

00113 {
00114   if(classToLoadable_.end() == classToLoadable_.find(iName) ) {
00115     const SharedLibrary* lib = PluginManager::get()->tryToLoad(category(),
00116                                                           iName);
00117     if( 0 == lib) {
00118       return false;
00119     }
00120     //read the items from the 'capabilities' symbol
00121     if(not tryToFind(*lib) ) {
00122       throw cms::Exception("PluginNotFound")<<"The dictionary for class '"<<iName <<"' is supposed to be in file\n '"
00123       <<lib->path().native_file_string()<<"'\n but no dictionaries are in that file.\n"
00124       "It appears like the cache is wrong.  Please do 'EdmPluginRefresh "<<lib->path().native_file_string()<<"'.";
00125     }
00126     
00127     if(classToLoadable_.end() == classToLoadable_.find(iName)) {
00128       throw cms::Exception("PluginNotFound")<<"The dictionary for class '"<<iName<<"' is supposed to be in file\n '"
00129       <<lib->path().native_file_string()<<"'\n but was not found.\n"
00130       "It appears like the cache is wrong.  Please do 'EdmPluginRefresh "<<lib->path().native_file_string()<<"'.";
00131     }
00132   }
00133   return true;
00134 }


Friends And Related Function Documentation

friend class DummyFriend [friend]

Definition at line 35 of file PluginCapabilities.h.


Member Data Documentation

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

Definition at line 62 of file PluginCapabilities.h.


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:46:41 2009 for CMSSW by  doxygen 1.5.4