CppCommon  1.0.4.1
C++ Common Library
Public Member Functions | Static Public Member Functions | Friends | List of all members
CppCommon::DLL Class Reference

Dynamic link library. More...

#include <dll.h>

Public Member Functions

 DLL ()
 Initialize the dynamic link library with an empty path. More...
 
 DLL (const Path &path, bool load=true)
 Initialize the dynamic link library with a given path and optionally load it. More...
 
 DLL (const DLL &dll)
 
 DLL (DLL &&dll) noexcept
 
 ~DLL ()
 
DLLoperator= (const Path &path)
 
DLLoperator= (const DLL &dll)
 
DLLoperator= (DLL &&dll) noexcept
 
 operator bool () const
 Check if the dynamic link library is loaded. More...
 
const Path path () const
 Get the dynamic link library path. More...
 
bool IsLoaded () const
 Is dynamic link library loaded? More...
 
bool IsResolve (const std::string &name) const
 Is dynamic link library resolve the given symbol? More...
 
bool Load ()
 Load dynamic link library. More...
 
bool Load (const Path &path)
 Load dynamic link library with a given path. More...
 
void Unload ()
 Unload dynamic link library. More...
 
template<typename T >
T * Resolve (const std::string &name) const
 Resolve dynamic link library symbol by the given name. More...
 
void swap (DLL &dll) noexcept
 Swap two instances. More...
 

Static Public Member Functions

static std::string prefix ()
 Get the dynamic link library prefix. More...
 
static std::string extension ()
 Get the dynamic link library extension. More...
 

Friends

void swap (DLL &dll1, DLL &dll2) noexcept
 

Detailed Description

Dynamic link library.

Dynamic link library wraps dll operations (load, resolve, unload).

Not thread-safe.

Examples
system_dll.cpp.

Definition at line 55 of file dll.h.

Constructor & Destructor Documentation

◆ DLL() [1/4]

CppCommon::DLL::DLL ( )

Initialize the dynamic link library with an empty path.

Definition at line 147 of file dll.cpp.

◆ DLL() [2/4]

CppCommon::DLL::DLL ( const Path path,
bool  load = true 
)

Initialize the dynamic link library with a given path and optionally load it.

Parameters
path- Dynamic link library path
load- Load library flag (default is true)

Definition at line 158 of file dll.cpp.

◆ DLL() [3/4]

CppCommon::DLL::DLL ( const DLL dll)

Definition at line 174 of file dll.cpp.

◆ DLL() [4/4]

CppCommon::DLL::DLL ( DLL &&  dll)
noexcept

Definition at line 187 of file dll.cpp.

◆ ~DLL()

CppCommon::DLL::~DLL ( )

Definition at line 200 of file dll.cpp.

Member Function Documentation

◆ extension()

std::string CppCommon::DLL::extension ( )
inlinestatic

Get the dynamic link library extension.

Linux: .so OSX: .dylib Windows: .dll

Returns
Dynamic link library extension

Definition at line 28 of file dll.inl.

◆ IsLoaded()

bool CppCommon::DLL::IsLoaded ( ) const

Is dynamic link library loaded?

Definition at line 226 of file dll.cpp.

◆ IsResolve()

bool CppCommon::DLL::IsResolve ( const std::string &  name) const

Is dynamic link library resolve the given symbol?

Definition at line 227 of file dll.cpp.

◆ Load() [1/2]

bool CppCommon::DLL::Load ( )

Load dynamic link library.

Returns
'true' if the library was successfully loaded, 'false' if the library was not loaded
Examples
system_dll.cpp.

Definition at line 229 of file dll.cpp.

◆ Load() [2/2]

bool CppCommon::DLL::Load ( const Path path)

Load dynamic link library with a given path.

Parameters
path- Dynamic link library path
Returns
'true' if the library was successfully loaded, 'false' if the library was not loaded

Definition at line 230 of file dll.cpp.

◆ operator bool()

CppCommon::DLL::operator bool ( ) const
inlineexplicit

Check if the dynamic link library is loaded.

Definition at line 75 of file dll.h.

◆ operator=() [1/3]

DLL & CppCommon::DLL::operator= ( const DLL dll)

Definition at line 212 of file dll.cpp.

◆ operator=() [2/3]

DLL & CppCommon::DLL::operator= ( const Path path)

Definition at line 206 of file dll.cpp.

◆ operator=() [3/3]

DLL & CppCommon::DLL::operator= ( DLL &&  dll)
noexcept

Definition at line 218 of file dll.cpp.

◆ path()

const Path CppCommon::DLL::path ( ) const

Get the dynamic link library path.

Definition at line 224 of file dll.cpp.

◆ prefix()

std::string CppCommon::DLL::prefix ( )
inlinestatic

Get the dynamic link library prefix.

Cygwin: cyg MinGW: lib Linux: lib OSX: lib Windows:

Returns
Dynamic link library prefix

Definition at line 17 of file dll.inl.

◆ Resolve()

template<typename T >
T * CppCommon::DLL::Resolve ( const std::string &  name) const
inline

Resolve dynamic link library symbol by the given name.

Parameters
name- Symbol name
Returns
A pointer to the resolved symbol or nullptr in case of symbol resolution failed
Examples
system_dll.cpp.

Definition at line 12 of file dll.inl.

◆ swap()

void CppCommon::DLL::swap ( DLL dll)
noexcept

Swap two instances.

Definition at line 235 of file dll.cpp.

◆ Unload()

void CppCommon::DLL::Unload ( )

Unload dynamic link library.

If the dynamic link library cannot be unloaded the method will raise a dynamic link library exception!

Examples
system_dll.cpp.

Definition at line 231 of file dll.cpp.

Friends And Related Function Documentation

◆ swap

void swap ( DLL dll1,
DLL dll2 
)
friend

Definition at line 41 of file dll.inl.


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