FdkBaseLib 2.1.1
|
Classes | |
struct | Directory |
Public Types | |
using | DirectoryList = std::vector< Directory > |
Public Member Functions | |
void | prependSearchPath (const char *) |
Adds a search path to the beginning of the path list. | |
void | appendSearchPath (const char *) |
Adds a search path to the end of the path list. | |
size_t | numSearchPaths () const |
Returns the number of total search path strings, which is also the total number of Directories. | |
const StringList & | searchPaths () const |
Returns the list of search paths. | |
const DirectoryList & | directories () const |
const Directory & | directory (size_t i) const |
Retrieve the Directory entry. | |
const Directory & | findDirectoryForPath (const char *filepath) const |
const Directory & | findOrAddDirectory (const char *directory_name, size_t name_length=0) |
const StringList & | pluginExtensions () const |
std::filesystem::path | findPlugin (const char *plugin_name, const StringList *extensions=nullptr) |
PluginHandle | loadPlugin (const char *plugin_name, const StringList *extensions=nullptr) |
const std::string & | lastLoadedPlugin () const |
bool | haveLoadError () const |
const std::string & | lastLoadedError () const |
void | setLastLoadedError (const char *error_message) |
const StringList & | loadedPlugins () const |
Returns the list of paths to all successfully loaded plugins, last loaded at end. | |
Protected Member Functions | |
PluginRegistry (const PluginRegistry &)=delete | |
PluginRegistry & | operator= (const PluginRegistry &)=delete |
virtual void | _initializeSearchPaths ()=0 |
virtual bool | _isValidPlugin (const char *, const std::filesystem::path &, PluginHandle) const |
const DirectoryList & fdk::PluginRegistry::directories | ( | ) | const |
Returns the list of directories the registry will search to find a plugin. The indexing of this list will match searchPaths().
const Directory & fdk::PluginRegistry::findDirectoryForPath | ( | const char * | filepath | ) | const |
const Directory & fdk::PluginRegistry::findOrAddDirectory | ( | const char * | directory_name, |
size_t | name_length = 0 |
||
) |
|
inline |
List of default extensions that findPlugin() will append to the plugin name and search for, in priority order.
std::filesystem::path fdk::PluginRegistry::findPlugin | ( | const char * | plugin_name, |
const StringList * | extensions = nullptr |
||
) |
Attempt to find a plugin matching plugin_name with each possible extension inside each of the search directories, returning the path to the plugin file. If the extensions list is explicitly provided they are used instead of the current list in the registry.
PluginHandle fdk::PluginRegistry::loadPlugin | ( | const char * | plugin_name, |
const StringList * | extensions = nullptr |
||
) |
Attempt to find and load a plugin matching plugin_name with each possible extension inside each of the search directories. If plugin_name starts with a '\' or '/' then it's assumed to be an absolute file path and the plugin file directly loaded, skipping the search and extension matching. If the extensions list is explicitly provided it's used instead of the current list in the registry. If the plugin file is loaded without error it is added to the end of the loadedPlugins() list and the pointer to it returned, otherwise the error message from the failed load is retrieved via lastLoadedError().
const std::string & fdk::PluginRegistry::lastLoadedPlugin | ( | ) | const |
Returns the path of the most recently loaded plugin file, or empty if error has occurred, found in lastLoadedError().
|
protectedpure virtual |
Called the first time the registry is asked for the list of paths. A subclass should add the plugin search paths needed for basic functionality such as directories relative to the application or library install location. Must implement.
|
inlineprotectedvirtual |
Check that a loaded plugin file object is ok for the client dcc. Can be used for binary validation, checking for symbols, or license checks. Called when a plugin file has successfully loaded inside loadPlugin(), but before it's been added to the _loadedPlugins list. If this method returns false the plugin is unloaded and loadPlugin() returns a null PluginHandle. A clent dcc can fille in setLastLoadedError() with whatever it needs to communicate the reason why the plugin was rejected. Default implementation returns true.
©2024 The Foundry Visionmongers, Ltd. All Rights Reserved. |