23 void Start(hipo::banklist& banks)
override;
24 bool Run(hipo::banklist& banks)
const override;
36 void Add(std::string
const& algo_class_name, std::string
const& algo_instance_name =
"");
46 template <
class ALGORITHM>
47 void Add(std::string_view algo_instance_name =
"")
49 if(algo_instance_name ==
"")
50 Add(std::make_unique<ALGORITHM>());
52 Add(std::make_unique<ALGORITHM>(algo_instance_name));
63 void Add(algo_t&& algo);
73 template <
class ALGORITHM>
74 ALGORITHM*
Get(std::string
const& algo_instance_name)
76 if(
auto it{m_algo_names.find(algo_instance_name)}; it != m_algo_names.end())
77 return dynamic_cast<ALGORITHM*
>(m_sequence[it->second].get());
78 m_log->Error(
"cannot find algorithm '{}' in sequence", algo_instance_name);
79 throw std::runtime_error(
"cannot Get algorithm");
87 template <
typename OPTION_TYPE>
88 void SetOption(std::string
const& algo_instance_name, std::string
const& key,
const OPTION_TYPE val)
101 std::vector<std::string>
GetCreatedBankNames(std::string
const& algo_instance_name)
const noexcept(
false);
139 std::vector<algo_t> m_sequence;
142 std::unordered_map<std::string, std::vector<algo_t>::size_type> m_algo_names;
#define DEFINE_IGUANA_ALGORITHM(ALGO_NAME, ALGO_FULL_NAME)
An algorithm that can run a sequence of algorithms.
void SetConfigDirectoryForEachAlgorithm(std::string const &name)
Set a custom configuration file directory for each algorithm in the sequence.
void Add(std::string_view algo_instance_name="")
void Stop() override
Finalize this algorithm after all events are processed.
std::vector< std::string > GetCreatedBankNames(std::string const &algo_instance_name) const noexcept(false)
void Add(std::string const &algo_class_name, std::string const &algo_instance_name="")
ALGORITHM * Get(std::string const &algo_instance_name)
void ForEachAlgorithm(std::function< void(algo_t &)> func)
Call a function for each algorithm in the sequence.
void SetConfigFileForEachAlgorithm(std::string const &name)
Set a custom configuration file for each algorithm in the sequence.
std::string GetCreatedBankName(std::string const &algo_instance_name) const noexcept(false)
void SetOption(std::string const &algo_instance_name, std::string const &key, const OPTION_TYPE val)
void Start(hipo::banklist &banks) override
Initialize this algorithm before any events are processed, with the intent to process banks.
void SetName(std::string_view name)
void PrintSequence(Logger::Level level=Logger::info) const
bool Run(hipo::banklist &banks) const override
Run Function: Process an event's hipo::banklist
Algorithm(std::string_view name)
std::unique_ptr< Logger > m_log
Logger instance for this object