|
Ocean
|
This class implements a factory able to create instances of devices. More...
#include <Factory.h>
Data Structures | |
| class | DeviceDescriptor |
| This class stores information to describe and to creator a device. More... | |
Public Member Functions | |
| const std::string & | name () const |
| Returns the name of this factory. | |
Protected Types | |
| using | InstanceFunction = Callback< Device *, const std::string &, const Device::DeviceType & > |
| Definition of a callback function creating a specific device. | |
| using | DeviceDescriptors = std::vector< DeviceDescriptor > |
| Definition of a vector holding device descriptor objects. | |
Protected Member Functions | |
| Factory (const Factory &factory)=delete | |
| Disabled copy constructor. | |
| Factory (const std::string &name) | |
| Creates a new factory. | |
| virtual | ~Factory () |
| Destructs this factory. | |
| virtual Strings | devices () const |
| Returns a list of available devices. | |
| virtual Strings | devices (const Device::DeviceType type) const |
| Returns a list of available devices matching a specified major device type. | |
| virtual Device::DeviceType | deviceType (const std::string &device) const |
| Returns the type of a specified device. | |
| virtual DeviceRef | device (const std::string &name, const bool useExclusive=false) const |
| Creates a new device by its name or returns an existing one if an exclusive use is not necessary. | |
| virtual DeviceRef | device (const Device::DeviceType type, const bool useExclusive=false) |
| Creates a new device defined by a major and a minor device type or returns an existing one if an exclusive use is not necessary. | |
| DeviceRef | adapterDevice (const Device::DeviceType type, const std::string &name) |
| Returns a new adapter measurement device, which is exclusive always. | |
| Factory & | operator= (const Factory &factory)=delete |
| Disabled copy operator. | |
| bool | registerDevice (const std::string &deviceName, const Device::DeviceType deviceType, const InstanceFunction &deviceInstanceFunction, const unsigned int priority=100u) |
| Registes a device at this factory. | |
| bool | unregisterDevice (const std::string &deviceName) |
| Unregisters a previously registered device from this factory. | |
Static Protected Member Functions | |
| static bool | registerFactory (std::unique_ptr< Factory > &&factory) |
| Registers a factory at the manager. | |
| static bool | unregisterFactory (const std::string &factory) |
| Unregisters a factory at the manager. | |
| static DeviceRef | createDevice (const DeviceDescriptor &deviceDescriptor, bool useExclusive) |
| Creates a new device by a given device triple. | |
| static Factory * | factory (const std::string &name, TemporaryScopedLock &scopedLock) |
| Returns a specified factory. | |
Private Attributes | |
| std::string | name_ |
| The factory's name. | |
| DeviceDescriptors | deviceDescriptors_ |
| Vector holding all registered devices with name and type. | |
| Lock | lock_ |
| Factory lock. | |
Friends | |
| class | Manager |
| struct | std::default_delete< Factory > |
This class implements a factory able to create instances of devices.
|
protected |
Definition of a vector holding device descriptor objects.
|
protected |
Definition of a callback function creating a specific device.
|
protecteddelete |
Disabled copy constructor.
| factory | Object which would be copied |
|
explicitprotected |
Creates a new factory.
| name | The name of the factory to create |
|
protectedvirtual |
Destructs this factory.
|
protected |
Returns a new adapter measurement device, which is exclusive always.
| type | Type of the device to return |
| name | Unique name of the resulting adapter device, this name will be assigned to the new adapter device |
|
staticprotected |
Creates a new device by a given device triple.
| deviceDescriptor | The descriptor of the device to be created |
| useExclusive | Determines whether the device will be used exclusively |
|
protectedvirtual |
Creates a new device defined by a major and a minor device type or returns an existing one if an exclusive use is not necessary.
| type | Type of the device to return |
| useExclusive | Determines whether the device will be used exclusively |
|
protectedvirtual |
Creates a new device by its name or returns an existing one if an exclusive use is not necessary.
| name | The name of the device to create |
| useExclusive | Determines whether the device will be used exclusively |
|
protectedvirtual |
Returns a list of available devices.
|
protectedvirtual |
Returns a list of available devices matching a specified major device type.
| type | Type to return device names for |
|
protectedvirtual |
Returns the type of a specified device.
| device | Name of the device to return the type for |
|
staticprotected |
Returns a specified factory.
| name | The name of the factory to return, must be valid |
| scopedLock | The scoped lock which will be used to lock access the access to the factor, needs to be released as soon as possible |
|
inline |
Returns the name of this factory.
Disabled copy operator.
| factory | Object which would be copied |
|
protected |
Registes a device at this factory.
| deviceName | Unique name of the device to register |
| deviceType | Type of the device |
| deviceInstanceFunction | Function creating an instance of the device |
| priority | The priority of the device, in case two devices are equivalent, the device with the higher priority will be used |
|
staticprotected |
Registers a factory at the manager.
Each factory should be registered at most once.
| factory | The factory to register |
|
protected |
Unregisters a previously registered device from this factory.
Beware: Ensure that the device is not used anymore before unregistering it.
| deviceName | The name of the device to unregister, must be valid |
|
staticprotected |
Unregisters a factory at the manager.
Beware: All devices created by the factory must be released before,
otherwise the factory cannot be unregistered.
| factory | Name of the factory to unregister |
|
private |
Vector holding all registered devices with name and type.
|
private |
The factory's name.