DASpec:genericize synonymous param parsing

This commit is contained in:
2025-11-16 04:46:42 -04:00
parent 3bcb83894b
commit f919385088
3 changed files with 35 additions and 36 deletions
@@ -110,7 +110,6 @@ void produceStimFrameAck(void)
static int parseHistbuffMs(
const std::shared_ptr<device::DeviceAttachmentSpec>& spec)
{
int histbuffMs = 30000; // Default: 30000ms (30 seconds)
const std::vector<std::string> histbuffParamNames = {
"history-buffer-duration-ms",
"hist-buff-duration-ms",
@@ -118,23 +117,8 @@ static int parseHistbuffMs(
"histbuff-ms"
};
// Loop through synonyms in reverse order; lattermost synonym wins.
for (auto synIt = histbuffParamNames.rbegin();
synIt != histbuffParamNames.rend(); ++synIt)
{
const auto& paramName = *synIt;
try {
histbuffMs = device::DeviceAttachmentSpec
::parseRequiredParamAsInt(
spec->qualeIfaceApiParams, paramName);
break; // Found and parsed successfully
} catch (const std::exception&) {
// Parameter not found or parse error, continue to next synonym
continue;
}
}
return histbuffMs;
return device::DeviceAttachmentSpec::parseOptionalParamAsIntWithSynonyms(
spec->qualeIfaceApiParams, histbuffParamNames, 30000);
}
std::shared_ptr<StimulusBuffer>