Loading...
Searching...
No Matches
DLHandler Class Reference

`#include <openbabel/dlhandler.h>`

## Static Public Member Functions

static bool | getConvDirectory (std::string &convPath)
static int | findFiles (std::vector< std::string > &file_list, const std::string &pattern, const std::string &path)
static int | findFiles (std::vector< std::string > &file_list, const std::string &filename)
static bool | openLib (const std::string &lib_name)
static const char * | getFormatFilePattern ()
static char | getSeparator ()
static void | Sleep (int n)

## Detailed Description

Interface for dynamic libraries.

This class defines an interface for finding and opening dynamic loadable libraries on different platforms (e.g., modular plugins) via different source code files. It has only what is needed for OpenBabel and is not intended to be general purpose. Internally, it is used for dynamic loading and unloading OBFormat file translation modules.

## Member Function Documentation

## getConvDirectory()

bool getConvDirectory | ( | std::string & | convPath | ) |

static

Get the directory containing the dynamic library plugins.

The result is stored in `convPath` and depends on the operating system and build tools.

Linux: always returns OB_MODULE_PATH (defined in src/config.h.cmake).

Windows cygwin: Uses windows' GetModuleHandle to get a handle to the application module. From this, the applications path can be extracted. The appname.exe is removed and ..\lib\openbabel\BABEL_VERSION\ is appended.

Windows MSVC: Uses windows' GetModuleHandle to get a handle to the OBError dll module. From this, the dll's path can be extracted.

See also
  findFiles

Referenced by OBPlugin::LoadAllPlugins().

## findFiles() [1/2]

int findFiles | ( | std::vector< std::string > & | file_list,
|  | const std::string & | pattern,
|  | const std::string & | path )

static

Searches a directory specified by path for files whose name matches a pattern which can include * as a wildcard. If the BABEL_LIBDIR environment variable is set, this will override the `path` parameter. The path name should include a final separator (\ or /). The routine fills a vector of strings with the matching file names (including path). Note that this is not recursive: it only matches files in the specified path. For example, if path = e:\path\to\ and pattern = *.obf it will return vector entries lik e:\path\to\cmlformat.obf

Returns
  the number of valid files.

Referenced by findFiles(), and OBPlugin::LoadAllPlugins().

## findFiles() [2/2]

int findFiles | ( | std::vector< std::string > & | file_list,
|  | const std::string & | filename )

static

Searches for files which match a full filename (including the path) which contains a wildcard. The routine adds matching file names (including path) to a vector of strings .

Returns
  the number of matching files. If no wildcard in name adds name to vector and returns -1.

## openLib()

bool openLib | ( | const std::string & | lib_name | ) |

static

Open a dynamic library with path `lib_name`.

Referenced by OBPlugin::LoadAllPlugins().

## getFormatFilePattern()

const char * getFormatFilePattern | ( |  | ) |

static

Returns
  The file extension pattern for Open Babel plugin modules (e.g. *.obf on Windows)

Referenced by OBPlugin::LoadAllPlugins(), and matchFiles().

## getSeparator()

char getSeparator | ( |  | ) |

static

Returns
  The system directory separator (i.e. "\" on Windows, "/" on UNIX)

Referenced by findFiles().

## Sleep()

void Sleep | ( | int | n | ) |

static

Call the system routine to wait (sleep) this process for `n` seconds.

Referenced by Sleep().

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

- dlhandler.h
- dlhandler_unix.cpp
- dlhandler_win32.cpp