Tulip 6.1.0
Large graphs analysis and drawing
Loading...
Searching...
No Matches
PluginLibraryLoader.h
1/*
2 *
3 * This file is part of Tulip (https://tulip.labri.fr)
4 *
5 * Authors: David Auber and the Tulip development Team
6 * from LaBRI, University of Bordeaux
7 *
8 * Tulip is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation, either version 3
11 * of the License, or (at your option) any later version.
12 *
13 * Tulip is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 * See the GNU General Public License for more details.
17 *
18 */
19///@cond DOXYGEN_HIDDEN
20
21#ifndef PLUGINLIBLOADER_H
22#define PLUGINLIBLOADER_H
23
24#include <set>
25#include <string>
26
27#include <tulip/tulipconf.h>
28
29namespace tlp {
30
31struct PluginLoader;
32
33/**
34 * @ingroup Plugins
35 *
36 * @brief This class takes care of the actual loading of the libraries.
37 * You can use it to load a single plugin (loadPluginLibrary) or all the plugins in a given folder
38 *(loadPlugins).
39 *
40 * It is a singleton to guarantee the currentPluginLibrary member is initialized, but it only shows
41 *static functions for syntactic sugar.
42 **/
43class TLP_SCOPE PluginLibraryLoader {
44public:
45 /**
46 * @brief Loads all the plugins in each directory contained in TulipPluginsPath.
47 * This function will not look into subfolders of the specified folder.
48 *
49 *
50 * To load all the plugins in the following example, you need to call this function once for the
51 *lib/tulip folder,
52 * once for the glyph folder, and once for the interactors folder.
53 *
54 * lib/tulip/
55 * -> glyphs
56 * |-> libBillboard-4.0.0.so
57 * |-> libWindow-4.0.0.so
58 * -> interactors
59 * |-> libInteractorAddEdge-4.0.0.so
60 * |-> libInteractorSelectionModifier-4.0.0.so
61 * -> libAdjacencyMatrixImport-4.0.0.so
62 * -> libColorMapping-4.0.0.so
63 * -> libCompleteGraph-4.0.0.so
64 *
65 *
66 * @param loader A PluginLoader to output what is going on. Defaults to nullptr.
67 * @param pluginPath A folder to append to each path in TulipPluginsPath (e.g. "glyphs/")
68 *
69 **/
70 static void loadPlugins(PluginLoader *loader = nullptr, const std::string &pluginPath = "");
71
72 /**
73 * @brief Recursively loads plugins from a root directory.
74 *
75 * @since Tulip 5.1
76 *
77 * This function enables to recursively load Tulip plugins from a
78 * provided root directory, thus visiting subdirectories of the provided
79 * one and so forth. If a new version of a plugin exist in a user specific
80 * local directory then the plugin is not loaded.
81 *
82 *
83 * @param rootPath The root directory from which to look for plugins to load.
84 * @param loader A PluginLoader to output what is going on. Defaults to nullptr.
85 * @param userLocalPath A user specific local directory where some plugins may have been downloaded
86
87 *
88 **/
89 static void loadPluginsFromDir(const std::string &rootPath, PluginLoader *loader = nullptr,
90 const std::string &userLocalPath = "");
91
92 /**
93 * @brief Loads a single plugin library.
94 *
95 * @param filename The name of the plugin file to load.
96 * @param loader A loader to report what is going on (only its loaded or aborted functions will be
97 *called) Defaults to nullptr.
98 * @return bool Whether the plugin was successfully loaded.
99 **/
100 static bool loadPluginLibrary(const std::string &filename, PluginLoader *loader = nullptr);
101
102 /**
103 * @brief Gets the name of the plug-in library being loaded.
104 * If the plugin is statically linked into the tulip library, returns an empty string.
105 *
106 * @return :string& The name of the plugin library being loaded.
107 **/
108 static const std::string &getCurrentPluginFileName() {
109 return _currentPluginLibrary;
110 }
111
112private:
113 PluginLibraryLoader() {}
114 static bool initPluginDir(PluginLoader *loader, bool recursive = false,
115 const std::string &userPluginsPath = "");
116 static std::string _message;
117 static std::string _pluginPath;
118 static std::string _currentPluginLibrary;
119};
120} // namespace tlp
121
122#endif // PLUGINLIBLOADER_H
123
124///@endcond
A callback class when loading plugins into Tulip.