Ocean
|
This class implements as singleton-based manager which allows to access all available devices. More...
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. More... | |
Public Member Functions | |
DeviceRef | device (const std::string &name, const bool useExclusive=false) |
Returns a specific device. More... | |
DeviceRef | device (const Device::DeviceType type, const bool useExclusive=false) |
Returns a specified device. More... | |
Strings | devices () const |
Returns a list with the names of all available devices. More... | |
Strings | devices (const Device::DeviceType type) const |
Returns a list with the names of all available devices matching a major and minor device type. More... | |
bool | isRegistered (const std::string &library) |
Returns whether a specified library is registered at this manager. More... | |
Strings | libraries () const |
Returns the names of all registered libraries. More... | |
std::string | objectDescription (const Measurement::ObjectId objectId) const |
Returns the description of an object id. More... | |
void | release () |
Destructs all registered libraries and their corresponding factories. More... | |
bool | registerAdhocDevice (const std::string &deviceName, const Device::DeviceType &deviceType, const AdhocInstanceFunction &deviceInstanceFunction) |
Registes an ad-hoc device at this manager. More... | |
bool | unregisterAdhocDevice (const std::string &deviceName) |
Unregisters a previously registered ad-hoc device from this manager. More... | |
Static Public Member Functions | |
static std::string | nameAdhocFactory () |
Returns the name of the ad-hoc factory. More... | |
Static Public Member Functions inherited from Ocean::Singleton< Manager > | |
static Manager & | get () |
Returns a reference to the unique object. More... | |
Protected Types | |
typedef std::vector< std::unique_ptr< Factory > > | FactoryUniquePointers |
Definition of a vector holding unique pointers of factories. More... | |
typedef std::unordered_multimap< Measurement::ObjectId, std::string > | ObjectIdMultimap |
Definition of an unsorted multimap mapping object ids to descriptions. More... | |
Private Member Functions | |
Manager () | |
Creates a new manager object. More... | |
virtual | ~Manager () |
Destructs a manager object. More... | |
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). More... | |
bool | registerFactory (std::unique_ptr< Factory > &&factory) |
Registers a new factory. More... | |
bool | unregisterFactory (const std::string &factory) |
Unregisters a factory. More... | |
Private Attributes | |
ObjectIdMultimap | objectIdMultimap_ |
The map mapping object ids to descriptions. More... | |
Measurement::ObjectId | uniqueObjectIdCounter_ = Measurement::ObjectId(0) |
The counter for unique object ids. More... | |
FactoryUniquePointers | factories_ |
All registered device factories. More... | |
Lock | lock_ |
The Manager's lock. More... | |
Friends | |
class | Singleton< Manager > |
class | Factory |
class | Measurement |
Additional Inherited Members | |
Protected Member Functions inherited from Ocean::Singleton< Manager > | |
Singleton ()=default | |
Default constructor. More... | |
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 |
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 |
|
friend |
|
private |
All registered device factories.
|
private |
The map mapping object ids to descriptions.
|
private |
The counter for unique object ids.