19#include <condition_variable>
20#include <unordered_set>
21#include <unordered_map>
265 using Mutex = std::mutex;
266 using Lock = std::unique_lock<Mutex>;
267 using Condition = std::condition_variable;
273 void detectDevices();
275 void notifyClientsOfDetection(const
DeviceInfo& deviceInfo);
276 void notifyClientsOfLostDetection(const
DeviceInfo& deviceInfo);
277 void notifyClientsOfChangedDetection(const
DeviceInfo& deviceInfo);
279 void waitForDetectionUpdate(
int seconds);
280 void notifyOfDetectionUpdate();
283 Mutex _detectedDevicesMutex;
287 std::atomic<
bool> _shutdown;
288 std::atomic<
bool> _running;
289 std::atomic<
int> _period;
290 std::unique_ptr<std::thread> _thread;
292 Mutex _waitForDetectionUpdateMutex;
293 Condition _waitForDetectionUpdateCondition;
294 bool _waitForDetectionUpdateComplete;
296 Mutex _waitForDetectionUpdateConditionsMutex;
297 bool _newDetectorAdded;
302 Mutex _detectorsMutex;
Contains defines controlling the Windows DLL export and import of symbols.
#define OTC_SDK_API
Only needed when working with Windows DLLs.
Definition Api.h:65
Contains a class encapsulating important information about devices.
Contains the interface definition for classes that wish to be updated about the detection of availabl...
Contains the interface definition for classes detecting available devices.
Holds important information about a device.
Definition DeviceInfo.h:33
Defines the interface for classes that want to be updated about the detection of available devices.
Definition EnumerationClient.h:25
Common interface for classes detecting available devices.
Definition EnumerationDetector.h:23
OTC_SDK_API std::vector< std::string > getDetectorNames()
Returns the names of all added detectors.
OTC_SDK_API EnumerationManager & operator=(EnumerationManager &&)=delete
No move assignment.
OTC_SDK_API bool removeClient(EnumerationClient *client)
Removes the given observer/client.
OTC_SDK_API bool runAsync()
Runs the connection event detection continuously in a dedicated thread.
OTC_SDK_API std::string addUsbDetector()
Adds a detector for USB devices.
OTC_SDK_API std::string addDetector(const std::string &name, std::shared_ptr< EnumerationDetector > detector)
Adds a new detector for connected devices.
OTC_SDK_API void clearDetectors()
Clears all added detectors.
OTC_SDK_API EnumerationManager & operator=(const EnumerationManager &)=delete
No copy assignment.
OTC_SDK_API void run()
Runs the connection event detection continuously.
virtual OTC_SDK_API ~EnumerationManager()
Destructor.
OTC_SDK_API bool removeEthernetDetector(const std::string &networkAddress)
Remove the Ethernet detector for the specified network.
OTC_SDK_API void addClient(EnumerationClient *client)
Adds an observer/client that will be updated if a device detection status changes.
OTC_SDK_API bool removeDetector(const std::string &name)
Removes the detector with the given name.
OTC_SDK_API void stopRunning()
Stops the continuous connection event detection.
OTC_SDK_API void setDetectionPeriod(int period) noexcept
Sets the minimum period in milliseconds for a single connection event detection run.
Definition EnumerationManager.h:308
OTC_SDK_API std::shared_ptr< EnumerationDetector > getDetector(const std::string &name)
Return the detector registered under the given name.
OTC_SDK_API EnumerationManager(const EnumerationManager &)=delete
No copy constructor.
OTC_SDK_API bool removeUsbDetector()
Removes the detector for USB devices.
static OTC_SDK_API EnumerationManager & getInstance()
Returns an instance of the EnumerationManager.
OTC_SDK_API int getDetectionPeriod() const noexcept
Returns the minimum period in milliseconds for a single connection event detection run.
Definition EnumerationManager.h:313
OTC_SDK_API bool isRunning() const noexcept
Returns whether the connection event detection is running.
OTC_SDK_API EnumerationManager(EnumerationManager &&)=delete
No move constructor.
OTC_SDK_API std::vector< DeviceInfo > getDetectedDevices(int seconds=0)
Returns information about the currently detected devices.
OTC_SDK_API std::string addEthernetDetector(const std::string &networkAddress)
Adds a detector for Ethernet devices in the specified network.
Encapsulates an IP v4 address.
Definition IpAddress.h:33
Main SDK namespace.
Definition DeviceInfo.h:24