RobWorkProject  23.9.11-
Public Types | Public Member Functions | List of all members
PluginRepository Class Reference

The PluginRepository provides a container load methods for plugins. More...

#include <PluginRepository.hpp>

Public Types

typedef rw::core::Ptr< PluginRepositoryPtr
 Smart pointer type for PluginRepository.
 

Public Member Functions

 PluginRepository ()
 Constructs an empty repository.
 
 ~PluginRepository ()
 Destructor.
 
void load (const std::string &filename)
 Loads in a PluginFactoryBase from a file. More...
 
void loadFilesInFolder (const std::string &path, bool searchSubFolders)
 Attempts to load all dll files in folder. More...
 
void addPlugin (PluginFactoryBase::Ptr plugin, bool force=false)
 this adds a plugin directly More...
 
const std::map< std::string, PluginFactoryBase::Ptr > & getAllPlugins () const
 Returns map in which keys are the identifiers of loaded plugins factories and the value is the plugin factory. More...
 
std::map< std::string, PluginFactoryBase::Ptr > & getAllPlugins ()
 Returns map in which keys are the identifiers of loaded plugins factories and the value is the plugin factory. More...
 
template<class T >
std::vector< rw::core::Ptr< PluginFactory< T > > > getPlugins ()
 Returns all rw::core::PluginFactory<T> instances which matches the template argument T. More...
 

Detailed Description

The PluginRepository provides a container load methods for plugins.

The PluginRepository contain a collection of pointers rw::plugin::PluginFactoryBase instances which can be used to create plugins.

The PluginRepository has a number of different methods to load plugins and methods for searching for a plugins either based on identifiers or by type.

Member Function Documentation

◆ addPlugin()

void addPlugin ( PluginFactoryBase::Ptr  plugin,
bool  force = false 
)

this adds a plugin directly

This is especially usefull if you want to add plugin functionality statically avoiding dynamic loading or managing the dynamic loading your self.

Parameters
plugin[in] the plugin factory base
force[in] if true, an existing plugin with same identifier string will be replaced by the new plugin

◆ getAllPlugins() [1/2]

std::map<std::string, PluginFactoryBase::Ptr>& getAllPlugins ( )

Returns map in which keys are the identifiers of loaded plugins factories and the value is the plugin factory.

Returns
Reference to std::map with identifier and PluginFactoryBase::Ptr.

◆ getAllPlugins() [2/2]

const std::map<std::string, PluginFactoryBase::Ptr>& getAllPlugins ( ) const

Returns map in which keys are the identifiers of loaded plugins factories and the value is the plugin factory.

Returns
Const reference to std::map with identifier and PluginFactoryBase::Ptr.

◆ getPlugins()

std::vector<rw::core::Ptr<PluginFactory<T> > > getPlugins ( )
inline

Returns all rw::core::PluginFactory<T> instances which matches the template argument T.

Returns
List of all factories matching T

◆ load()

void load ( const std::string &  filename)

Loads in a PluginFactoryBase from a file.

If the file could not be loaded or does not contain an object of type PluginFactoryBase a rw::core::Exception is thrown.

Parameters
filename[in] File to load

◆ loadFilesInFolder()

void loadFilesInFolder ( const std::string &  path,
bool  searchSubFolders 
)

Attempts to load all dll files in folder.

If finding a dll file which can not be loaded or does not contain an object of type PluginFactoryBase a rw::core::Exception is thrown.

Parameters
path[in] Path from which to attempt for load plugins
searchSubFolders[in] True to search recursively into subfolders.

The documentation for this class was generated from the following file: