-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogfile.h
66 lines (53 loc) · 1.35 KB
/
logfile.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
/*
* logfile header
*/
#ifndef LOGFILE_H
#define LOGFILE_H
#include "eventlist.h"
#include <string>
/*
* Logfile is a class for specifying the log file format.
* The loggers (loggers.h) face both
* 1. the log file, using the base class Logger (defined here)
* 2. the simulator, using the base classes in loggertypes.h
*/
#define MAX_RECORDS 100000
struct __attribute__((__packed__)) Record {
double time;
uint32_t type;
uint32_t id;
uint32_t ev;
double val1;
double val2;
double val3;
};
class Logfile;
class Logger
{
friend class Logfile;
protected:
void setLogfile(Logfile &logfile) { _logfile = &logfile; }
Logfile *_logfile;
};
class Logfile
{
public:
Logfile(const std::string &filename,
simtime_picosec start = 0,
simtime_picosec end = ULLONG_MAX);
~Logfile();
void addLogger(Logger &logger);
void write(const std::string &msg);
void writeName(Logged &logged);
void writeRecord(uint32_t type, uint32_t id, uint32_t ev,
double val1, double val2, double val3);
private:
FILE *_trace_file;
FILE *_id_file;
simtime_picosec _start;
simtime_picosec _end;
struct Record *_records;
uint32_t _nRecords;
uint32_t _nTotalRecords;
};
#endif /* LOGFILE_H */