Tesseract
Motion Planning Environment
Loading...
Searching...
No Matches
class_loader.h
Go to the documentation of this file.
1
26#ifndef TESSERACT_COMMON_CLASS_LOADER_H
27#define TESSERACT_COMMON_CLASS_LOADER_H
28
31#include <memory>
32#include <string>
33#include <vector>
35
36namespace tesseract_common
37{
50{
60 template <class ClassBase>
61 static std::shared_ptr<ClassBase> createSharedInstance(const std::string& symbol_name,
62 const std::string& library_name,
63 const std::string& library_directory = "");
64
73 static inline bool isClassAvailable(const std::string& symbol_name,
74 const std::string& library_name,
75 const std::string& library_directory = "");
76
84 static inline std::vector<std::string> getAvailableSymbols(const std::string& section,
85 const std::string& library_name,
86 const std::string& library_directory = "");
87
94 static inline std::vector<std::string> getAvailableSections(const std::string& library_name,
95 const std::string& library_directory = "",
96 bool include_hidden = false);
97
111 static inline std::string decorate(const std::string& library_name, const std::string& library_directory = "");
112};
113} // namespace tesseract_common
114
115// clang-format off
116#define TESSERACT_ADD_PLUGIN_SECTIONED(DERIVED_CLASS, ALIAS, SECTION) \
117 extern "C" BOOST_SYMBOL_EXPORT DERIVED_CLASS ALIAS; \
118 BOOST_DLL_SECTION(SECTION, read) BOOST_DLL_SELECTANY \
119 DERIVED_CLASS ALIAS;
120
121#define TESSERACT_ADD_PLUGIN(DERIVED_CLASS, ALIAS) \
122 TESSERACT_ADD_PLUGIN_SECTIONED(DERIVED_CLASS, ALIAS, boostdll)
123
124#define TESSERACT_PLUGIN_ANCHOR_DECL(ANCHOR_NAME) \
125 const void* ANCHOR_NAME(); // NOLINT
126
127#define TESSERACT_PLUGIN_ANCHOR_IMPL(ANCHOR_NAME) \
128 const void* ANCHOR_NAME() { return (const void*)(&ANCHOR_NAME); } // NOLINT
129
130// clang-format on
131
133
134#endif // TESSERACT_COMMON_CLASS_LOADER_H
Class Loader to be used throughout Tesseract for loading plugins.
Common Tesseract Macros.
#define TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
Definition: macros.h:71
Definition: create_convex_hull.cpp:36
Definition: allowed_collision_matrix.h:16
const std::string symbol_name
Definition: plugin_loader_unit.cpp:58
This is a wrapper around Boost DLL for loading plugins within Tesseract.
Definition: class_loader.h:50
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.
Definition: class_loader.hpp:82
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.
Definition: class_loader.hpp:148
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.
Definition: class_loader.hpp:113
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 f...
Definition: class_loader.hpp:45
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 suffi...
Definition: class_loader.hpp:196