rcpputils  master
C++ API providing common utilities and data structures.
shared_library.hpp
Go to the documentation of this file.
1 // Copyright 2020 Open Source Robotics Foundation, Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef RCPPUTILS__SHARED_LIBRARY_HPP_
16 #define RCPPUTILS__SHARED_LIBRARY_HPP_
17 
18 #include <string>
19 #include <stdexcept>
20 
21 #include "rcutils/shared_library.h"
23 
24 namespace rcpputils
25 {
26 
32 {
33 public:
35 
42  explicit SharedLibrary(const std::string & library_path);
43 
46  virtual ~SharedLibrary();
47 
49 
53  void
55 
57 
62  bool
63  has_symbol(const std::string & symbol_name);
64 
66 
73  void *
74  get_symbol(const std::string & symbol_name);
75 
77 
84 
85 private:
86  rcutils_shared_library_t lib;
87 };
88 
90 
101 std::string get_platform_library_name(std::string library_name, bool debug = false);
102 
103 } // namespace rcpputils
104 
105 #endif // RCPPUTILS__SHARED_LIBRARY_HPP_
std::string
rcpputils::SharedLibrary::get_library_path
std::string get_library_path()
Return shared library path.
rcpputils
Definition: asserts.hpp:37
rcpputils::get_platform_library_name
std::string get_platform_library_name(std::string library_name, bool debug=false)
Get the platform specific library name.
rcpputils::SharedLibrary
Definition: shared_library.hpp:31
rcpputils::SharedLibrary::unload_library
void unload_library()
Unload library.
rcpputils::SharedLibrary::has_symbol
bool has_symbol(const std::string &symbol_name)
Return true if the shared library contains a specific symbol name otherwise returns false.
visibility_control.hpp
Macros for controlling visibilty of exported iterfaces.
RCPPUTILS_PUBLIC
#define RCPPUTILS_PUBLIC
Declares symbols and functions will be visible for export.
Definition: visibility_control.hpp:85
rcpputils::SharedLibrary::~SharedLibrary
virtual ~SharedLibrary()
The library is unloaded in the deconstructor.
rcpputils::SharedLibrary::SharedLibrary
SharedLibrary(const std::string &library_path)
The library is loaded in the constructor.
rcpputils::SharedLibrary::get_symbol
void * get_symbol(const std::string &symbol_name)
Return shared library symbol pointer.