|
Ocean
|
This class implements as singleton-based manager which allows to access all available devices. More...
#include <Manager.h>
Data Structures | |
| class | AdhocFactory |
| This class implements an ad-hoc factory for devices which are implemented outside of an own library e.g., during rapid prototyping. More... | |
Public Types | |
| using | AdhocInstanceFunction = Factory::InstanceFunction |
| Definition of a callback function creating an ad-hoc device. | |
Public Member Functions | |
| DeviceRef | device (const std::string &name, const bool useExclusive=false) |
| Returns a specific device. | |
| DeviceRef | device (const Device::DeviceType type, const bool useExclusive=false) |
| Returns a specified device. | |
| Strings | devices () const |
| Returns a list with the names of all available devices. | |
| Strings | devices (const Device::DeviceType type) const |
| Returns a list with the names of all available devices matching a major and minor device type. | |
| bool | isRegistered (const std::string &library) |
| Returns whether a specified library is registered at this manager. | |
| Strings | libraries () const |
| Returns the names of all registered libraries. | |
| std::string | objectDescription (const Measurement::ObjectId objectId) const |
| Returns the description of an object id. | |
| void | release () |
| Destructs all registered libraries and their corresponding factories. | |
| bool | registerAdhocDevice (const std::string &deviceName, const Device::DeviceType &deviceType, const AdhocInstanceFunction &deviceInstanceFunction) |
| Registes an ad-hoc device at this manager. | |
| bool | unregisterAdhocDevice (const std::string &deviceName) |
| Unregisters a previously registered ad-hoc device from this manager. | |
Static Public Member Functions | |
| static std::string | nameAdhocFactory () |
| Returns the name of the ad-hoc factory. | |
Static Public Member Functions inherited from Ocean::Singleton< Manager > | |
| static Manager & | get () |
| Returns a reference to the unique object. | |
Protected Types | |
| typedef std::vector< std::unique_ptr< Factory > > | FactoryUniquePointers |
| Definition of a vector holding unique pointers of factories. | |
| typedef std::unordered_multimap< Measurement::ObjectId, std::string > | ObjectIdMultimap |
| Definition of an unsorted multimap mapping object ids to descriptions. | |
Private Member Functions | |
| Manager () | |
| Creates a new manager object. | |
| virtual | ~Manager () |
| Destructs a manager object. | |
| Measurement::ObjectId | createUniqueObjectId (const std::string &description) |
| Creates a unique object id for a new object (e.g., a tracking object like an image, a marker, or a location). | |
| bool | registerFactory (std::unique_ptr< Factory > &&factory) |
| Registers a new factory. | |
| bool | unregisterFactory (const std::string &factory) |
| Unregisters a factory. | |
| Factory * | factory (const std::string &name, TemporaryScopedLock &scopedLock) |
| Returns a specified factory. | |
Private Attributes | |
| ObjectIdMultimap | objectIdMultimap_ |
| The map mapping object ids to descriptions. | |
| Measurement::ObjectId | uniqueObjectIdCounter_ = Measurement::ObjectId(0) |
| The counter for unique object ids. | |
| FactoryUniquePointers | factories_ |
| All registered device factories. | |
| Lock | lock_ |
| The Manager's lock. | |
Friends | |
| class | Singleton< Manager > |
| class | Factory |
| class | Measurement |
Additional Inherited Members | |
Protected Member Functions inherited from Ocean::Singleton< Manager > | |
| Singleton ()=default | |
| Default constructor. | |
This class implements as singleton-based manager which allows to access all available devices.
Definition of a callback function creating an ad-hoc device.
|
protected |
Definition of a vector holding unique pointers of factories.
|
protected |
Definition of an unsorted multimap mapping object ids to descriptions.
|
private |
Creates a new manager object.
|
privatevirtual |
Destructs a manager object.
|
private |
Creates a unique object id for a new object (e.g., a tracking object like an image, a marker, or a location).
| description | The description of the new object, must be valid |
| DeviceRef Ocean::Devices::Manager::device | ( | const Device::DeviceType | type, |
| const bool | useExclusive = false |
||
| ) |
Returns a specified device.
| type | The major type of the device to return |
| useExclusive | True, if the caller would like to use this device exclusively; False, if the device can be shared |
| DeviceRef Ocean::Devices::Manager::device | ( | const std::string & | name, |
| const bool | useExclusive = false |
||
| ) |
Returns a specific device.
| name | The name of the device to return, must be valid |
| useExclusive | True, if the caller would like to use this device exclusively; False, if the device can be shared |
| Strings Ocean::Devices::Manager::devices | ( | ) | const |
Returns a list with the names of all available devices.
| Strings Ocean::Devices::Manager::devices | ( | const Device::DeviceType | type | ) | const |
Returns a list with the names of all available devices matching a major and minor device type.
| type | Type of the device to return |
|
private |
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 |
| bool Ocean::Devices::Manager::isRegistered | ( | const std::string & | library | ) |
Returns whether a specified library is registered at this manager.
| library | Name of the library to check |
| Strings Ocean::Devices::Manager::libraries | ( | ) | const |
Returns the names of all registered libraries.
|
static |
Returns the name of the ad-hoc factory.
The ad-hoc factory is for devices which are implemented outside of an own library e.g., during rapid prototyping.
| std::string Ocean::Devices::Manager::objectDescription | ( | const Measurement::ObjectId | objectId | ) | const |
Returns the description of an object id.
| objectId | The object id for which the description will be returned |
| bool Ocean::Devices::Manager::registerAdhocDevice | ( | const std::string & | deviceName, |
| const Device::DeviceType & | deviceType, | ||
| const AdhocInstanceFunction & | deviceInstanceFunction | ||
| ) |
Registes an ad-hoc device at this manager.
In general, devices should be implemented in an own decicated plugin-based library. However, for prototyping an ad-hoc device cames with the same features as a device implemented in a dedicatd library without the overhead of writing the code for the plugin mechanisms etc.
| deviceName | Unique name of the device to register |
| deviceType | Type of the device |
| deviceInstanceFunction | Function creating an instance of the device |
|
private |
Registers a new factory.
| factory | The factory to register |
| void Ocean::Devices::Manager::release | ( | ) |
Destructs all registered libraries and their corresponding factories.
| bool Ocean::Devices::Manager::unregisterAdhocDevice | ( | const std::string & | deviceName | ) |
Unregisters a previously registered ad-hoc device from this manager.
Beware: Ensure that the device is not used anymore before unregistering it.
| deviceName | The name of the device to unregister, must be valid |
|
private |
Unregisters a factory.
| factory | Name of the factory to unregister |
|
friend |
|
private |
All registered device factories.
|
private |
The map mapping object ids to descriptions.
|
private |
The counter for unique object ids.