|
Ocean
|
This class implements a manager for device references. More...
#include <DeviceRef.h>
Public Types | |
| using | DeviceCallback = Callback< void, Device *, bool > |
| Definition of a callback function for devices. | |
Public Member Functions | |
| DeviceRef | registerDevice (Device *device, const bool exclusive) |
| Registers a new device. | |
| DeviceRef | device (const std::string &name, const bool allowExclusive=true) const |
| Returns a device by a given device name. | |
| DeviceRef | device (const Device::DeviceType type, const bool exactMatch=false) const |
| Returns a specified device by it's device type. | |
| DeviceRef | device (const Device *device) const |
| Returns the reference of a specific device. | |
| bool | isEmpty () const |
| Returns whether no device is registered currently. | |
| bool | isEmpty (const std::string &library) const |
| Returns whether no device is registered created by a specific library. | |
| Strings | devicesFromLibrary (const std::string &library) const |
| Returns the name of all existing devices which belong to a specific library. | |
| void | addDeviceCallbackFunction (const DeviceCallback &callback) |
| Adds a callback function which is called whenever a new device is created or deleted. | |
| void | removeDeviceCallbackFunction (const DeviceCallback &callback) |
| Removes a previously added callback function for device events. | |
Protected Types | |
| using | DevicePair = std::pair< DeviceRef, bool > |
| Definition of a pair combining a device reference with a state specifying whether the medium is used exclusively. | |
| using | DeviceMap = std::multimap< std::string, DevicePair > |
| Map mapping urls to device references. | |
| using | DeviceCallbacks = Callbacks< DeviceCallback > |
| Definition of device callback functions. | |
Protected Member Functions | |
| virtual | ~DeviceRefManager () |
| Destructs the manager. | |
| bool | isExclusive (const Device *device) |
| Returns whether a specified device is registered as exclusive. | |
| void | unregisterDevice (const Device *device) |
| Unregisters a device. | |
Protected Member Functions inherited from Ocean::Singleton< DeviceRefManager > | |
| Singleton ()=default | |
| Default constructor. | |
Protected Attributes | |
| DeviceMap | deviceMap_ |
| Map holding all device references. | |
| DeviceCallbacks | deviceCallbacks_ |
| The callback functions for device events. | |
| Lock | lock_ |
| Lock for the device map. | |
Friends | |
| class | Device |
| class | Singleton< DeviceRefManager > |
| class | ObjectRef< Device > |
| class | Manager |
Additional Inherited Members | |
Static Public Member Functions inherited from Ocean::Singleton< DeviceRefManager > | |
| static DeviceRefManager & | get () |
| Returns a reference to the unique object. | |
This class implements a manager for device references.
| using Ocean::Devices::DeviceRefManager::DeviceCallback = Callback<void, Device*, bool> |
Definition of a callback function for devices.
|
protected |
Definition of device callback functions.
|
protected |
Map mapping urls to device references.
|
protected |
Definition of a pair combining a device reference with a state specifying whether the medium is used exclusively.
|
protectedvirtual |
Destructs the manager.
| void Ocean::Devices::DeviceRefManager::addDeviceCallbackFunction | ( | const DeviceCallback & | callback | ) |
Adds a callback function which is called whenever a new device is created or deleted.
The callback function will be called immediately for all already existing devices.
| callback | The callback function, must be valid |
Returns the reference of a specific device.
In contrast to the name-based lookup, this function identifies the device by its address, so it also works if several devices share the same name.
| device | The device for which the reference will be returned, must be valid |
| DeviceRef Ocean::Devices::DeviceRefManager::device | ( | const Device::DeviceType | type, |
| const bool | exactMatch = false |
||
| ) | const |
Returns a specified device by it's device type.
Devices which have been created for exclusive usage are skipped, and if several of the remaining devices match it is not defined which of them is returned.
| type | The type of the device to return |
| exactMatch | True, to return a device with exact matching type; False, if the requested type is part of the device |
| DeviceRef Ocean::Devices::DeviceRefManager::device | ( | const std::string & | name, |
| const bool | allowExclusive = true |
||
| ) | const |
Returns a device by a given device name.
If the device does not exist an empty reference is returned. Several devices can be registered with the same name, in that case it is not defined which of them is returned.
| name | The name of the device |
| allowExclusive | True, to also return a device which has been created for exclusive usage; False, to return a shareable device only |
| Strings Ocean::Devices::DeviceRefManager::devicesFromLibrary | ( | const std::string & | library | ) | const |
Returns the name of all existing devices which belong to a specific library.
| library | The name of the library to which the devices belong, must be valid |
|
inline |
Returns whether no device is registered currently.
| bool Ocean::Devices::DeviceRefManager::isEmpty | ( | const std::string & | library | ) | const |
Returns whether no device is registered created by a specific library.
| library | The name of the library to check, must be valid |
|
protected |
Returns whether a specified device is registered as exclusive.
| device | Device to check |
|
inline |
Removes a previously added callback function for device events.
| callback | The callback function, must be valid |
|
protected |
Unregisters a device.
|
friend |
|
protected |
The callback functions for device events.
|
protected |
Map holding all device references.