forked from opentracing/opentracing-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dynamic_load.cpp
57 lines (50 loc) · 1.92 KB
/
dynamic_load.cpp
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
#include <dlfcn.h>
#include <opentracing/dynamic_load.h>
#include <opentracing/version.h>
namespace opentracing {
BEGIN_OPENTRACING_ABI_NAMESPACE
namespace {
class DynamicLoadErrorCategory : public std::error_category {
public:
DynamicLoadErrorCategory() {}
const char* name() const noexcept override {
return "OpenTracingDynamicLoadError";
}
std::error_condition default_error_condition(int code) const
noexcept override {
if (code == dynamic_load_failure_error.value()) {
return std::make_error_condition(std::errc::no_such_file_or_directory);
}
if (code == dynamic_load_not_supported_error.value()) {
return std::make_error_condition(std::errc::not_supported);
}
if (code == incompatible_library_versions_error.value()) {
return std::make_error_condition(std::errc::invalid_argument);
}
return std::error_condition(code, *this);
}
std::string message(int code) const override {
if (code == dynamic_load_failure_error.value()) {
return "opentracing: failed to load dynamic library";
}
if (code == dynamic_load_not_supported_error.value()) {
return "opentracing: dynamic library loading is not supported";
}
if (code == incompatible_library_versions_error.value()) {
return "opentracing: versions of opentracing libraries are incompatible";
}
return "opentracing: unknown dynamic load error";
}
};
} // anonymous namespace
const std::error_category& dynamic_load_error_category() {
static const DynamicLoadErrorCategory error_category;
return error_category;
}
DynamicTracingLibraryHandle::DynamicTracingLibraryHandle(
std::unique_ptr<const TracerFactory>&& tracer_factory,
std::unique_ptr<DynamicLibraryHandle>&& dynamic_library_handle) noexcept
: dynamic_library_handle_{std::move(dynamic_library_handle)},
tracer_factory_{std::move(tracer_factory)} {}
END_OPENTRACING_ABI_NAMESPACE
} // namespace opentracing