Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: set configuration files and directories for all algorithms in an AlgorithmSequence #297

Merged
merged 1 commit into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/iguana/algorithms/AlgorithmSequence.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<void(algo_t&)> func)
{
for(auto& algo : m_sequence)
func(algo);
}

}
23 changes: 23 additions & 0 deletions src/iguana/algorithms/AlgorithmSequence.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<void(algo_t&)> func);

private:

/// The sequence of algorithms
Expand Down
Loading