CppCMS

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
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, int flags)
| 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)
bool | open (std::string const &file_name, int flags)
bool | open (std::string const &file_name, std::string &error_message, int flags)
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)

## Static Public Attributes
static const int | load_lazy = 1
static const int | load_now = 2
| Pass RTLD_LAZY to dlopen.
static const int | load_global = 4
| Pass RTLD_NOW to dlopen.
static const int | load_local = 8
| Pass RTLD_GLOBAL to dlopen.

## Detailed Description

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

## Constructor & Destructor Documentation

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

Pass RTLD_LOCAL to dlopen 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,
|  | int | flags
| ) |  |

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 flags - load flags: one of load_lazy, load_now, load_local, load_global - ignored on Windows

Exceptions

  booster::system::system_error | if it is impossible to load it New in CppCMS 1.2

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

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

Load shared object or dll

Parameters

  file_name | - the name of the file, UTF-8 encoded under Windows flags - load flags: one of load_lazy, load_now, load_local, load_global - ignored on Windows

Returns
  true if the shared object was loaded

New in CppCMS 1.2

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

Load shared object or dll

Parameters

  file_name | - the name of the file, UTF-8 encoded under Windows flags - load flags: one of load_lazy, load_now, load_local, load_global - ignored on Windows
  error_message | - the error message

Returns
  true if the shared object was loaded

New in CppCMS 1.2

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 resolved booster::runtime_error is thrown

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

- booster/shared_object.h