19#include <condition_variable>
20#include <unordered_set>
21#include <unordered_map>
169 using Mutex = std::mutex;
170 using Lock = std::unique_lock<Mutex>;
171 using Condition = std::condition_variable;
177 void detectDevices();
179 void notifyClientsOfDetection(const
DeviceInfo& deviceInfo);
180 void notifyClientsOfLostDetection(const
DeviceInfo& deviceInfo);
182 void waitForFirstPass(
int seconds);
185 Mutex _detectedDevicesMutex;
189 std::atomic<
bool> _shutdown;
190 std::atomic<
bool> _running;
191 std::atomic<
int> _period;
192 std::unique_ptr<std::thread> _thread;
194 Mutex _firstPassMutex;
195 Condition _firstPassCondition;
196 bool _firstPassComplete;
201 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:32
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:24
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 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 void addClient(EnumerationClient *client)
Adds an observer/client that will be updated if a device detection status changes.
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:207
static OTC_SDK_API EnumerationManager & getInstance() noexcept
Returns an instance of the EnumerationManager.
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 int getDetectionPeriod() const noexcept
Returns the minimum period in milliseconds for a single connection event detection run.
Definition EnumerationManager.h:212
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 void registerDetector(const std::string &name, std::shared_ptr< EnumerationDetector > detector)
Registers a new detector for connected devices.
OTC_SDK_API std::vector< DeviceInfo > getDetectedDevices(int seconds=0)
Returns information about the currently detected devices.
Main SDK namespace.
Definition DeviceInfo.h:23