Loading [MathJax]/extensions/TeX/AMSmath.js
ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages Concepts
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 <mutex>
28#include <sstream>
29#include <string>
30#include <vector>
31
32namespace ErrorHandling {
33
35public:
36 explicit RuntimeErrorCollector(boost::mpi::communicator comm);
38
40 void message(const RuntimeError &message);
41 void message(RuntimeError::ErrorLevel level, const std::string &msg,
42 const char *function, const char *file, int line);
43
44 void warning(const std::string &msg, const char *function, const char *file,
45 int line);
46 void warning(const char *msg, const char *function, const char *file,
47 int line);
48 void warning(const std::ostringstream &mstr, const char *function,
49 const char *file, int line);
50
51 void error(const std::string &msg, const char *function, const char *file,
52 int line);
53 void error(const char *msg, const char *function, const char *file, int line);
54 void error(const std::ostringstream &mstr, const char *function,
55 const char *file, int line);
56
57 /**
58 * \brief Get the number of all flying messages on all nodes.
59 *
60 * @return Total number of messages.
61 */
62 int count() const;
63
64 /**
65 * \brief Get the number of messages that have at least severity
66 * @p level on this node.
67 *
68 * @param level Severity filter.
69 * @return Number of messages that match the filter.
70 */
72
73 /**
74 * @brief Reset error messages.
75 */
76 void clear();
77
78 /**
79 * @brief Flush error messages to standard error.
80 */
81 void flush();
82
83 std::vector<RuntimeError> gather();
84 void gather_local();
85
86 const boost::mpi::communicator &comm() const { return m_comm; }
87
88private:
89 mutable std::mutex mutex;
90 std::vector<RuntimeError> m_errors;
91 boost::mpi::communicator m_comm;
92};
93
94} // namespace ErrorHandling
95
96#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.