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), info(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.info) != 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.info) != 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.info);
154 keys.push_back(it->first);
167 static const Plugin& pluginInformation(
const std::string& name);
175 static bool pluginExists(
const std::string& pluginName);
191 static const std::list<tlp::Dependency>& getPluginDependencies(
const std::string& name);
199 static std::string getPluginLibrary(
const std::string& name);
208 static void removePlugin(
const std::string& name);
216 static void registerPlugin(FactoryInterface* objectFactory);
222 void sendPluginAddedEvent(
const std::string &pluginName);
223 void sendPluginRemovedEvent(
const std::string &pluginName);
230 std::map<std::string , PluginDescription> _plugins;
238 static std::string getPluginRelease(
const std::string& name);
243 class TLP_SCOPE PluginEvent :
public Event {
246 enum PluginEventType {
248 TLP_REMOVE_PLUGIN = 1
252 PluginEvent(PluginEventType pluginEvtType,
const std::string& pluginName)
254 evtType(pluginEvtType), pluginName(pluginName) {}
256 PluginEventType getType()
const {
260 std::string getPluginName()
const {
266 PluginEventType evtType;
267 std::string pluginName;
274 #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.