Ocean
Ocean::Devices::DeviceRefManager Class Reference

This class implements a manager for device references. More...

Inheritance diagram for Ocean::Devices::DeviceRefManager:

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, DevicePairDeviceMap
 Map mapping urls to device references. More...
 
typedef Callbacks< DeviceCallbackDeviceCallbacks
 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...
 

Detailed Description

This class implements a manager for device references.

Member Typedef Documentation

◆ DeviceCallback

Definition of a callback function for devices.

◆ DeviceCallbacks

Definition of device callback functions.

◆ DeviceMap

typedef std::multimap<std::string, DevicePair> Ocean::Devices::DeviceRefManager::DeviceMap
protected

Map mapping urls to device references.

◆ DevicePair

typedef std::pair<DeviceRef, bool> Ocean::Devices::DeviceRefManager::DevicePair
protected

Definition of a pair combining a device reference with a state specifying whether the medium is used exclusively.

Constructor & Destructor Documentation

◆ ~DeviceRefManager()

virtual Ocean::Devices::DeviceRefManager::~DeviceRefManager ( )
protectedvirtual

Destructs the manager.

Member Function Documentation

◆ addDeviceCallbackFunction()

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.

Parameters
callbackThe callback function, must be valid

◆ device() [1/2]

DeviceRef Ocean::Devices::DeviceRefManager::device ( const Device::DeviceType  type) const

Returns a specified device by it's device type.

Parameters
typeDevice type
Returns
Requested device

◆ device() [2/2]

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.

Parameters
nameThe name of the new device
Returns
Device reference of the requested device

◆ devicesFromLibrary()

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.

Parameters
libraryThe name of the library to which the devices belong, must be valid
Returns
The names of all currently existing devices

◆ isEmpty() [1/2]

bool Ocean::Devices::DeviceRefManager::isEmpty ( ) const
inline

Returns whether no device is registered currently.

Returns
True, if so

◆ isEmpty() [2/2]

bool Ocean::Devices::DeviceRefManager::isEmpty ( const std::string &  library) const

Returns whether no device is registered created by a specific library.

Parameters
libraryThe name of the library to check, must be valid
Returns
True, if so

◆ isExclusive()

bool Ocean::Devices::DeviceRefManager::isExclusive ( const Device device)
protected

Returns whether a specified device is registered as exclusive.

Parameters
deviceDevice to check
Returns
True, if so

◆ registerDevice()

DeviceRef Ocean::Devices::DeviceRefManager::registerDevice ( Device device,
const bool  exclusive 
)

Registers a new device.

Parameters
deviceDevice object to manage
exclusiveState specifying whether the device will be used exclusively
Returns
Device reference

◆ removeDeviceCallbackFunction()

void Ocean::Devices::DeviceRefManager::removeDeviceCallbackFunction ( const DeviceCallback callback)
inline

Removes a previously added callback function for device events.

Parameters
callbackThe callback function, must be valid

◆ unregisterDevice()

void Ocean::Devices::DeviceRefManager::unregisterDevice ( const Device device)
protected

Unregisters a device.

Friends And Related Function Documentation

◆ Device

friend class Device
friend

◆ Manager

friend class Manager
friend

◆ ObjectRef< Device >

friend class ObjectRef< Device >
friend

◆ Singleton< DeviceRefManager >

friend class Singleton< DeviceRefManager >
friend

Field Documentation

◆ deviceCallbacks_

DeviceCallbacks Ocean::Devices::DeviceRefManager::deviceCallbacks_
protected

The callback functions for device events.

◆ deviceMap_

DeviceMap Ocean::Devices::DeviceRefManager::deviceMap_
protected

Map holding all device references.

◆ lock_

Lock Ocean::Devices::DeviceRefManager::lock_
mutableprotected

Lock for the device map.


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