ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
RuntimeErrorCollector.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2014-2026 The ESPResSo project
3 *
4 * This file is part of ESPResSo.
5 *
6 * ESPResSo is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * ESPResSo is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#pragma once
21
23
24#include <boost/mpi/communicator.hpp>
25
26#include <mutex>
27#include <string>
28#include <vector>
29
30namespace ErrorHandling {
31
33public:
34 explicit RuntimeErrorCollector(boost::mpi::communicator comm);
36
37 void message(RuntimeError::ErrorLevel level, const std::string &msg,
38 const char *function, const char *file, int line);
39
40 void warning(const std::string &msg, const char *function, const char *file,
41 int line);
42
43 void error(const std::string &msg, const char *function, const char *file,
44 int line);
45
46 /**
47 * \brief Get the number of all flying messages on all nodes.
48 *
49 * @return Total number of messages.
50 */
51 int count() const;
52
53 /**
54 * \brief Get the number of messages that have at least severity
55 * @p level on this node.
56 *
57 * @param level Severity filter.
58 * @return Number of messages that match the filter.
59 */
61
62 /**
63 * @brief Reset error messages.
64 */
65 void clear();
66
67 /**
68 * @brief Flush error messages to standard error.
69 */
70 void flush();
71
72 std::vector<RuntimeError> gather();
73 void gather_local();
74
75 const boost::mpi::communicator &comm() const { return m_comm; }
76
77private:
78 mutable std::mutex mutex;
79 std::vector<RuntimeError> m_errors;
80 boost::mpi::communicator m_comm;
81};
82
83} // namespace ErrorHandling
void flush()
Flush error messages to standard error.
int count() const
Get the number of all flying messages on all nodes.
void error(const std::string &msg, const char *function, const char *file, int line)
void warning(const std::string &msg, const char *function, const char *file, int line)
const boost::mpi::communicator & comm() const
void message(RuntimeError::ErrorLevel level, const std::string &msg, const char *function, const char *file, int line)