FairMQ: Implement config API for string subscriptions

This API auto converts property values to strings and allows a more
convenient one catches all subscription.
This commit is contained in:
Dennis Klein
2017-11-16 17:50:36 +01:00
committed by Mohammad Al-Turany
parent 80332583ee
commit 378c47c5e5
3 changed files with 37 additions and 0 deletions

View File

@@ -226,6 +226,21 @@ class PluginServices
template<typename T>
auto UnsubscribeFromPropertyChange(const std::string& subscriber) -> void { fConfig->Unsubscribe<T>(subscriber); }
/// @brief Subscribe to property updates
/// @param subscriber
/// @param callback function
///
/// Subscribe to property changes with a callback to monitor property changes in an event based fashion. Will convert the property to string.
auto SubscribeToPropertyChangeAsString(const std::string& subscriber, std::function<void(const std::string& key, std::string)> callback) const -> void
{
fConfig->SubscribeAsString(subscriber, callback);
}
/// @brief Unsubscribe from property updates that convert to string
/// @param subscriber
auto UnsubscribeFromPropertyChangeAsString(const std::string& subscriber) -> void { fConfig->UnsubscribeAsString(subscriber); }
static const std::unordered_map<std::string, DeviceState> fkDeviceStateStrMap;
static const std::unordered_map<DeviceState, std::string, tools::HashEnum<DeviceState>> fkStrDeviceStateMap;
static const std::unordered_map<std::string, DeviceStateTransition> fkDeviceStateTransitionStrMap;