forked from cms-patatrack/pixeltrack-standalone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SharedLibrary.cc
82 lines (71 loc) · 1.71 KB
/
SharedLibrary.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// -*- C++ -*-
//
// Package: PluginManager
// Class : SharedLibrary
//
// Implementation:
// <Notes on implementation>
//
// Original Author: Chris Jones
// Created: Thu Apr 5 15:30:15 EDT 2007
//
// system include files
#include <string> /*needed by the following include*/
#include <dlfcn.h>
#include <cerrno>
#include <stdexcept>
// user include files
#include "SharedLibrary.h"
namespace edmplugin {
//
// constants, enums and typedefs
//
//
// static data member definitions
//
//
// constructors and destructor
//
SharedLibrary::SharedLibrary(const std::string& iName)
: libraryHandle_(::dlopen(iName.c_str(), RTLD_LAZY | RTLD_GLOBAL)), path_(iName) {
if (libraryHandle_ == nullptr) {
char const* err = dlerror();
if (err == nullptr) {
throw std::runtime_error("unable to load " + iName);
}
throw std::runtime_error("unable to load " + iName + " because " + err);
}
}
// SharedLibrary::SharedLibrary(const SharedLibrary& rhs)
// {
// // do actual copying here;
// }
SharedLibrary::~SharedLibrary() {}
//
// assignment operators
//
// const SharedLibrary& SharedLibrary::operator=(const SharedLibrary& rhs)
// {
// //An exception safe implementation is
// SharedLibrary temp(rhs);
// swap(rhs);
//
// return *this;
// }
//
// member functions
//
//
// const member functions
//
bool SharedLibrary::symbol(const std::string& iSymbolName, void*& iSymbol) const {
if (libraryHandle_ == nullptr) {
return false;
}
iSymbol = dlsym(libraryHandle_, iSymbolName.c_str());
return (iSymbol != nullptr);
}
//
// static member functions
//
} // namespace edmplugin