20 #ifndef TULIP_PLUGINLISTER_H 21 #define TULIP_PLUGINLISTER_H 27 #include <tulip/Plugin.h> 28 #include <tulip/PluginLoader.h> 29 #include <tulip/Observable.h> 43 class FactoryInterface {
67 struct PluginDescription {
68 FactoryInterface *factory;
72 PluginDescription() : factory(
nullptr), info(
nullptr) {}
73 ~PluginDescription() {
114 template <
typename PluginType>
116 auto it = _plugins.find(pluginName);
117 return (it != _plugins.end() && (
dynamic_cast<const PluginType *
>(it->second.info) !=
nullptr));
131 template <
typename PluginType>
133 auto it = _plugins.find(name);
134 if (it != _plugins.end() && (
dynamic_cast<const PluginType *
>(it->second.info) !=
nullptr)) {
135 std::string pluginName = it->second.info->name();
136 if (name != pluginName)
137 tlp::warning() <<
"Warning: '" << name <<
"' is a deprecated plugin name. Use '" 138 << pluginName <<
"' instead." << std::endl;
140 return static_cast<PluginType *
>(it->second.factory->createPluginObject(context));
149 static std::list<std::string> availablePlugins();
151 template <
typename PluginType>
152 std::list<std::string> availablePlugins() {
153 std::list<std::string> keys;
155 for (
auto it = _plugins.begin(); it != _plugins.end(); ++it) {
156 PluginType *plugin =
dynamic_cast<PluginType *
>(it->second.info);
158 if (plugin !=
nullptr &&
160 it->first == it->second.info->name()) {
161 keys.push_back(it->first);
174 static const Plugin &pluginInformation(
const std::string &name);
182 static bool pluginExists(
const std::string &pluginName);
190 static const ParameterDescriptionList &getPluginParameters(
const std::string &name);
199 static const std::list<tlp::Dependency> &getPluginDependencies(
const std::string &name);
207 static std::string getPluginLibrary(
const std::string &name);
216 static void removePlugin(
const std::string &name);
224 static void registerPlugin(FactoryInterface *objectFactory);
228 void sendPluginAddedEvent(
const std::string &pluginName);
229 void sendPluginRemovedEvent(
const std::string &pluginName);
231 static PluginLister *_instance;
237 std::map<std::string, PluginDescription> _plugins;
246 static std::string getPluginRelease(
const std::string &name);
251 class TLP_SCOPE PluginEvent :
public Event {
253 enum PluginEventType { TLP_ADD_PLUGIN = 0, TLP_REMOVE_PLUGIN = 1 };
256 PluginEvent(PluginEventType pluginEvtType,
const std::string &pluginName)
257 : Event(*(
tlp::PluginLister::instance()), Event::TLP_MODIFICATION), evtType(pluginEvtType),
258 pluginName(pluginName) {}
260 PluginEventType getType()
const {
264 std::string getPluginName()
const {
269 PluginEventType evtType;
270 std::string pluginName;
275 #endif // TULIP_PLUGINLISTER_H
The PluginLister class is a singleton used to list plugins currently loaded into Tulip and retrieve i...
Contains runtime parameters for a plugin.
Top-level interface for plug-ins.
PluginType * getPluginObject(const std::string &name, tlp::PluginContext *context)
Similar to tlp::PluginLister::getPluginObject() but returns a typed instance.
The Observable class is the base of Tulip's observation system.
bool pluginExists(const std::string &pluginName)
Checks if a plugin of a given type is loaded This method checks the plugin "pluginName" is currently ...
A callback class when loading plugins into Tulip.