rcpputils  master
C++ API providing common utilities and data structures.
Public Member Functions | List of all members
rcpputils::SharedLibrary Class Reference

#include <shared_library.hpp>

Public Member Functions

 SharedLibrary (const std::string &library_path)
 The library is loaded in the constructor. More...
 
virtual ~SharedLibrary ()
 The library is unloaded in the deconstructor. More...
 
void unload_library ()
 Unload library. More...
 
bool has_symbol (const std::string &symbol_name)
 Return true if the shared library contains a specific symbol name otherwise returns false. More...
 
void * get_symbol (const std::string &symbol_name)
 Return shared library symbol pointer. More...
 
std::string get_library_path ()
 Return shared library path. More...
 

Detailed Description

This class is an abstraction of rcutils shared library to be able to used it with modern C++.

Constructor & Destructor Documentation

◆ SharedLibrary()

rcpputils::SharedLibrary::SharedLibrary ( const std::string library_path)
explicit

The library is loaded in the constructor.

Parameters
[in]library_pathThe library string path.
Exceptions
std::bad_allocif allocating storage for the callback fails
std::runtime_errorif there are some invalid arguments or the library was not load properly

◆ ~SharedLibrary()

virtual rcpputils::SharedLibrary::~SharedLibrary ( )
virtual

The library is unloaded in the deconstructor.

Member Function Documentation

◆ unload_library()

void rcpputils::SharedLibrary::unload_library ( )

Unload library.

Exceptions
std::runtime_errorif the library is not unloaded properly

◆ has_symbol()

bool rcpputils::SharedLibrary::has_symbol ( const std::string symbol_name)

Return true if the shared library contains a specific symbol name otherwise returns false.

Parameters
[in]symbol_namename of the symbol inside the shared library
Returns
if symbols exists returns true, otherwise returns false.

◆ get_symbol()

void* rcpputils::SharedLibrary::get_symbol ( const std::string symbol_name)

Return shared library symbol pointer.

Parameters
[in]symbol_namename of the symbol inside the shared library
Returns
shared library symbol pointer, if the symbol doesn't exist then throws a runtime_error exception
Exceptions
std::runtime_errorif the symbol doesn't exist in the shared library

◆ get_library_path()

std::string rcpputils::SharedLibrary::get_library_path ( )

Return shared library path.

Returns
shared library path or it throws an std::runtime_error if it's not defined
Exceptions
std::runtime_errorif the path is NULL

The documentation for this class was generated from the following file: