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...
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 83 of file AnalysisLoader.cc. { // 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. { 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; } const string aname = ab->alias(); if (!aname.empty()) { //MSG_WARNING("ALIAS!!! " << aname); if (_ptrs.find(aname) != _ptrs.end()) { MSG_WARNING("Ignoring duplicate plugin analysis alias '" << aname << "'"); } else { MSG_TRACE("Registering a plugin analysis via alias '" << aname << "'"); _ptrs[aname] = ab; } } }
Get all the available analyses' names. Definition at line 22 of file AnalysisLoader.cc. { _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. { _loadAnalysisPlugins(); vector<unique_ptr<Analysis>> analyses; foreach (const auto & p, _ptrs) { analyses.emplace_back( p.second->mkAnalysis() ); } return analyses; }
Definition at line 30 of file AnalysisLoader.cc. { 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. { _loadAnalysisPlugins(); AnalysisBuilderMap::const_iterator ai = _ptrs.find(analysisname); if (ai == _ptrs.end()) return nullptr; 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. The documentation for this class was generated from the following files: Generated on Tue Dec 13 2016 16:32:46 for The Rivet MC analysis system by ![]() |