Skip to content

Commit

Permalink
make attach_suite virtual instead of pure virtual
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobdenobel committed May 22, 2023
1 parent b9eeb3f commit 91b2309
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions include/ioh/logger/analyzer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ namespace ioh::logger
if (info_stream_.tellp() != 0)
info_stream_ << "\n";

info_stream_ << "suite = \"" << current_suite_ << "\", funcId = " << problem.problem_id
info_stream_ << "suite = \"" << suite_ << "\", funcId = " << problem.problem_id
<< ", funcName = \"" << problem.name << "\", DIM = " << problem.n_variables
<< ", maximization = \""
<< (problem.optimization_type == common::OptimizationType::MAX ? 'T' : 'F')
Expand Down Expand Up @@ -539,7 +539,7 @@ namespace ioh::logger

if (experiments_.find(current_filename_) == experiments_.end())
experiments_.insert({current_filename_,
{current_suite_, problem, algorithm_,
{suite_, problem, algorithm_,
common::as_vector<str, str, sAttr>(attributes_.experiment),
common::keys(attributes_.run), attribute_names()}});
}
Expand Down
9 changes: 4 additions & 5 deletions include/ioh/logger/flatfile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ namespace ioh::logger
//! Output stream
std::ofstream out_;

//! Current suite
std::string current_suite_;


//! Current run
size_t current_run_;
Expand Down Expand Up @@ -126,12 +125,12 @@ namespace ioh::logger
(common_header_titles.empty() ? "" : sep_)),
repeat_header_(repeat_header), store_positions_(store_positions), requires_header_(true),
log_meta_data_(!common_header_titles.empty()), output_directory_(output_directory), filename_(filename),
current_suite_("unknown_suite"), current_run_(0), current_meta_data_{}
current_run_(0), current_meta_data_{}
{
assert(common_header_titles.empty() || common_header_titles.size() == 7);
}

void attach_suite(const std::string &suite_name) override { current_suite_ = suite_name; }


void attach_problem(const problem::MetaData &problem) override
{
Expand Down Expand Up @@ -214,7 +213,7 @@ namespace ioh::logger
if (log_meta_data_)
{
std::stringstream ss;
ss /* no sep */ << current_suite_;
ss /* no sep */ << suite_;
ss << sep_ << problem_.value().name;
ss << sep_ << problem_.value().problem_id;
ss << sep_ << problem_.value().instance;
Expand Down
9 changes: 6 additions & 3 deletions include/ioh/logger/loggers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ namespace ioh {
//! Access to the problem.
std::optional<problem::MetaData> problem_;

//! Current suite
std::string suite_ = "unknown_suite";

/** Map property names to property references.
*
* If your logger is handling any property, you can just iterate over them,
Expand Down Expand Up @@ -189,11 +192,11 @@ namespace ioh {
IOH_DBG(xdebug,"attach problem " << problem.problem_id)
problem_ = problem;
}

public:

//! Starts a new session for the given Suite name.
virtual void attach_suite(const std::string& suite_name) = 0;
virtual void attach_suite(const std::string &suite_name) { suite_ = suite_name; }

public:
//! Main entry point, called everytime a Trigger is true.
virtual void call(const logger::Info& log_info) = 0;

Expand Down

0 comments on commit 91b2309

Please sign in to comment.