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 {
64 struct PluginDescription {
65 FactoryInterface* factory;
69 PluginDescription(): factory(NULL), infos(NULL) {}
70 ~PluginDescription() {
109 template<
typename PluginType>
111 std::map<std::string, PluginDescription>::const_iterator it =
112 _plugins.find(pluginName);
113 return (it != _plugins.end() &&
114 (
dynamic_cast<const PluginType*
>(it->second.infos) != NULL));
127 template<
typename PluginType>
130 std::map<std::string, PluginDescription>::const_iterator it =
132 return (it != _plugins.end() &&
133 (
dynamic_cast<const PluginType*
>(it->second.infos) != NULL))
134 ? static_cast<PluginType*>(it->second.factory->createPluginObject(context))
143 static std::list<std::string> availablePlugins();
146 template<
typename PluginType>
147 std::list<std::string> availablePlugins() {
148 std::list<std::string> keys;
150 for(std::map<std::string, PluginDescription>::const_iterator it = _plugins.begin(); it != _plugins.end(); ++it) {
151 PluginType* plugin =
dynamic_cast<PluginType*
>(it->second.infos);
154 keys.push_back(it->first);
167 static const Plugin& pluginInformation(
const std::string& name);
176 static _DEPRECATED
const Plugin& pluginInformations(
const std::string& name);
184 static bool pluginExists(
const std::string& pluginName);
200 static const std::list<tlp::Dependency>& getPluginDependencies(
const std::string& name);
208 static std::string getPluginLibrary(
const std::string& name);
217 static void removePlugin(
const std::string& name);
225 static void registerPlugin(FactoryInterface* objectFactory);
231 void sendPluginAddedEvent(
const std::string &pluginName);
232 void sendPluginRemovedEvent(
const std::string &pluginName);
239 std::map<std::string , PluginDescription> _plugins;
247 static std::string getPluginRelease(
const std::string& name);
252 class TLP_SCOPE PluginEvent :
public Event {
255 enum PluginEventType {
257 TLP_REMOVE_PLUGIN = 1
261 PluginEvent(PluginEventType pluginEvtType,
const std::string& pluginName)
263 evtType(pluginEvtType), pluginName(pluginName) {}
265 PluginEventType getType()
const {
269 std::string getPluginName()
const {
275 PluginEventType evtType;
276 std::string pluginName;
283 #endif //TULIP_PLUGINLISTER_H
The PluginLister class is a singleton used to list plugins currently loaded into Tulip and retrieve i...
Event is the base class for all events used in the Observation mechanism.
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.
This class describes parameters taken by a plugin.
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.
static tlp::PluginLister * instance()
Gets the static instance of this class. If not already done, creates it beforehand.