Ocean
|
This class implements a manager for device references. More...
Public Types | |
typedef Callback< void, Device *, bool > | DeviceCallback |
Definition of a callback function for devices. More... | |
Public Member Functions | |
DeviceRef | registerDevice (Device *device, const bool exclusive) |
Registers a new device. More... | |
DeviceRef | device (const std::string &name) const |
Returns a device by a given device name. More... | |
DeviceRef | device (const Device::DeviceType type) const |
Returns a specified device by it's device type. More... | |
bool | isEmpty () const |
Returns whether no device is registered currently. More... | |
bool | isEmpty (const std::string &library) const |
Returns whether no device is registered created by a specific library. More... | |
std::vector< std::string > | devicesFromLibrary (const std::string &library) const |
Returns the name of all existing devices which belong to a specific library. More... | |
void | addDeviceCallbackFunction (const DeviceCallback &callback) |
Adds a callback function which is called whenever a new device is created or deleted. More... | |
void | removeDeviceCallbackFunction (const DeviceCallback &callback) |
Removes a previously added callback function for device events. More... | |
Protected Types | |
typedef std::pair< DeviceRef, bool > | DevicePair |
Definition of a pair combining a device reference with a state specifying whether the medium is used exclusively. More... | |
typedef std::multimap< std::string, DevicePair > | DeviceMap |
Map mapping urls to device references. More... | |
typedef Callbacks< DeviceCallback > | DeviceCallbacks |
Definition of device callback functions. More... | |
Protected Member Functions | |
virtual | ~DeviceRefManager () |
Destructs the manager. More... | |
bool | isExclusive (const Device *device) |
Returns whether a specified device is registered as exclusive. More... | |
void | unregisterDevice (const Device *device) |
Unregisters a device. More... | |
Protected Member Functions inherited from Ocean::Singleton< DeviceRefManager > | |
Singleton ()=default | |
Default constructor. More... | |
Protected Attributes | |
DeviceMap | deviceMap_ |
Map holding all device references. More... | |
DeviceCallbacks | deviceCallbacks_ |
The callback functions for device events. More... | |
Lock | lock_ |
Lock for the device map. More... | |
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. More... | |
This class implements a manager for device references.
typedef Callback<void, Device*, bool> Ocean::Devices::DeviceRefManager::DeviceCallback |
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 |
|
friend |
|
friend |
|
protected |
The callback functions for device events.
|
protected |
Map holding all device references.