FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
BehaviorTree.CPP/src/shared_library_UNIX.cpp at master · BehaviorTree/BehaviorTree.CPP · GitHub
BehaviorTree
/
BehaviorTree.CPP
Public
Notifications
You must be signed in to change notification settings
Fork
857
Star
4.2k
Code
Issues
33
Pull requests
21
Discussions
Actions
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
BehaviorTree.CPP
/
src
/
shared_library_UNIX.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
103 lines (88 loc) · 1.89 KB
Breadcrumbs
BehaviorTree.CPP
/
src
/
shared_library_UNIX.cpp
Copy path
File metadata and controls
103 lines (88 loc) · 1.89 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#
include
"
behaviortree_cpp/exceptions.h
"
#
include
"
behaviortree_cpp/utils/shared_library.h
"
#
include
<
mutex
>
#
include
<
string
>
#
include
<
dlfcn.h
>
namespace
BT
{
SharedLibrary::SharedLibrary
() =
default
;
void
SharedLibrary::load
(
const
std::string& path,
int
)
{
const
std::unique_lock<std::mutex>
lock
(_mutex);
if
(_handle !=
nullptr
)
{
throw
RuntimeError
(
"
Library already loaded:
"
+ path);
}
_handle =
dlopen
(path.
c_str
(),
RTLD_NOW
|
RTLD_GLOBAL
);
if
(_handle ==
nullptr
)
{
const
char
* err =
dlerror
();
throw
RuntimeError
(
"
Could not load library:
"
+
(err !=
nullptr
?
std::string
(err) : path));
}
_path = path;
}
void
SharedLibrary::unload
()
{
const
std::unique_lock<std::mutex>
lock
(_mutex);
if
(_handle !=
nullptr
)
{
dlclose
(_handle);
_handle =
nullptr
;
}
}
bool
SharedLibrary::isLoaded
()
const
{
return
_handle !=
nullptr
;
}
void
*
SharedLibrary::findSymbol
(
const
std::string& name)
{
const
std::unique_lock<std::mutex>
lock
(_mutex);
void
* result =
nullptr
;
if
(_handle !=
nullptr
)
{
result =
dlsym
(_handle, name.
c_str
());
}
return
result;
}
const
std::string&
SharedLibrary::getPath
()
const
{
return
_path;
}
std::string
SharedLibrary::prefix
()
{
#
if
BT_OS == BT_OS_CYGWIN
return
"
cyg
"
;
#
else
return
"
lib
"
;
#
endif
}
std::string
SharedLibrary::suffix
()
{
#
if
BT_OS == BT_OS_MAC_OS_X
#
if
defined(_DEBUG) && !defined(CL_NO_SHARED_LIBRARY_DEBUG_SUFFIX)
return
"
d.dylib
"
;
#
else
return
"
.dylib
"
;
#
endif
#
elif
BT_OS == BT_OS_HPUX
#
if
defined(_DEBUG) && !defined(CL_NO_SHARED_LIBRARY_DEBUG_SUFFIX)
return
"
d.sl
"
;
#
else
return
"
.sl
"
;
#
endif
#
elif
BT_OS == BT_OS_CYGWIN
#
if
defined(_DEBUG) && !defined(CL_NO_SHARED_LIBRARY_DEBUG_SUFFIX)
return
"
d.dll
"
;
#
else
return
"
.dll
"
;
#
endif
#
else
#
if
defined(_DEBUG) && !defined(CL_NO_SHARED_LIBRARY_DEBUG_SUFFIX)
return
"
d.so
"
;
#
else
return
"
.so
"
;
#
endif
#
endif
}
}
//
namespace BT
Back
|
FazBrowse Home
|
New Git URL