18#include <condition_variable>
19#include <unordered_set>
20#include <unordered_map>
264 friend class DeviceClaimService;
267 using Mutex = std::mutex;
268 using Lock = std::unique_lock<Mutex>;
269 using ScopedLock = std::scoped_lock<Mutex, Mutex>;
270 using Condition = std::condition_variable;
276 void detectDevices();
277 void debounceLostDetections(std::vector<
DeviceInfo>& currentlyDetected);
281 void notifyClientsOfDetection(const
DeviceInfo& deviceInfo);
282 void notifyClientsOfLostDetection(const
DeviceInfo& deviceInfo);
283 void notifyClientsOfChangedDetection(const
DeviceInfo& deviceInfo);
285 void waitForDetectionUpdate(
int seconds);
286 void notifyOfDetectionUpdate();
288 void setDeviceBusy(
unsigned long serialNumber, const std::
string& connectionInterface,
bool busy);
291 Mutex _detectedDevicesMutex;
298 std::unique_ptr<std::thread> _runThread;
300 Mutex _runThreadMutex;
301 Condition _runThreadCondition;
302 std::atomic<
bool> _runThreadActive;
305 std::atomic<
bool> _running;
307 std::atomic<
bool> _actuallyRunning;
309 std::atomic<
int> _period;
312 Mutex _waitForDetectionUpdateMutex;
313 Condition _waitForDetectionUpdateCondition;
314 bool _waitForDetectionUpdateComplete;
316 Mutex _waitForDetectionUpdateConditionsMutex;
317 bool _newDetectorAdded;
322 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 base class for all clients observing the EnumerationManager.
Contains the interface definition for classes detecting available devices.
Holds important information about a device.
Definition DeviceInfo.h:33
Base class for all clients observing the EnumerationManager.
Definition EnumerationClient.h:21
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 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 void run()
Runs the connection event detection continuously.
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.
EnumerationManager & operator=(EnumerationManager &&)=delete
No move assignment.
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:328
EnumerationManager(EnumerationManager &&)=delete
No move constructor.
EnumerationManager & operator=(const EnumerationManager &)=delete
No copy assignment.
OTC_SDK_API std::shared_ptr< EnumerationDetector > getDetector(const std::string &name)
Return the detector registered under the given name.
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:333
OTC_SDK_API bool isRunning() const noexcept
Returns whether the connection event detection is running.
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 AlarmChannel.h:21