|
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 |
| Returns a device by a given device name. | |
| DeviceRef | device (const Device::DeviceType type) const |
| Returns a specified device by it's device type. | |
| 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. | |
| std::vector< std::string > | 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 |
| DeviceRef Ocean::Devices::DeviceRefManager::device | ( | const Device::DeviceType | type | ) | const |
| DeviceRef Ocean::Devices::DeviceRefManager::device | ( | const std::string & | name | ) | const |
Returns a device by a given device name.
If the device does not exist an empty reference is returned.
| name | The name of the new device |
| std::vector< std::string > 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.