RobWorkProject  23.9.11-
Public Types | Public Member Functions | List of all members
PluginFactory< T > Class Template Reference

Template class form which to inherit when creating a factory for a plugin. More...

#include <PluginFactory.hpp>

Inherits PluginFactoryBase.

Public Types

typedef rw::core::Ptr< PluginFactory< T > > Ptr
 Smart pointer type for PluginFactory.
 
- Public Types inherited from PluginFactoryBase
typedef rw::core::Ptr< PluginFactoryBasePtr
 smart pointer for this class
 

Public Member Functions

 PluginFactory (const std::string &identifier)
 Constructs a PluginFactory. More...
 
virtual rw::core::Ptr< T > make ()
 Creates plugin of type T by calling default constructor. More...
 
virtual rw::core::Ptr< T > make (const std::string &)
 Creates plugin of type T by calling constructor with std::string. More...
 
- Public Member Functions inherited from PluginFactoryBase
 PluginFactoryBase (const std::string &identifier)
 Constructor. More...
 
virtual ~PluginFactoryBase (void)
 Destructor.
 
virtual std::string identifier () const
 Returns identifier associated with the PluginFactory. More...
 

Detailed Description

template<class T>
class rw::plugin::PluginFactory< T >

Template class form which to inherit when creating a factory for a plugin.

Example: If we wish to create a new type of rw::models::Device the following steps are needed. 1) Implement you device "MyDevice" which should inherit from rw::models::Device.

2) Create a Factory (lets call it MyDeviceFactory) which inherits from PluginFactory<T> and specifies T=rw::models::Device. It is important to specify T=rw::models::Device and NOT MyDevice as the PluginRepository can otherwise not identify it as a factory for creating a device.

3) Override the relevant "make" methods from PluginFactory<T> to provide a way of creating instances of MyDevice. Which methods to override depends on how and where you wish to use your plugin. See the documentation of the different methods.

4) Call DLL_FACTORY_METHOD(MyDeviceFactory) to create a proper entry in the dynamic library. Make sure that MyDeviceFactory has a default constructor.

Constructor & Destructor Documentation

◆ PluginFactory()

PluginFactory ( const std::string &  identifier)
inline

Constructs a PluginFactory.

Parameters
identifier[in] Identifiers of the PluginFactory

Member Function Documentation

◆ make() [1/2]

virtual rw::core::Ptr<T> make ( )
inlinevirtual

Creates plugin of type T by calling default constructor.

If method is not overridden an exception is thrown.

Returns
Pointer with ownership to new plugin instance.

◆ make() [2/2]

virtual rw::core::Ptr<T> make ( const std::string &  )
inlinevirtual

Creates plugin of type T by calling constructor with std::string.

If method is not overridden an exception is thrown.

Returns
Pointer with ownership to new plugin instance.

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