#include "generators/logger_generator.h" #include "simulation/errors.h" #include "simulation/logger.h" namespace generator { std::shared_ptr buildDeletionLogger(json_t* object) { std::vector used_types; std::vector used_phys_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 if (type_alias == "cluster_formation") { used_types.push_back(DeletionType::cluster_formation); } else if (type_alias == "wall_physical") { used_phys_types.push_back(PhysicalDeletionType::wall); }else { ERROR("This deletion type " + type_alias + " 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); used_types.push_back(DeletionType::cluster_formation); used_phys_types.push_back(PhysicalDeletionType::wall); used_phys_types.push_back(PhysicalDeletionType::large_energy_transfer); } } return std::make_shared(used_types, used_phys_types); } std::shared_ptr buildDeletionLogger( Parameter& parameter, const json_path& path_to_loggers) { #ifdef debug_level2 DEBUG_LEVEL_2("Creating deletion logger."); #endif json_path path_logger = json_path_append(path_to_loggers, {"Deletion"}); json_t* object = parameter.jsonObjectFromBase(path_logger); return buildDeletionLogger(object); } } // namespace generator