Tulip
4.6.0
Better Visualization Through Research
|
00001 /* 00002 * 00003 * This file is part of Tulip (www.tulip-software.org) 00004 * 00005 * Authors: David Auber and the Tulip development Team 00006 * from LaBRI, University of Bordeaux 00007 * 00008 * Tulip is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU Lesser General Public License 00010 * as published by the Free Software Foundation, either version 3 00011 * of the License, or (at your option) any later version. 00012 * 00013 * Tulip is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00016 * See the GNU General Public License for more details. 00017 * 00018 */ 00019 00020 #ifndef PLUGINLIBLOADER_H 00021 #define PLUGINLIBLOADER_H 00022 00023 #ifndef DOXYGEN_NOTFOR_USER 00024 00025 #include <set> 00026 #include <string> 00027 00028 #include <tulip/tulipconf.h> 00029 00030 namespace tlp { 00031 00032 struct PluginLoader; 00033 00034 /** 00035 * @ingroup Plugins 00036 * 00037 * @brief This class takes care of the actual loading of the libraries. 00038 * You can use it to load a single plugin (loadPluginLibrary) or all the plugins in a given folder (loadPlugins).0 00039 * 00040 * It is a singleton to guarantee the currentPluginLibrary member is initialized, but it only shows static functions for syntactic sugar. 00041 **/ 00042 class TLP_SCOPE PluginLibraryLoader { 00043 public: 00044 00045 #ifndef EMSCRIPTEN 00046 /** 00047 * @brief Loads all the plugins in each directory contained in TulipPluginsPath. 00048 * This function will not look into subfolders of the specified folder. 00049 * 00050 * 00051 * To load all the plugins in the following example, you need to call this function once for the lib/tulip folder, 00052 * once for the glyph folder, and once for the interactors folder. 00053 * 00054 * lib/tulip/ 00055 * -> glyphs 00056 * |-> libBillboard-4.0.0.so 00057 * |-> libWindow-4.0.0.so 00058 * -> interactors 00059 * |-> libInteractorAddEdge-4.0.0.so 00060 * |-> libInteractorSelectionModifier-4.0.0.so 00061 * -> libAdjacencyMatrixImport-4.0.0.so 00062 * -> libColorMapping-4.0.0.so 00063 * -> libCompleteGraph-4.0.0.so 00064 * 00065 * 00066 * @param loader A PluginLoader to output what is going on. Defaults to 0. 00067 * @param pluginPath A folder to append to each path in TulipPluginsPath (e.g. "glyphs/") 00068 * 00069 **/ 00070 static void loadPlugins(PluginLoader *loader = NULL, const std::string& pluginPath = ""); 00071 00072 /** 00073 * @brief Loads a single plugin library. 00074 * 00075 * @param filename The name of the plugin file to load. 00076 * @param loader A loader to report what is going on (only its loaded or aborted functions will be called) Defaults to 0. 00077 * @return bool Whether the plugin was sucessfully loaded. 00078 **/ 00079 static bool loadPluginLibrary(const std::string & filename, PluginLoader *loader = NULL); 00080 #endif //EMSCRIPTEN 00081 00082 /** 00083 * @brief Gets the name of the plug-in library being loaded. 00084 * If the plugin is statically linked into the tulip library, returns an empty string. 00085 * 00086 * @return :string& The name of the plugin library being loaded. 00087 **/ 00088 static const std::string& getCurrentPluginFileName() { 00089 return getInstance()->currentPluginLibrary; 00090 } 00091 00092 private: 00093 PluginLibraryLoader() {} 00094 #ifndef EMSCRIPTEN 00095 bool loadNextPluginLibrary(PluginLoader *loader); 00096 00097 bool initPluginDir(PluginLoader *loader); 00098 #endif 00099 00100 static PluginLibraryLoader* getInstance() { 00101 if(_instance == NULL) { 00102 _instance = new PluginLibraryLoader(); 00103 } 00104 00105 return _instance; 00106 } 00107 static PluginLibraryLoader* _instance; 00108 00109 std::string message; 00110 std::string pluginPath; 00111 std::string currentPluginLibrary; 00112 }; 00113 00114 } 00115 #endif //DOXYGEN_NOTFOR_USER 00116 #endif //PLUGINLIBLOADER_H