18#include <condition_variable>
19#include <unordered_set>
20#include <unordered_map>
264 friend class DeviceClaimService;
267 using Mutex = std::mutex;
268 using RecursiveMutex = std::recursive_mutex;
269 using Lock = std::unique_lock<Mutex>;
270 using RecursiveLock = std::unique_lock<RecursiveMutex>;
271 using ScopedLock = std::scoped_lock<RecursiveMutex, RecursiveMutex>;
272 using Condition = std::condition_variable;
278 void detectDevices();
279 void debounceLostDetections(std::vector<
DeviceInfo>& currentlyDetected);
283 void notifyClientsOfDetection(const
DeviceInfo& deviceInfo);
284 void notifyClientsOfLostDetection(const
DeviceInfo& deviceInfo);
285 void notifyClientsOfChangedDetection(const
DeviceInfo& deviceInfo);
287 void waitForDetectionUpdate(
int seconds);
288 void notifyOfDetectionUpdate();
290 void setDeviceBusy(
unsigned long serialNumber, const std::
string& connectionInterface,
bool busy);
293 RecursiveMutex _detectedDevicesMutex;
300 std::unique_ptr<std::thread> _runThread;
302 Mutex _runThreadMutex;
303 Condition _runThreadCondition;
304 std::atomic<
bool> _runThreadActive;
307 std::atomic<
bool> _running;
309 std::atomic<
bool> _actuallyRunning;
311 std::atomic<
int> _period;
314 Mutex _waitForDetectionUpdateMutex;
315 Condition _waitForDetectionUpdateCondition;
316 bool _waitForDetectionUpdateComplete;
318 Mutex _waitForDetectionUpdateConditionsMutex;
319 bool _newDetectorAdded;
321 RecursiveMutex _clientsMutex;
324 Mutex _detectorsMutex;
Contains defines controlling the Windows DLL export and import of symbols.
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
Detects and monitors available devices.
Definition EnumerationManager.h:43
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:330
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:335
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