@@ -112,27 +112,19 @@ std::vector<InputSpec> DataSampling::InputSpecsForPolicy(const std::string& poli
112112
113113std::vector<InputSpec> DataSampling::InputSpecsForPolicy (ConfigurationInterface* const config, const std::string& policyName)
114114{
115- std::vector<InputSpec> inputs;
116115 auto policiesTree = config->getRecursive (" dataSamplingPolicies" );
117-
118- for (auto && policyConfig : policiesTree) {
119- if (policyConfig.second .get <std::string>(" id" ) == policyName) {
120- auto policy = DataSamplingPolicy::fromConfiguration (policyConfig.second );
121- for (const auto & path : policy.getPathMap ()) {
122- InputSpec input = DataSpecUtils::matchingInput (path.second );
123- inputs.push_back (input);
124- }
125- break ;
126- }
127- }
128- return inputs;
116+ return InputSpecsForPolicy (policiesTree, policyName);
129117}
130118
131119std::vector<InputSpec> DataSampling::InputSpecsForPolicy (std::shared_ptr<configuration::ConfigurationInterface> config, const std::string& policyName)
132120{
133- std::vector<InputSpec> inputs;
134121 auto policiesTree = config->getRecursive (" dataSamplingPolicies" );
122+ return InputSpecsForPolicy (policiesTree, policyName);
123+ }
135124
125+ std::vector<framework::InputSpec> DataSampling::InputSpecsForPolicy (const boost::property_tree::ptree& policiesTree, const std::string& policyName)
126+ {
127+ std::vector<InputSpec> inputs;
136128 for (auto && policyConfig : policiesTree) {
137129 if (policyConfig.second .get <std::string>(" id" ) == policyName) {
138130 auto policy = DataSamplingPolicy::fromConfiguration (policyConfig.second );
@@ -154,9 +146,13 @@ std::vector<OutputSpec> DataSampling::OutputSpecsForPolicy(const std::string& po
154146
155147std::vector<OutputSpec> DataSampling::OutputSpecsForPolicy (ConfigurationInterface* const config, const std::string& policyName)
156148{
157- std::vector<OutputSpec> outputs;
158149 auto policiesTree = config->getRecursive (" dataSamplingPolicies" );
150+ return OutputSpecsForPolicy (policiesTree, policyName);
151+ }
159152
153+ std::vector<framework::OutputSpec> DataSampling::OutputSpecsForPolicy (const boost::property_tree::ptree& policiesTree, const std::string& policyName)
154+ {
155+ std::vector<OutputSpec> outputs;
160156 for (auto && policyConfig : policiesTree) {
161157 if (policyConfig.second .get <std::string>(" id" ) == policyName) {
162158 auto policy = DataSamplingPolicy::fromConfiguration (policyConfig.second );
@@ -172,6 +168,17 @@ std::vector<OutputSpec> DataSampling::OutputSpecsForPolicy(ConfigurationInterfac
172168std::optional<uint16_t > DataSampling::PortForPolicy (configuration::ConfigurationInterface* const config, const std::string& policyName)
173169{
174170 auto policiesTree = config->getRecursive (" dataSamplingPolicies" );
171+ return PortForPolicy (policiesTree, policyName);
172+ }
173+
174+ std::optional<uint16_t > DataSampling::PortForPolicy (const std::string& policiesSource, const std::string& policyName)
175+ {
176+ std::unique_ptr<ConfigurationInterface> config = ConfigurationFactory::getConfiguration (policiesSource);
177+ return PortForPolicy (config.get (), policyName);
178+ }
179+
180+ std::optional<uint16_t > DataSampling::PortForPolicy (const boost::property_tree::ptree& policiesTree, const std::string& policyName)
181+ {
175182 for (auto && policyConfig : policiesTree) {
176183 if (policyConfig.second .get <std::string>(" id" ) == policyName) {
177184 auto boostOptionalPort = policyConfig.second .get_optional <uint16_t >(" port" );
@@ -181,16 +188,21 @@ std::optional<uint16_t> DataSampling::PortForPolicy(configuration::Configuration
181188 throw std::runtime_error (" Could not find the policy '" + policyName + " '" );
182189}
183190
184- std::optional<uint16_t > DataSampling::PortForPolicy (const std::string& policiesSource, const std::string& policyName)
191+ std::vector<std::string> DataSampling::MachinesForPolicy (configuration::ConfigurationInterface* const config, const std::string& policyName)
192+ {
193+ auto policiesTree = config->getRecursive (" dataSamplingPolicies" );
194+ return MachinesForPolicy (policiesTree, policyName);
195+ }
196+
197+ std::vector<std::string> DataSampling::MachinesForPolicy (const std::string& policiesSource, const std::string& policyName)
185198{
186199 std::unique_ptr<ConfigurationInterface> config = ConfigurationFactory::getConfiguration (policiesSource);
187- return PortForPolicy (config.get (), policyName);
200+ return MachinesForPolicy (config.get (), policyName);
188201}
189202
190- std::vector<std::string> DataSampling::MachinesForPolicy (configuration::ConfigurationInterface* const config , const std::string& policyName)
203+ std::vector<std::string> DataSampling::MachinesForPolicy (const boost::property_tree::ptree& policiesTree , const std::string& policyName)
191204{
192205 std::vector<std::string> machines;
193- auto policiesTree = config->getRecursive (" dataSamplingPolicies" );
194206 for (auto && policyConfig : policiesTree) {
195207 if (policyConfig.second .get <std::string>(" id" ) == policyName) {
196208 if (policyConfig.second .count (" machines" ) > 0 ) {
@@ -204,10 +216,4 @@ std::vector<std::string> DataSampling::MachinesForPolicy(configuration::Configur
204216 throw std::runtime_error (" Could not find the policy '" + policyName + " '" );
205217}
206218
207- std::vector<std::string> DataSampling::MachinesForPolicy (const std::string& policiesSource, const std::string& policyName)
208- {
209- std::unique_ptr<ConfigurationInterface> config = ConfigurationFactory::getConfiguration (policiesSource);
210- return MachinesForPolicy (config.get (), policyName);
211- }
212-
213219} // namespace o2::utilities
0 commit comments