forked from ChristophKirst/SimKernel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsim_io_manager.h
86 lines (57 loc) · 1.89 KB
/
sim_io_manager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/***************************************************************************
sim_io_manager.h - manages messages and errors
Christoph Kirst
Max Planck Institue for Dynamics and Self-Organisation
HU Berlin, BCCN Göttingen & Berlin (2008)
****************************************************************************/
#ifndef SIM_IO_MANAGER_H
#define SIM_IO_MANAGER_H
#include <string>
#include <sstream>
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <assert.h>
#include "sim_signals.h"
class SimIOManager
{
private:
bool screen_out;
bool file_out;
std::string file_name;
std::ofstream of;
std::vector<std::string> messages;
std::vector<std::string> errors;
int n_ids;
std::string pre;
bool print_id;
bool next_pre;
SimSignal outl;
static std::map<SimSignal, std::string> SimSignalDescription;
public:
SimIOManager();
~SimIOManager();
void init(bool so = true, const std::string& prefix = "Sim: ", bool pid = true,
bool fo = false, const std::string& filen = "sim.log",
const SimSignal& ol = AllOutput);
void set_iterations(int n_iters);
void set_output_level(const SimSignal& sig);
void message(const std::string& tex, const SimSignal& sig=Message, int id = -1, int pr =-1);
void set_screen_output(bool so);
void set_pre(const std::string& newpre);
void message_summary(int id = -1);
void error_summary(int id = -1);
void summary(int id = -1);
void flush();
void endline(int id = -1, int pr = -1);
void close();
private:
void print_message(const std::string& tex, int id = -1, int pr = -1);
std::string message_text(const std::string& tex, const SimSignal& sig);
std::string printpre(int id, int pr);
std::string message_summary_text(int id = -1);
std::string error_summary_text(int id = -1);
};
#endif