OptrisOptrisDocumentation

Documentation/OTC SDK/OTC SDK — legacy C++ API referencev12.0

These are the pre-v12 classes, kept so existing code keeps building. New code should use the modern API — see Migration Guide: v11 to v12.

optris::EnumerationManager

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.

Public static functions

getInstance

static OTC_SDK_API EnumerationManager & getInstance()

Returns an instance of the EnumerationManager. Only one instance per program is available (Singleton).

Returns: EnumerationManager instance.

Public functions

EnumerationManager

EnumerationManager(const EnumerationManager &)=delete

No copy constructor.

operator=

EnumerationManager & operator=(const EnumerationManager &)=delete

No copy assignment.

EnumerationManager

EnumerationManager(EnumerationManager &&)=delete

No move constructor.

operator=

EnumerationManager & operator=(EnumerationManager &&)=delete

No move assignment.

~EnumerationManager

OTC_SDK_API ~EnumerationManager()

Destructor.

getDetectedDevices

OTC_SDK_API std::vector< DeviceInfo > getDetectedDevices(int seconds=0)

Returns information about the currently detected devices.

Note: A non-zero seconds starts the detection loop if it is not already running, because asking to wait for a detection pass is asking for one to happen. Detection is no longer started by Sdk::init(): that opened every attached camera twice a second for the life of any process that had initialised the SDK, whether or not it ever asked for a device list.

Note: seconds == 0 neither starts detection nor waits, so it cannot get stuck and cannot cause a bus read. It answers with what is already known, which on a process that has never detected anything is an empty list.

Parameters

Name Description
seconds < 0 the method waits indefinitely for the first detection pass to complete. == 0 the method will not wait. > 0 the method waits the given amount of seconds for the first detection pass to complete.

Returns: a vector holding the currently detected devices.

See also: runAsync()

addClient

OTC_SDK_API void addClient(EnumerationClient *client)

Adds an observer/client that will be updated if a device detection status changes.

Note: Starts the detection loop if it is not already running. Subscribing is a request to be told about arrivals, and there is nothing to tell while nothing is detecting. Before the loop was deferred out of Sdk::init() this happened to be unnecessary.

Parameters

Name Description
client callback client.

removeClient

OTC_SDK_API bool removeClient(EnumerationClient *client)

Removes the given observer/client.

Parameters

Name Description
client to remove.

run

OTC_SDK_API void 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 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.

Note: This method returns once the detection loop is running, however long the machine takes to schedule the thread. It used to give up waiting after one second and report failure, so on a loaded machine it could return false about a loop that was about to run perfectly well.

Returns: true once the detection loop is running. False only if the detection was stopped before it got going, which is the one case in which it really is not running.

See also: stopRunning()

See also: isRunning()

stopRunning

OTC_SDK_API void stopRunning()

Stops the continuous connection event detection. This does not clear the list of currently detected devices.

isRunning

OTC_SDK_API bool isRunning() const noexcept

Returns whether the connection event detection is running.

Returns: whether the connection event detection is running.

setDetectionPeriod

OTC_SDK_API void setDetectionPeriod(int period) noexcept

Sets the minimum period in milliseconds for a single connection event detection run.

Parameters

Name Description
period in milliseconds to set.

getDetectionPeriod

OTC_SDK_API int getDetectionPeriod() const noexcept

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.

addUsbDetector

OTC_SDK_API std::string 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.

removeUsbDetector

OTC_SDK_API bool removeUsbDetector()

Removes the detector for USB devices.

Returns: true, if an existing detector was removed. False otherwise.

addEthernetDetector

OTC_SDK_API std::string addEthernetDetector(const std::string &networkAddress)

Adds a detector for Ethernet devices in the specified network.

Parameters

Name Description
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.

removeEthernetDetector

OTC_SDK_API bool removeEthernetDetector(const std::string &networkAddress)

Remove the Ethernet detector for the specified network.

Parameters

Name Description
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.

addEthernetDetector

OTC_SDK_API std::string addEthernetDetector(const IpAddress &networkAddress, int cidr)

Adds a detector for Ethernet devices in the specified network.

Parameters

Name Description
networkAddress IP address of the network. Its host portion will be ignored.
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.

removeEthernetDetector

OTC_SDK_API bool removeEthernetDetector(const IpAddress &networkAddress, int cidr)

Remove the Ethernet detector for the specified network.

Parameters

Name Description
networkAddress IP address of the network. Its host portion will be ignored.
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.

addDetector

OTC_SDK_API std::string addDetector(const std::string &name, std::shared_ptr< EnumerationDetector > detector)

Adds a new detector for connected devices.

Parameters

Name Description
name under which to register the detector. If an empty string is provided, no detector will be added.
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.

removeDetector

OTC_SDK_API bool removeDetector(const std::string &name)

Removes the detector with the given name.

Parameters

Name Description
name of the detector to remove.

Returns: true, if a detector with the given name was removed. False otherwise.

clearDetectors

OTC_SDK_API void clearDetectors()

Clears all added detectors.

getDetectorNames

OTC_SDK_API std::vector< std::string > getDetectorNames()

Returns the names of all added detectors.

Returns: names of all added detectors.

getDetector

OTC_SDK_API std::shared_ptr< EnumerationDetector > getDetector(const std::string &name)

Return the detector registered under the given name.

Parameters

Name Description
name of the desired detector.

Returns: shared pointer to the detector or a nullptr if a detector with the given name is not registered.