2016-03-24 13:55:12 +08:00
|
|
|
/*
|
|
|
|
|
Copyright 2016 Statoil ASA.
|
|
|
|
|
|
|
|
|
|
This file is part of the Open Porous Media project (OPM).
|
|
|
|
|
|
|
|
|
|
OPM 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.
|
|
|
|
|
|
|
|
|
|
OPM 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 OPM. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef MESSAGECONTAINER_H
|
|
|
|
|
#define MESSAGECONTAINER_H
|
|
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
|
|
namespace Opm {
|
|
|
|
|
|
2016-03-25 09:47:57 +08:00
|
|
|
namespace MessageType {
|
|
|
|
|
|
|
|
|
|
enum MessageTypeEnum {
|
2016-04-01 10:46:31 +02:00
|
|
|
|
|
|
|
|
struct Message {
|
|
|
|
|
enum type {
|
2016-03-29 14:18:03 +02:00
|
|
|
Debug = 1,
|
|
|
|
|
Info = 2,
|
|
|
|
|
Warning = 3,
|
|
|
|
|
Error = 4,
|
|
|
|
|
Problem = 5,
|
|
|
|
|
Bug = 6
|
2016-03-25 09:47:57 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace MessageType
|
|
|
|
|
|
|
|
|
|
|
2016-03-24 13:55:12 +08:00
|
|
|
struct Location {
|
2016-04-01 10:46:31 +02:00
|
|
|
Location() = default;
|
|
|
|
|
Location( const std::string& s, int l ) : filename( s ), lineno( l ) {}
|
|
|
|
|
|
2016-03-24 13:55:12 +08:00
|
|
|
std::string filename;
|
2016-04-01 10:46:31 +02:00
|
|
|
int lineno = -1;
|
|
|
|
|
|
|
|
|
|
explicit operator bool() const {
|
|
|
|
|
return lineno > 0;
|
|
|
|
|
}
|
2016-03-24 13:55:12 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct Message {
|
2016-03-25 09:47:57 +08:00
|
|
|
MessageType::MessageTypeEnum mtype;
|
2016-03-24 13:55:12 +08:00
|
|
|
std::string message;
|
2016-04-01 10:46:31 +02:00
|
|
|
Location location;
|
2016-03-24 13:55:12 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///Message container is used to replace OpmLog functionalities.
|
|
|
|
|
class MessageContainer {
|
|
|
|
|
public:
|
2016-03-29 14:18:03 +02:00
|
|
|
void error(const std::string& msg, const std::string& filename, const int lineno);
|
2016-03-25 09:47:57 +08:00
|
|
|
void error(const std::string& msg);
|
2016-03-24 13:55:12 +08:00
|
|
|
|
|
|
|
|
void bug(const std::string& msg, const std::string& filename, const int lineno);
|
2016-03-25 09:47:57 +08:00
|
|
|
void bug(const std::string& msg);
|
2016-03-24 13:55:12 +08:00
|
|
|
|
|
|
|
|
void warning(const std::string& msg, const std::string& filename, const int lineno);
|
2016-03-25 09:47:57 +08:00
|
|
|
void warning(const std::string& msg);
|
2016-03-24 13:55:12 +08:00
|
|
|
|
|
|
|
|
void info(const std::string& msg, const std::string& filename, const int lineno);
|
2016-03-25 09:47:57 +08:00
|
|
|
void info(const std::string& msg);
|
2016-03-24 13:55:12 +08:00
|
|
|
|
|
|
|
|
void debug(const std::string& msg, const std::string& filename, const int lineno);
|
2016-03-25 09:47:57 +08:00
|
|
|
void debug(const std::string& msg);
|
2016-03-24 13:55:12 +08:00
|
|
|
|
|
|
|
|
void problem(const std::string& msg, const std::string& filename, const int lineno);
|
2016-03-25 09:47:57 +08:00
|
|
|
void problem(const std::string& msg);
|
2016-03-24 13:55:12 +08:00
|
|
|
|
2016-03-25 09:47:57 +08:00
|
|
|
std::vector<Message>::const_iterator begin() const;
|
|
|
|
|
std::vector<Message>::const_iterator end() const;
|
2016-03-24 13:55:12 +08:00
|
|
|
private:
|
2016-03-25 09:47:57 +08:00
|
|
|
std::vector<Message> m_messages;
|
2016-03-24 13:55:12 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Opm
|
2016-04-01 15:57:26 +02:00
|
|
|
|
|
|
|
|
#endif // OPM_MESSAGECONTAINER_HEADER_INCLUDED
|