45 [[nodiscard]]
auto GetAllDevices() -> std::vector<ExperimentDeviceProxy>
47 _variant_t device_list = ::IncaOnlineExperiment_Dispatch::GetAllDevices();
48 if (device_list.vt != (VT_ARRAY | VT_VARIANT))
49 throw std::runtime_error(
"GetAllDevices returned an unexpected type.");
51 SAFEARRAY *psa = V_ARRAY(&device_list);
52 long lLower{}, lUpper{};
53 SafeArrayGetLBound(psa, 1, &lLower);
54 SafeArrayGetUBound(psa, 1, &lUpper);
56 std::vector<ExperimentDeviceProxy> out{};
57 out.reserve(
static_cast<std::size_t
>(lUpper - lLower + 1));
58 for (
long i{lLower}; i <= lUpper; ++i)
61 if (FAILED(SafeArrayGetElement(psa, &i, &device)))
62 throw std::runtime_error(
"GetAllDevices: SafeArrayGetElement failed");
64 if (device.vt != VT_DISPATCH)
65 throw std::runtime_error(
"GetAllDevices: device element is not VT_DISPATCH");
67 auto idispatch = (IDispatch *)(device);
68 out.emplace_back(idispatch);