Class SharedLibrary

Class Documentation

class SharedLibrary

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

Public Functions

explicit SharedLibrary(const std::string &library_path)

The library is loaded in the constructor.

Parameters:

library_path[in] The library string path.

Throws:
  • std::bad_alloc – if allocating storage for the callback fails

  • std::runtime_error – if there are some invalid arguments or the library was not load properly

virtual ~SharedLibrary()

The library is unloaded in the deconstructor.

void unload_library()

Unload library.

Throws:

std::runtime_error – if the library is not unloaded properly

bool has_symbol(const char *symbol_name)

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

Parameters:

symbol_name[in] name of the symbol inside the shared library

Returns:

if symbols exists returns true, otherwise returns false.

bool has_symbol(const std::string &symbol_name)
Parameters:

symbol_name[in] name of the symbol inside the shared library

Returns:

if symbols exists returns true, otherwise returns false.

void *get_symbol(const char *symbol_name)

Return shared library symbol pointer.

Parameters:

symbol_name[in] name of the symbol inside the shared library

Throws:

std::runtime_error – if the symbol doesn’t exist in the shared library

Returns:

shared library symbol pointer, if the symbol doesn’t exist then throws a runtime_error exception

void *get_symbol(const std::string &symbol_name)

Return shared library symbol pointer.

Parameters:

symbol_name[in] name of the symbol inside the shared library

Throws:

std::runtime_error – if the symbol doesn’t exist in the shared library

Returns:

shared library symbol pointer, if the symbol doesn’t exist then throws a runtime_error exception

std::string get_library_path()

Return shared library path.

Throws:

std::runtime_error – if the path is NULL

Returns:

shared library path or it throws an std::runtime_error if it’s not defined