File indexing completed on 2024-04-06 12:12:59
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #include <string> /*needed by the following include*/
0015 #include <dlfcn.h>
0016 #include <cerrno>
0017
0018
0019 #include "FWCore/PluginManager/interface/SharedLibrary.h"
0020 #include "FWCore/Utilities/interface/Exception.h"
0021
0022 namespace edmplugin {
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 SharedLibrary::SharedLibrary(const std::filesystem::path& iName)
0035 : libraryHandle_(::dlopen(iName.string().c_str(), RTLD_LAZY | RTLD_GLOBAL)), path_(iName) {
0036 if (libraryHandle_ == nullptr) {
0037 char const* err = dlerror();
0038 if (err == nullptr) {
0039 throw cms::Exception("PluginLibraryLoadError") << "unable to load " << iName.string();
0040 }
0041 throw cms::Exception("PluginLibraryLoadError") << "unable to load " << iName.string() << " because " << err;
0042 }
0043 }
0044
0045
0046
0047
0048
0049
0050 SharedLibrary::~SharedLibrary() {}
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071 bool SharedLibrary::symbol(const std::string& iSymbolName, void*& iSymbol) const {
0072 if (libraryHandle_ == nullptr) {
0073 return false;
0074 }
0075 iSymbol = dlsym(libraryHandle_, iSymbolName.c_str());
0076 return (iSymbol != nullptr);
0077 }
0078
0079
0080
0081
0082 }