CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SharedLibrary.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: PluginManager
4 // Class : SharedLibrary
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: Chris Jones
10 // Created: Thu Apr 5 15:30:15 EDT 2007
11 //
12 
13 // system include files
14 #include <string> /*needed by the following include*/
15 #include <dlfcn.h>
16 #include <errno.h>
17 
18 // user include files
21 
22 namespace edmplugin {
23 //
24 // constants, enums and typedefs
25 //
26 
27 //
28 // static data member definitions
29 //
30 
31 //
32 // constructors and destructor
33 //
35  libraryHandle_(::dlopen(iName.string().c_str(), RTLD_LAZY | RTLD_GLOBAL)),
36  path_(iName)
37 {
38  if(libraryHandle_ == nullptr) {
39  char const* err = dlerror();
40  if(err == nullptr) {
41  throw cms::Exception("PluginLibraryLoadError") << "unable to load " << iName.string();
42  }
43  throw cms::Exception("PluginLibraryLoadError") << "unable to load " << iName.string() << " because " << err;
44  }
45 }
46 
47 // SharedLibrary::SharedLibrary(const SharedLibrary& rhs)
48 // {
49 // // do actual copying here;
50 // }
51 
53 {
54 }
55 
56 //
57 // assignment operators
58 //
59 // const SharedLibrary& SharedLibrary::operator=(const SharedLibrary& rhs)
60 // {
61 // //An exception safe implementation is
62 // SharedLibrary temp(rhs);
63 // swap(rhs);
64 //
65 // return *this;
66 // }
67 
68 //
69 // member functions
70 //
71 
72 //
73 // const member functions
74 //
75 bool
76 SharedLibrary::symbol(const std::string& iSymbolName, void*& iSymbol) const
77 {
78  if(libraryHandle_ == nullptr) {
79  return false;
80  }
81  iSymbol = dlsym(libraryHandle_, iSymbolName.c_str());
82  return (iSymbol != nullptr);
83 }
84 
85 //
86 // static member functions
87 //
88 }
bool symbol(const std::string &iSymbolName, void *&iSymbol) const
std::string & path_
SharedLibrary(const boost::filesystem::path &iName)