Allow plugins to create channels

This also fixes a bug, that prevented the usage of custom types with the
plugin config API.
This commit is contained in:
Dennis Klein
2018-10-30 15:54:57 +01:00
committed by Dennis Klein
parent 3b5b2b501f
commit 5e4876c947
5 changed files with 44 additions and 12 deletions

View File

@@ -186,13 +186,16 @@ class PluginServices
auto SetProperty(const std::string& key, T val) -> void
{
auto currentState = GetCurrentDeviceState();
if (currentState == DeviceState::InitializingDevice)
if ( (currentState == DeviceState::InitializingDevice)
|| ((currentState == DeviceState::Idle) && (key == "channel-config")))
{
fConfig.SetValue(key, val);
}
else
{
throw InvalidStateError{tools::ToString("PluginServices::SetProperty is not supported in device state ", currentState, ". Supported state is ", DeviceState::InitializingDevice, ".")};
throw InvalidStateError{
tools::ToString("PluginServices::SetProperty is not supported in device state ", currentState, ". ",
"Supported state is ", DeviceState::InitializingDevice, ".")};
}
}
struct InvalidStateError : std::runtime_error { using std::runtime_error::runtime_error; };