mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-13 16:46:47 +00:00
FairMQ: Implement GetPropertyKeys config API
This commit is contained in:
parent
2589ca5ced
commit
8c8ee45914
|
@ -90,6 +90,7 @@ class Plugin
|
|||
auto GetProperty(const std::string& key) const -> T { return fPluginServices->GetProperty<T>(key); }
|
||||
auto GetPropertyAsString(const std::string& key) const -> std::string { return fPluginServices->GetPropertyAsString(key); }
|
||||
auto GetChannelInfo() const -> std::unordered_map<std::string, int> { return fPluginServices->GetChannelInfo(); }
|
||||
auto GetPropertyKeys() const -> std::vector<std::string> { return fPluginServices->GetPropertyKeys(); }
|
||||
// template<typename T>
|
||||
// auto SubscribeToPropertyChange(std::function<void(const std::string& [>key*/, const T /*newValue<])> callback) const -> void { fPluginServices.SubscribeToPropertyChange(fkName, callback); }
|
||||
// template<typename T>
|
||||
|
|
|
@ -206,6 +206,8 @@ class PluginServices
|
|||
|
||||
auto GetChannelInfo() const -> std::unordered_map<std::string, int> { return fConfig->GetChannelInfo(); }
|
||||
|
||||
auto GetPropertyKeys() const -> std::vector<std::string> { return fConfig->GetPropertyKeys(); }
|
||||
|
||||
/// @brief Subscribe to property updates of type T
|
||||
/// @param subscriber
|
||||
/// @param callback function
|
||||
|
@ -228,7 +230,6 @@ class PluginServices
|
|||
// auto UnsubscribeFromPropertyChange(const std::string& subscriber) -> void { fConfig->Unsubscribe<T>(subscriber); }
|
||||
//
|
||||
// TODO Fix property subscription
|
||||
// TODO Property iterator
|
||||
|
||||
static const std::unordered_map<std::string, DeviceState> fkDeviceStateStrMap;
|
||||
static const std::unordered_map<DeviceState, std::string, tools::HashEnum<DeviceState>> fkStrDeviceStateMap;
|
||||
|
|
|
@ -64,6 +64,20 @@ class FairProgOptions
|
|||
FairProgOptions();
|
||||
virtual ~FairProgOptions();
|
||||
|
||||
auto GetPropertyKeys() const -> std::vector<std::string>
|
||||
{
|
||||
std::lock_guard<std::mutex> lock{fConfigMutex};
|
||||
|
||||
std::vector<std::string> result;
|
||||
|
||||
for (const auto& it : fVarMap)
|
||||
{
|
||||
result.push_back(it.first.c_str());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// add options_description
|
||||
int AddToCmdLineOptions(const po::options_description optDesc, bool visible = true);
|
||||
int AddToCfgFileOptions(const po::options_description optDesc, bool visible = true);
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include "Fixture.h"
|
||||
#include <fairmq/Tools.h>
|
||||
#include <algorithm>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
@ -47,4 +48,13 @@ TEST_F(PluginServices, ConfigInvalidStateError)
|
|||
});
|
||||
}
|
||||
|
||||
TEST_F(PluginServices, KeyDiscovery)
|
||||
{
|
||||
mConfig.SetValue("foo", 0);
|
||||
|
||||
auto keys{mServices.GetPropertyKeys()};
|
||||
|
||||
EXPECT_TRUE(find(keys.begin(), keys.end(), "foo") != keys.end());
|
||||
}
|
||||
|
||||
} /* namespace */
|
||||
|
|
Loading…
Reference in New Issue
Block a user