Holds a set of IDevice pointers and provides type-filtered access and iteration.
More...
#include <DeviceGroup.hpp>
|
| | DeviceGroup (std::vector< device::IDevice * > devices) |
| | Constructs a group from the given device pointers.
|
|
| ~DeviceGroup ()=default |
| | Destructor.
|
| std::vector< device::IDevice * > | getDevices () const |
| | Returns all devices in the group.
|
| unsigned int | getDeviceCount () const |
| | Returns the number of devices in the group.
|
| void | invokeForEachDevice (std::function< void(device::IDevice *)> callback) const |
| | Invokes callback once per device in the group.
|
| template<typename T> |
| std::vector< T * > | getDevicesOfType () const |
| | Returns devices that are of type T (dynamic_cast).
|
| template<typename T> |
| void | invokeForEachDeviceOfType (std::function< void(T *)> callback) const |
| | Invokes callback for each device that is of type T.
|
|
| template<typename Response, typename Predicate> |
| static bool | waitForAll (std::vector< std::future< Response > > &futures, std::chrono::steady_clock::duration timeout, Predicate &&success_predicate) noexcept |
| | Waits until all futures are ready within the given timeout, then checks each result with a predicate.
|
| template<typename T> |
| static DeviceGroup | createFromDevicesOfType (std::vector< device::IDevice * > devices) |
| | Builds a DeviceGroup containing only devices of type T from the given list.
|
Holds a set of IDevice pointers and provides type-filtered access and iteration.
◆ DeviceGroup()
| eduart::device::DeviceGroup::DeviceGroup |
( |
std::vector< device::IDevice * > | devices | ) |
|
Constructs a group from the given device pointers.
- Parameters
-
| [in] | devices | Pointers to devices to include in the group. |
◆ createFromDevicesOfType()
Builds a DeviceGroup containing only devices of type T from the given list.
- Template Parameters
-
- Parameters
-
| [in] | devices | Source device list to filter. |
- Returns
- DeviceGroup containing only the T* devices from devices.
◆ getDeviceCount()
| unsigned int eduart::device::DeviceGroup::getDeviceCount |
( |
| ) |
const |
Returns the number of devices in the group.
- Returns
- Number of devices in the group.
◆ getDevices()
| std::vector< device::IDevice * > eduart::device::DeviceGroup::getDevices |
( |
| ) |
const |
Returns all devices in the group.
- Returns
- Vector of IDevice pointers (order preserved).
◆ getDevicesOfType()
template<typename T>
| std::vector< T * > eduart::device::DeviceGroup::getDevicesOfType |
( |
| ) |
const |
Returns devices that are of type T (dynamic_cast).
- Template Parameters
-
- Returns
- Vector of T* for devices that support the cast.
◆ invokeForEachDevice()
| void eduart::device::DeviceGroup::invokeForEachDevice |
( |
std::function< void(device::IDevice *)> | callback | ) |
const |
Invokes callback once per device in the group.
- Parameters
-
| [in] | callback | Callable invoked with each device pointer. |
◆ invokeForEachDeviceOfType()
template<typename T>
| void eduart::device::DeviceGroup::invokeForEachDeviceOfType |
( |
std::function< void(T *)> | callback | ) |
const |
Invokes callback for each device that is of type T.
- Template Parameters
-
- Parameters
-
| [in] | callback | Callable invoked with each T*. |
◆ waitForAll()
template<typename Response, typename Predicate>
| bool eduart::device::DeviceGroup::waitForAll |
( |
std::vector< std::future< Response > > & | futures, |
|
|
std::chrono::steady_clock::duration | timeout, |
|
|
Predicate && | success_predicate ) |
|
staticnoexcept |
Waits until all futures are ready within the given timeout, then checks each result with a predicate.
- Template Parameters
-
| Response | Type of the future result. |
| Predicate | Callable with signature bool(const Response&); if it returns false for any result, this returns false. |
- Parameters
-
| [in,out] | futures | Vector of futures to wait on (will be moved-from / consumed). |
| [in] | timeout | Maximum time to wait. |
| [in] | success_predicate | Called once per future result; all must return true for this to return true. |
- Returns
- true if all futures became ready within the timeout and the predicate returned true for every result; false otherwise.
The documentation for this class was generated from the following file: