hemocell
Loading...
Searching...
No Matches
logfile.h
Go to the documentation of this file.
1/*
2This file is part of the HemoCell library
3
4HemoCell is developed and maintained by the Computational Science Lab
5in the University of Amsterdam. Any questions or remarks regarding this library
6can be sent to: info@hemocell.eu
7
8When using the HemoCell library in scientific work please cite the
9corresponding paper: https://doi.org/10.3389/fphys.2017.00563
10
11The HemoCell library is free software: you can redistribute it and/or
12modify it under the terms of the GNU Affero General Public License as
13published by the Free Software Foundation, either version 3 of the
14License, or (at your option) any later version.
15
16The library is distributed in the hope that it will be useful,
17but WITHOUT ANY WARRANTY; without even the implied warranty of
18MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19GNU Affero General Public License for more details.
20
21You should have received a copy of the GNU Affero General Public License
22along with this program. If not, see <http://www.gnu.org/licenses/>.
23*/
24#ifndef LOGFILE_H
25#define LOGFILE_H
26
27#include <fstream>
28#include <iostream>
29namespace hemo {
31{
32public:
34 : logfile(*(new std::fstream()))
35 {}
36 Logfile(std::fstream& logfile_)
37 : logfile(logfile_)
38 {}
39 std::fstream & logfile;
40 std::string filename = "";
41};
42template<typename Val>
43Logfile & operator << (Logfile & lf, Val const & rhs) {
44 if (lf.logfile.is_open()) {
45 std::cout << rhs;
46 lf.logfile << rhs;
47 }
48 return lf;
49}
50inline Logfile & operator<< (Logfile & lf, std::ostream & (*op) (std::ostream&)) {
51 if (lf.logfile.is_open()){
52 std::cout << op << std::flush;
53 lf.logfile << op;
54 }
55 return lf;
56}
57extern Logfile hlog;
58
60{};
61template<typename Val>
62Logfile_only & operator << (Logfile_only & lf, Val const & rhs) {
63 if (hlog.logfile.is_open()) {
64 hlog.logfile << rhs;
65 }
66 return lf;
67}
68inline Logfile_only & operator<< (Logfile_only & lf, std::ostream & (*op) (std::ostream&)) {
69 if (hlog.logfile.is_open()){
70 hlog.logfile << op;
71 }
72 return lf;
73}
74extern Logfile_only hlogfile;
75
76}
77#endif /* LOGFILE_H */
78
Definition logfile.h:60
Definition logfile.h:31
Logfile(std::fstream &logfile_)
Definition logfile.h:36
std::string filename
Definition logfile.h:40
Logfile()
Definition logfile.h:33
std::fstream & logfile
Definition logfile.h:39
Definition config.cpp:34
Logfile_only hlogfile
Definition logfile.cpp:27
Logfile & operator<<(Logfile &lf, Val const &rhs)
Definition logfile.h:43
Logfile hlog
Definition logfile.cpp:26