Static Public Member Functions |
Private Types |
Static Private Member Functions |
Static Private Attributes |
Friends
AnalysisLoader Class Reference Internal class which loads and registers analyses from plugin libs. More...
Collaboration diagram for AnalysisLoader:
![]()
Detailed DescriptionInternal class which loads and registers analyses from plugin libs. Definition at line 19 of file AnalysisLoader.hh. Member Typedef Documentation
Definition at line 46 of file AnalysisLoader.hh. Member Function Documentation
Load the available analyses at runtime.
Definition at line 72 of file AnalysisLoader.cc. References AnalysisLoader::_ptrs, Rivet::getAnalysisLibPaths(), MSG_TRACE, and MSG_WARNING. Referenced by AnalysisLoader::analysisNames(), AnalysisLoader::getAllAnalyses(), and AnalysisLoader::getAnalysis(). { // Only run once if (!_ptrs.empty()) return; // Build the list of directories to search const vector<string> dirs = getAnalysisLibPaths(); // Find plugin module library files const string libsuffix = ".so"; vector<string> pluginfiles; foreach (const string& d, dirs) { if (d.empty()) continue; oslink::directory dir(d); while (dir) { string filename = dir.next(); // Require that plugin lib name starts with 'Rivet' if (filename.find("Rivet") != 0) continue; size_t posn = filename.find(libsuffix); if (posn == string::npos || posn != filename.length()-libsuffix.length()) continue; /// @todo Make sure this is an abs path /// @todo Sys-dependent path separator instead of "/" const string path = d + "/" + filename; // Ensure no duplicate paths if (find(pluginfiles.begin(), pluginfiles.end(), path) == pluginfiles.end()) { pluginfiles += path; } } } // Load the plugin files MSG_TRACE("Candidate analysis plugin libs: " << pluginfiles); foreach (const string& pf, pluginfiles) { MSG_TRACE("Trying to load plugin analyses from file " << pf); void* handle = dlopen(pf.c_str(), RTLD_LAZY); if (!handle) { MSG_WARNING("Cannot open " << pf << ": " << dlerror()); continue; } } }
Register a new analysis builder. Definition at line 58 of file AnalysisLoader.cc. References AnalysisLoader::_ptrs, MSG_TRACE, and MSG_WARNING. { if (!ab) return; const string name = ab->name(); if (_ptrs.find(name) != _ptrs.end()) { // Duplicate analyses will be ignored... loudly //cerr << "Ignoring duplicate plugin analysis called '" << name << "'" << endl; MSG_WARNING("Ignoring duplicate plugin analysis called '" << name << "'"); } else { MSG_TRACE("Registering a plugin analysis called '" << name << "'"); _ptrs[name] = ab; } }
Get all the available analyses' names. Definition at line 22 of file AnalysisLoader.cc. References AnalysisLoader::_loadAnalysisPlugins(), and AnalysisLoader::_ptrs. Referenced by AnalysisLoader::getAllAnalysisNames(). { _loadAnalysisPlugins(); vector<string> names; foreach (const AnalysisBuilderMap::value_type& p, _ptrs) names += p.first; return names; }
Get all the available analyses. Definition at line 48 of file AnalysisLoader.cc. References AnalysisLoader::_loadAnalysisPlugins(), and AnalysisLoader::_ptrs. { _loadAnalysisPlugins(); vector<Analysis*> analyses; foreach (const AnalysisBuilderMap::value_type& p, _ptrs) { analyses += p.second->mkAnalysis(); } return analyses; }
Definition at line 30 of file AnalysisLoader.cc. References AnalysisLoader::analysisNames(). { set<string> anaset; vector<string> anas = analysisNames(); foreach (const string &ana, anas) { anaset.insert(ana); } return anaset; }
Get an analysis by name. Warning: a name arg which matches no known analysis will return a null pointer. Check your return values before using them! Definition at line 40 of file AnalysisLoader.cc. References AnalysisLoader::_loadAnalysisPlugins(), and AnalysisLoader::_ptrs. Referenced by AnalysisHandler::addAnalysis(). { _loadAnalysisPlugins(); AnalysisBuilderMap::const_iterator ai = _ptrs.find(analysisname); if (ai == _ptrs.end()) return 0; return ai->second->mkAnalysis(); } Friends And Related Function Documentation
Allow the analysis builders to call the private _registerBuilder function. Definition at line 38 of file AnalysisLoader.hh. Member Data Documentation
Definition at line 47 of file AnalysisLoader.hh. Referenced by AnalysisLoader::_loadAnalysisPlugins(), AnalysisLoader::_registerBuilder(), AnalysisLoader::analysisNames(), AnalysisLoader::getAllAnalyses(), and AnalysisLoader::getAnalysis(). The documentation for this class was generated from the following files: Generated on Wed Oct 7 2015 12:09:26 for The Rivet MC analysis system by ![]() |