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-2022 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#ifndef ESPRESSO_SRC_CORE_ERROR_HANDLING_RUNTIME_ERROR_COLLECTOR_HPP
21#define ESPRESSO_SRC_CORE_ERROR_HANDLING_RUNTIME_ERROR_COLLECTOR_HPP
22
24
25#include <boost/mpi/communicator.hpp>
26
27#include <sstream>
28#include <string>
29#include <vector>
30
31namespace ErrorHandling {
32
34public:
35 explicit RuntimeErrorCollector(boost::mpi::communicator comm);
37
39 void message(const RuntimeError &message);
40 void message(RuntimeError::ErrorLevel level, const std::string &msg,
41 const char *function, const char *file, int line);
42
43 void warning(const std::string &msg, const char *function, const char *file,
44 int line);
45 void warning(const char *msg, const char *function, const char *file,
46 int line);
47 void warning(const std::ostringstream &mstr, const char *function,
48 const char *file, int line);
49
50 void error(const std::string &msg, const char *function, const char *file,
51 int line);
52 void error(const char *msg, const char *function, const char *file, int line);
53 void error(const std::ostringstream &mstr, const char *function,
54 const char *file, int line);
55
56 /**
57 * \brief Get the number of all flying messages on all nodes.
58 *
59 * @return Total number of messages.
60 */
61 int count() const;
62
63 /**
64 * \brief Get the number of messages that have at least severity
65 * @p level on this node.
66 *
67 * @param level Severity filter.
68 * @return Number of messages that match the filter.
69 */
71
72 /**
73 * @brief Reset error messages.
74 */
75 void clear();
76
77 /**
78 * @brief Flush error messages to standard error.
79 */
80 void flush();
81
82 std::vector<RuntimeError> gather();
83 void gather_local();
84
85 const boost::mpi::communicator &comm() const { return m_comm; }
86
87private:
88 std::vector<RuntimeError> m_errors;
89 boost::mpi::communicator m_comm;
90};
91
92} // namespace ErrorHandling
93
94#endif
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
ErrorLevel
The error level, warnings are only displayed to the user, errors are fatal.