n2p2 - A neural network potential package
Log.h
Go to the documentation of this file.
1// n2p2 - A neural network potential package
2// Copyright (C) 2018 Andreas Singraber (University of Vienna)
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <https://www.gnu.org/licenses/>.
16
17#ifndef LOG_H
18#define LOG_H
19
20#include <cstdio> // FILE
21#include <fstream> // std::ofstream
22#include <string> // std::string
23#include <vector> // std::vector
24
25namespace nnp
26{
27
33class Log
34{
35public:
40 Log();
47 Log& operator<<(std::string const& entry);
55 std::vector<std::string> const& entries);
60 void addLogEntry(std::string const& entry);
66 std::vector<std::string> const& entries);
71 void registerCFilePointer(FILE** const& filePointer);
77 std::ofstream* const& streamPointer);
82 std::vector<std::string> getLog() const;
83
87 bool silent;
88
89private:
91 std::vector<std::string> memory;
93 std::vector<FILE**> cFilePointers;
95 std::vector<std::ofstream*> streamPointers;
96};
97
98}
99
100#endif
Logging class for library output.
Definition: Log.h:34
void addLogEntry(std::string const &entry)
Add string as new log entry.
Definition: Log.cpp:40
std::vector< std::string > getLog() const
Get complete log memory.
Definition: Log.cpp:97
Log & operator<<(std::string const &entry)
Overload << operator.
Definition: Log.cpp:28
void registerStreamPointer(std::ofstream *const &streamPointer)
Register new C++ ofstream pointer.
Definition: Log.cpp:91
void addMultipleLogEntries(std::vector< std::string > const &entries)
Add multiple log entries at once.
Definition: Log.cpp:74
bool silent
Completely silence output.
Definition: Log.h:87
std::vector< std::string > memory
Memory with all log entries.
Definition: Log.h:91
void registerCFilePointer(FILE **const &filePointer)
Register new C-style FILE* pointer for output.
Definition: Log.cpp:85
std::vector< FILE ** > cFilePointers
Storage for C-style FILE* pointers.
Definition: Log.h:93
bool writeToStdout
Turn on/off output to stdout.
Definition: Log.h:85
Log()
Constructor.
Definition: Log.cpp:23
std::vector< std::ofstream * > streamPointers
Storage for C++ ofstream pointers.
Definition: Log.h:95
Definition: Atom.h:28