8 #ifndef META_OCEAN_BASE_PLUGIN_MANAGER_H
9 #define META_OCEAN_BASE_PLUGIN_MANAGER_H
41 TYPE_INTERACTION = 1 << 1,
45 TYPE_RENDERING = 1 << 3,
47 TYPE_SCENEDESCRIPTION = 1 << 4,
49 TYPE_PHYSICS = 1 << 5,
51 TYPE_ANY = TYPE_DEVICE | TYPE_INTERACTION | TYPE_MEDIA | TYPE_RENDERING | TYPE_SCENEDESCRIPTION | TYPE_PHYSICS
80 typedef std::vector<std::string>
Names;
94 typedef bool (*PluginLoadFunction)();
99 typedef bool (*PluginUnloadFunction)();
104 typedef const char* (*PluginVersionFunction)();
124 Plugin(
const std::string& filename,
const std::string& name,
const std::string& description,
const PluginType type,
const PluginPriority priority,
const PluginTypeSet& dependencySet,
const std::string& thirdpartyDependences,
const std::string& thirdpartyDescription);
130 inline const std::string& filename()
const;
136 inline const std::string& name()
const;
142 inline const std::string& description()
const;
148 inline const std::string& thirdpartyInformation()
const;
160 inline const std::string& thirdpartyDependences()
const;
166 inline const std::string& thirdpartyDescription()
const;
174 #if defined(__APPLE__)
192 #if defined(__APPLE__)
208 explicit operator bool()
const;
232 mutable void* handle_ =
nullptr;
250 mutable PluginLoadFunction loadFunction_ =
nullptr;
253 mutable PluginUnloadFunction unloadFunction_ =
nullptr;
272 inline const std::string& fileExtension()
const;
287 unsigned int collectPlugins(
const std::string& directory,
const bool removeAlreadyCollected =
true);
365 #if defined(__APPLE__)
417 return thirdpartyInformation_;
427 return thirdpartyDependences_;
432 return thirdpartyDescription_;
This class implements a recursive lock object.
Definition: Lock.h:31
This class implements a plugin interface.
Definition: PluginManager.h:88
const std::string & thirdpartyDependences() const
Returns the 3rd party dependences of this plugin.
Definition: PluginManager.h:425
std::string name_
Name of the plugin.
Definition: PluginManager.h:223
std::string thirdpartyDependences_
3rd party dependences.
Definition: PluginManager.h:244
bool unloadApple() const
Tries to unload the plugin.
const std::string & description() const
Returns the description of the plugin.
Definition: PluginManager.h:410
bool unload() const
Tries to unload the plugin.
std::string description_
Description of the plugin.
Definition: PluginManager.h:226
PluginType type() const
Returns the type of this plugin.
Definition: PluginManager.h:420
const std::string & filename() const
Returns the filename of the plugin.
Definition: PluginManager.h:400
const std::string & thirdpartyDescription() const
Returns the description about the 3rd party dependences of this plugin.
Definition: PluginManager.h:430
Plugin(const std::string &filename, const std::string &name, const std::string &description, const PluginType type, const PluginPriority priority, const PluginTypeSet &dependencySet, const std::string &thirdpartyDependences, const std::string &thirdpartyDescription)
Creates a new plugin object.
bool loadApple() const
Loads the plugin (specialization for Apple platforms)
bool operator<(const Plugin &right) const
Returns whether the left plugin has to be loaded before the right one.
bool load() const
Loads the plugin.
const std::string & name() const
Returns the name of the plugin.
Definition: PluginManager.h:405
std::string thirdpartyDescription_
3rd party description.
Definition: PluginManager.h:247
PluginTypeSet dependencySet_
Set of plugin types this plugin depends on.
Definition: PluginManager.h:238
Plugin()=default
Creates an empty plugin object.
const std::string & thirdpartyInformation() const
Returns the version information of the used 3rd party libraries.
Definition: PluginManager.h:415
std::string thirdpartyInformation_
3rd party library version information.
Definition: PluginManager.h:229
std::string filename_
Filename of the plugin.
Definition: PluginManager.h:220
This class implements a manager for all plugins available for the Ocean framework.
Definition: PluginManager.h:26
Plugins loadedPlugins_
Vector holding all loaded plugins.
Definition: PluginManager.h:391
Names unloadedPlugins() const
Returns all not loaded plugins.
std::vector< std::string > Names
Definition of a vector holding plugin names.
Definition: PluginManager.h:80
std::vector< Plugin > Plugins
Definition of a vector holding plugin objects.
Definition: PluginManager.h:259
Lock lock_
Lock for the manager.
Definition: PluginManager.h:397
bool unloadAllPlugins()
Unloads all loaded plugins.
bool loadPlugins(const PluginType type)
Loads all plugins with a specified type.
bool loadAllPlugins()
Loads all available plugins.
~PluginManager()
Destructs a plugin manager object.
static bool determinePluginApple(const std::string &filename, Plugin &plugin)
Determines whether a given file is a plugin (specialization for Apple platforms)
PluginPriority
Definition of different plugin load priority values.
Definition: PluginManager.h:59
@ PRIORITY_LOW
Low plugin load priority.
Definition: PluginManager.h:63
@ PRIORITY_MEDIUM
Medium plugin load priority.
Definition: PluginManager.h:65
@ PRIORITY_UNDEFINED
Undefined plugin load priority.
Definition: PluginManager.h:61
@ PRIORITY_HIGH
High plugin load priority.
Definition: PluginManager.h:67
bool setPluginFileExtension(const std::string &extension)
Sets the file extension for plugin files.
Plugins collectedPlugins_
Vector holding all collected plugins.
Definition: PluginManager.h:388
Names loadedPlugins() const
Returns all loaded plugins.
Names plugins() const
Returns all available plugins.
void release()
Releases the plugin manager and unloads all plugins.
bool loadPlugins(const Names &names)
Loads several plugins and uses the internal dependency order.
static bool determinePlugin(const std::string &filename, Plugin &plugin)
Determines whether a given file is a plugin.
const std::string & fileExtension() const
Returns the file extension for plugin files.
Definition: PluginManager.h:435
PluginType
Definition of different plugin types.
Definition: PluginManager.h:35
bool loadPlugin(const std::string &name)
Loads a specific plugin.
std::set< Plugin > PluginSet
Definition of a set holding plugin objects.
Definition: PluginManager.h:264
std::set< PluginType > PluginTypeSet
Definition of a set holding plugin types.
Definition: PluginManager.h:75
std::string pluginFileExtension_
File extension for plugins.
Definition: PluginManager.h:394
PluginManager()
Creates a new plugin manager object.
static PluginType translateType(const std::string &type)
Translates a plugin type string to a plugin type id.
unsigned int collectPlugins(const std::string &directory, const bool removeAlreadyCollected=true)
Collects all Ocean supported plugins available in a given directory.
This template class is the base class for all singleton objects.
Definition: Singleton.h:71
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15