diff --git a/src/iguana/algorithms/AlgorithmSequence.cc b/src/iguana/algorithms/AlgorithmSequence.cc index db75a9aa..a2da0395 100644 --- a/src/iguana/algorithms/AlgorithmSequence.cc +++ b/src/iguana/algorithms/AlgorithmSequence.cc @@ -67,4 +67,22 @@ namespace iguana { m_log->Print(level, " - {}", algo->GetName()); } + void AlgorithmSequence::SetConfigFileForEachAlgorithm(std::string const& name) + { + for(auto const& algo : m_sequence) + algo->SetConfigFile(name); + } + + void AlgorithmSequence::SetConfigDirectoryForEachAlgorithm(std::string const& name) + { + for(auto const& algo : m_sequence) + algo->SetConfigDirectory(name); + } + + void AlgorithmSequence::ForEachAlgorithm(std::function func) + { + for(auto& algo : m_sequence) + func(algo); + } + } diff --git a/src/iguana/algorithms/AlgorithmSequence.h b/src/iguana/algorithms/AlgorithmSequence.h index 5f620a75..04e9b61b 100644 --- a/src/iguana/algorithms/AlgorithmSequence.h +++ b/src/iguana/algorithms/AlgorithmSequence.h @@ -93,6 +93,29 @@ namespace iguana { /// @param level the log level of the printout void PrintSequence(Logger::Level level = Logger::info) const; + /// @brief Set a custom configuration file for each algorithm in the sequence + /// + /// Use this function if you have a single configuration file for all the + /// algorithms in your sequence + /// @param name the configuration file name + void SetConfigFileForEachAlgorithm(std::string const& name); + + /// @brief Set a custom configuration file directory for each algorithm in the sequence + /// + /// Use this function if you have a single configuration file directory for all the + /// algorithms in your sequence + /// @param name the directory name + void SetConfigDirectoryForEachAlgorithm(std::string const& name); + + /// @brief Call a function for each algorithm in the sequence + /// + /// Use as: + /// ```cpp + /// ForEachAlgorithm([](auto& algo){ algo->...; }); + /// ``` + /// @param func the function to call for each algorithm `algo` + void ForEachAlgorithm(std::function func); + private: /// The sequence of algorithms