Detects and monitors available devices.
More...
#include <EnumerationManager.h>
Detects and monitors available devices.
It detects devices that the SDK can potentially connect to.
This class is implemented with the help of the Singleton design pattern. As a consequence, you have to use the EnumerationManager::getInstance() method to interact with it.
Furthermore, allows the registration of observers aka. EnumerationClient that want be informed if the detection status of a device changes.
◆ addClient()
Adds an observer/client that will be updated if a device detection status changes.
- Parameters
-
| [in] | client | callback client. |
◆ addDetector()
Adds a new detector for connected devices.
- Parameters
-
| [in] | name | under which to register the detector. If an empty string is provided, no detector will be added. |
| [in] | detector | to register. |
- Returns
- name of the added detector or an empty string if adding the detector failed or if a detector with the same name was already added.
◆ addEthernetDetector() [1/2]
| OTC_SDK_API std::string optris::EnumerationManager::addEthernetDetector |
( |
const IpAddress & | networkAddress, |
|
|
int | cidr ) |
Adds a detector for Ethernet devices in the specified network.
- Parameters
-
| [in] | networkAddress | IP address of the network. Its host portion will be ignored. |
| [in] | cidr | number of bits that constitute the network portion of the provided IP address. It is a shorthand for the subnet mask. Its value, typically, equals the number of 1 bits in the subnet mask. |
- Returns
- name of the added detector. It is "<network address in CIDR notation>" (e.g. 192.168.0.0/24), if the detector was added successfully. An empty string, if adding the detector failed or if a detector for this network was already added.
◆ addEthernetDetector() [2/2]
| OTC_SDK_API std::string optris::EnumerationManager::addEthernetDetector |
( |
const std::string & | networkAddress | ) |
|
Adds a detector for Ethernet devices in the specified network.
- Parameters
-
| [in] | networkAddress | in CIDR notation: a.b.c.d/cider with a.b.c.d as the network IP address and cidr as the number of bits that constitute the network portion of the IP address. It is a shorthand for the subnet mask. Its value, typically, equals the number of 1 bits in the subnet mask. |
- Returns
- name of the added detector. It is "<network address in CIDR notation>" (e.g. 192.168.0.0/24), if the detector was added successfully. An empty string, if the provided network address could not be parsed or if adding the detector failed or if a detector for this network was already added.
◆ addUsbDetector()
| OTC_SDK_API std::string optris::EnumerationManager::addUsbDetector |
( |
| ) |
|
Adds a detector for USB devices.
- Returns
- name of the added detector. It is "usb", if the detector was added successfully. An empty string, if adding the detector failed or if a USB detector was already added.
◆ getDetectedDevices()
Returns information about the currently detected devices.
- Note
- This method will never wait, if the EnumerationManger is not running. In this way clients can not unexpectedly get stuck in this method.
- Parameters
-
| [in] | seconds | < 0 the method waits indefintfly for the first detection pass to complete. == 0 the method will not wait. > 0 the method waits the given amount of seconds for th first detection pass to complete. |
- Returns
- a vector holding the currently detected devices.
◆ getDetectionPeriod()
| int optris::EnumerationManager::getDetectionPeriod |
( |
| ) |
const |
|
inlinenoexcept |
Returns the minimum period in milliseconds for a single connection event detection run.
- Returns
- minimum period in milliseconds for a single connection event detection run.
◆ getDetector()
Return the detector registered under the given name.
- Parameters
-
| [in] | name | of the desired detector. |
- Returns
- shared pointer to the detector or a nullptr if a detector with the given name is not registered.
◆ getDetectorNames()
| OTC_SDK_API std::vector< std::string > optris::EnumerationManager::getDetectorNames |
( |
| ) |
|
Returns the names of all added detectors.
- Returns
- names of all added detectors.
◆ getInstance()
◆ isRunning()
| OTC_SDK_API bool optris::EnumerationManager::isRunning |
( |
| ) |
const |
|
noexcept |
Returns whether the connection event detection is running.
- Returns
- whether the connection event detection is running.
◆ removeClient()
Removes the given observer/client.
- Parameters
-
◆ removeDetector()
| OTC_SDK_API bool optris::EnumerationManager::removeDetector |
( |
const std::string & | name | ) |
|
Removes the detector with the given name.
- Parameters
-
| [in] | name | of the detector to remove. |
- Returns
- true, if a detector with the given name was removed. False otherwise.
◆ removeEthernetDetector() [1/2]
| OTC_SDK_API bool optris::EnumerationManager::removeEthernetDetector |
( |
const IpAddress & | networkAddress, |
|
|
int | cidr ) |
Remove the Ethernet detector for the specified network.
- Parameters
-
| [in] | networkAddress | IP address of the network. Its host portion will be ignored. |
| [in] | cidr | number of bits that constitute the network portion of the provided IP address. It is a shorthand for the subnet mask. Its value, typically, equals the number of 1 bits in the subnet mask. |
- Returns
- true, if an exiting detector was removed. False otherwise.
◆ removeEthernetDetector() [2/2]
| OTC_SDK_API bool optris::EnumerationManager::removeEthernetDetector |
( |
const std::string & | networkAddress | ) |
|
Remove the Ethernet detector for the specified network.
- Parameters
-
| [in] | networkAddress | in CIDR notation: a.b.c.d/cider with a.b.c.d as the network IP address and cidr as the number of bits that constitute the network portion of the IP address. It is a shorthand for the subnet mask. Its value, typically, equals the number of 1 bits in the subnet mask. |
- Returns
- true, if an exiting detector was removed. False if no detector for the given network existed or if the provided network address could not be parsed.
◆ removeUsbDetector()
| OTC_SDK_API bool optris::EnumerationManager::removeUsbDetector |
( |
| ) |
|
Removes the detector for USB devices.
- Returns
- true, if an existing detector was removed. False otherwise.
◆ run()
Runs the connection event detection continuously.
This method blocks until stopRunning() is called from a different thread or until the program terminates.
- See also
- stopRunning()
◆ runAsync()
| OTC_SDK_API bool optris::EnumerationManager::runAsync |
( |
| ) |
|
Runs the connection event detection continuously in a dedicated thread.
This method runs until stopRunning() is called from a different thread or until the program terminates.
- Note
- All callback methods of a registered EnumerationClient are called from this detection thread.
- Returns
- true if the thread started within a second. False otherwise.
- See also
- stopRunning()
◆ setDetectionPeriod()
| void optris::EnumerationManager::setDetectionPeriod |
( |
int | period | ) |
|
|
inlinenoexcept |
Sets the minimum period in milliseconds for a single connection event detection run.
- Parameters
-
| [in] | period | in milliseconds to set. |
◆ stopRunning()
| OTC_SDK_API void optris::EnumerationManager::stopRunning |
( |
| ) |
|
Stops the continuous connection event detection.
This does not clear the list of currently detected devices.
The documentation for this class was generated from the following file: