LSSTApplications  20.0.0
LSSTDataManagementBasePackage
library.cc
Go to the documentation of this file.
1 #include "lsst/base/library.h"
2 
3 namespace lsst {
4 namespace base {
5 
6 namespace {
7 
9 bool endsWith(std::string const& str, std::string const& end)
10 {
11  return str.size() >= end.size() && str.compare(str.size() - end.size(), end.size(), end) == 0;
12 }
13 
14 } // anonymous namespace
15 
16 
18 {
19 #ifdef __APPLE__
20  return ".dylib";
21 #else
22  return ".so";
23 #endif
24 }
25 
26 
28 {
29  if (endsWith(name, ".so") || endsWith(name, ".dylib")) {
30  // User asked for a library with a certain extension, so give it to them
31  return name;
32  }
33  return name + libraryExtension();
34 }
35 
36 
37 bool canLoadLibrary(std::string const& libName)
38 {
39  return dlopen(getLibraryFilename(libName).c_str(), RTLD_LAZY | RTLD_GLOBAL);
40 }
41 
42 
43 }} // lsst::base
std::string
STL class.
lsst::base::getLibraryFilename
std::string getLibraryFilename(std::string const &name)
Get filename for library.
Definition: library.cc:27
base
Definition: __init__.py:1
std::string::size
T size(T... args)
lsst::afw::geom.transform.transformContinued.name
string name
Definition: transformContinued.py:32
end
int end
Definition: BoundedField.cc:105
lsst::base::libraryExtension
std::string libraryExtension()
Return filename extension for libraries.
Definition: library.cc:17
std::string::compare
T compare(T... args)
library.h
lsst
A base class for image defects.
Definition: imageAlgorithm.dox:1
lsst::base::canLoadLibrary
bool canLoadLibrary(std::string const &libName)
Return whether we can load a library.
Definition: library.cc:37