Tesseract
Motion Planning Environment
Loading...
Searching...
No Matches
Static Public Member Functions | List of all members
tesseract_common::ClassLoader Struct Reference

This is a wrapper around Boost DLL for loading plugins within Tesseract. More...

#include <class_loader.h>

Static Public Member Functions

template<class ClassBase >
static std::shared_ptr< ClassBase > createSharedInstance (const std::string &symbol_name, const std::string &library_name, const std::string &library_directory="")
 Create a shared instance for the provided symbol_name loaded from the library_name searching system folders for library. More...
 
static bool isClassAvailable (const std::string &symbol_name, const std::string &library_name, const std::string &library_directory="")
 Check if the symbol is available in the library_name searching system folders for library. More...
 
static std::vector< std::string > getAvailableSymbols (const std::string &section, const std::string &library_name, const std::string &library_directory="")
 Get a list of available symbols under the provided section. More...
 
static std::vector< std::string > getAvailableSections (const std::string &library_name, const std::string &library_directory="", bool include_hidden=false)
 Get a list of available sections. More...
 
static std::string decorate (const std::string &library_name, const std::string &library_directory="")
 Give library name without prefix and suffix it will return the library name with the prefix and suffix. More...
 

Detailed Description

This is a wrapper around Boost DLL for loading plugins within Tesseract.

The library_name should not include the prefix 'lib' or suffix '.so'. It will add the correct prefix and suffix based on the OS.

The plugin must be exported using the macro TESSERACT_ADD_PLUGIN. In the example below, the first parameter is the derived object and the second is the assigned symbol name which is used for looding Example: TESSERACT_ADD_PLUGIN(my_namespace::MyPlugin, plugin)

auto p = ClassLoader::createSharedInstance<my_namespace::MyPluginBase>("my_plugin", "plugin");

Member Function Documentation

◆ createSharedInstance()

template<class ClassBase >
std::shared_ptr< ClassBase > tesseract_common::ClassLoader::createSharedInstance ( const std::string &  symbol_name,
const std::string &  library_name,
const std::string &  library_directory = "" 
)
static

Create a shared instance for the provided symbol_name loaded from the library_name searching system folders for library.

The symbol name is the alias provide when calling TESSERACT_ADD_PLUGIN

Parameters
symbol_nameThe symbol to create a shared instance of
library_nameThe library name to load which does not include the prefix 'lib' or suffix '.so'
library_directoryThe library directory, if empty it will enable search system directories
Returns
A shared pointer of the object with the symbol name located in library_name_

◆ decorate()

std::string tesseract_common::ClassLoader::decorate ( const std::string &  library_name,
const std::string &  library_directory = "" 
)
inlinestatic

Give library name without prefix and suffix it will return the library name with the prefix and suffix.

  • For instance, for a library_name like "boost" it returns :
  • path/to/libboost.so on posix platforms
  • path/to/libboost.dylib on OSX
  • path/to/boost.dll on Windows

    Todo:
    When support is dropped for 18.04 switch to using boost::dll::shared_library::decorate
    Parameters
    library_nameThe library name without prefix and suffix
    library_directoryThe library directory, if empty it just returns the decorated library name
    Returns
    The library name or path with prefix and suffix

◆ getAvailableSections()

std::vector< std::string > tesseract_common::ClassLoader::getAvailableSections ( const std::string &  library_name,
const std::string &  library_directory = "",
bool  include_hidden = false 
)
inlinestatic

Get a list of available sections.

Parameters
library_nameThe library name to load which does not include the prefix 'lib' or suffix '.so'
library_directoryThe library directory, if empty it will enable search system directories
Returns
A list of sections if they exist.

◆ getAvailableSymbols()

std::vector< std::string > tesseract_common::ClassLoader::getAvailableSymbols ( const std::string &  section,
const std::string &  library_name,
const std::string &  library_directory = "" 
)
inlinestatic

Get a list of available symbols under the provided section.

Parameters
sectionThe section to search for available symbols
library_nameThe library name to load which does not include the prefix 'lib' or suffix '.so'
library_directoryThe library directory, if empty it will enable search system directories
Returns
A list of symbols if they exist.

◆ isClassAvailable()

bool tesseract_common::ClassLoader::isClassAvailable ( const std::string &  symbol_name,
const std::string &  library_name,
const std::string &  library_directory = "" 
)
inlinestatic

Check if the symbol is available in the library_name searching system folders for library.

The symbol name is the alias provide when calling TESSERACT_ADD_PLUGIN

Parameters
symbol_nameThe symbol to create a shared instance of
library_nameThe library name to load which does not include the prefix 'lib' or suffix '.so'
library_directoryThe library directory, if empty it will enable search system directories
Returns
True if the symbol exists, otherwise false

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