booster::shared_object Class Reference

Class that allows loading dynamic libraries: shared objects and dlls. More...

`#include <booster/booster/shared_object.h>`

Inheritance diagram for booster::shared_object:

## Public Member Functions

| shared_object ()
| ~shared_object ()
| shared_object (std::string const &file_name)
bool | is_open () const
bool | open (std::string const &file_name)
bool | open (std::string const &file_name, std::string &error_message)
void | close ()
void * | resolve_symbol (std::string const &name) const
template<typename T >
void | symbol (T &s, std::string const &name) const

## Static Public Member Functions

static std::string | name (std::string const &module)
static std::string | name (std::string const &module, std::string const &soversion)

## Detailed Description

Class that allows loading dynamic libraries: shared objects and dlls.

## Constructor & Destructor Documentation

booster::shared_object::shared_object | ( |  | ) |

Create an empty shared object

booster::shared_object::~shared_object | ( |  | ) |

If the shared object was open unloads it, If private copy of DLL was made it is removed from the file system

booster::shared_object::shared_object | ( | std::string const & | file_name | ) |

Create shared object and load it,

See Also
  open(std::string const&,bool);

Parameters

  file_name | - the name of the file, UTF-8 encoded under Windows

Exceptions

  booster::system::system_error | if it is impossible to load it

## Member Function Documentation

void booster::shared_object::close | ( |  | ) |

Unload the shared object

bool booster::shared_object::is_open | ( |  | ) | const

Check if the shared object was loaded

static std::string booster::shared_object::name | ( | std::string const & | module | ) |

static

Format the OS specific name name of the library according to its name. Uses CMake convensions.

For example library "foo" is converted to the name

- libfoo.so under Linux, FreeBSD, Solaris
- libfoo.dylib under Darwin/Mac OS X
- libfoo.dll under Windows using gcc/mingw
- foo.dll under Windows using MSVC
- cygfoo.dll under Cygwin

static std::string booster::shared_object::name | ( | std::string const & | module,
|  | std::string const & | soversion
| ) |  |

static

Format the OS specific name name of the library according to its name and its soversion. Uses CMake convensions.

For example library "foo" and soversion "1" is converted to the name

- libfoo.so.1 under Linux, FreeBSD, Solaris
- libfoo.1.dylib under Darwin/Mac OS X
- libfoo-1.dll under Windows using gcc/mingw
- foo-1.dll under Windows using MSVC
- cygfoo-1.dll under Cygwin

bool booster::shared_object::open | ( | std::string const & | file_name | ) |

Load shared object or dll

Parameters

  file_name | - the name of the file, UTF-8 encoded under Windows

Returns
  true if the shared object was loaded

bool booster::shared_object::open | ( | std::string const & | file_name,
|  | std::string & | error_message
| ) |  |

Load shared object or dll

Parameters

  file_name | - the name of the file, UTF-8 encoded under Windows
  error_message | - the error message

Returns
  true if the shared object was loaded

void* booster::shared_object::resolve_symbol | ( | std::string const & | name | ) | const

Resolve symbol in the shared object dll. If it can't be resolved, NULL is returned

If the shared object was not opened, it would throw booster::runtime_error

template<typename T >

void booster::shared_object::symbol | ( | T & | s,
|  | std::string const & | name
| ) |  | const

inline

Resolve symbol in the shared object dll. If it can't be

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

- booster/shared_object.h