/** * @file common/utils/Trace.hpp * @author The ARTIS Development Team * See the AUTHORS or Authors.txt file */ /* * ARTIS - the multimodeling and simulation environment * This file is a part of the ARTIS environment * * Copyright (C) 2013-2022 ULCO http://www.univ-littoral.fr * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef COMMON_UTILS_TRACE #define COMMON_UTILS_TRACE #include #include #include #include #include #include #include #include #include namespace artis::common { template class TraceElement { public: TraceElement() : _time(Time::null), _formalism_type(FormalismType::NONE), _function_type(FunctionType::NONE), _level_type(LevelType::NONE) {} TraceElement(const std::string &model_name, typename Time::type time, const FormalismType::Values &formalism_type, const FunctionType::Values &function_type, const LevelType::Values &level_type) : _model_name(model_name), _time(time), _formalism_type(formalism_type), _function_type(function_type), _level_type(level_type) {} virtual ~TraceElement() {} const std::string &get_comment() const { return _comment; } const std::string &get_model_name() const { return _model_name; } typename Time::type get_time() const { return _time; } const FormalismType::Values &get_formalism_type() const { return _formalism_type; } const FunctionType::Values &get_function_type() const { return _function_type; } const LevelType::Values &get_level_type() const { return _level_type; } void set_comment(const std::string &comment) { _comment = comment; } std::string to_string() const { std::ostringstream ss; ss << "TRACE: " << get_model_name() << " at " << get_time() << " <"; ss << FormalismType::to_string(get_formalism_type()) << ", "; ss << FunctionType::to_string(get_function_type()) << ", "; ss << LevelType::to_string(get_level_type()) << ">"; if (not get_comment().empty()) { ss << " => " << get_comment(); } return ss.str(); } private: std::string _model_name; typename Time::type _time; FormalismType::Values _formalism_type; FunctionType::Values _function_type; LevelType::Values _level_type; std::string _comment; }; template class TraceElements : public std::vector > { public: TraceElements() {} virtual ~TraceElements() {} TraceElements filter_model_name(const std::string &model_name) const { TraceElements