Files
karl/src/generators/logger_generator.cpp
T

51 lines
1.6 KiB
C++
Executable File

#include "generators/logger_generator.h"
#include "simulation/errors.h"
#include "simulation/logger.h"
namespace generator {
std::shared_ptr<DeletionLogger> buildDeletionLogger(json_t* object) {
std::vector<DeletionType> used_types;
json_t* type = json_object_by_path(object, {"Type"});
if (json_is_array(type)) {
size_t index;
json_t* value;
json_array_foreach(type, index, value) {
std::string type_alias = json_string(value);
if (type_alias == "wall") {
used_types.push_back(DeletionType::wall);
} else if (type_alias == "recombination") {
used_types.push_back(DeletionType::recombination);
} else if (type_alias == "max_interactions") {
used_types.push_back(DeletionType::max_interactions);
} else if (type_alias == "max_time_alive") {
used_types.push_back(DeletionType::max_time_alive);
} else {
ERROR("This deletion type is not known");
}
}
} else {
if (json_string(type) == "all") {
used_types.push_back(DeletionType::wall);
used_types.push_back(DeletionType::recombination);
used_types.push_back(DeletionType::max_interactions);
used_types.push_back(DeletionType::max_time_alive);
}
}
return std::make_shared<DeletionLogger>(used_types);
}
std::shared_ptr<DeletionLogger> buildDeletionLogger(
Parameter& parameter,
const json_path& path_to_loggers) {
DEBUG_LEVEL_2("Creating deletion logger.");
json_path path_logger = json_path_append(path_to_loggers, {"Deletion"});
json_t* object = parameter.jsonObjectFromBase(path_logger);
return buildDeletionLogger(object);
}
} // namespace generator