-
Notifications
You must be signed in to change notification settings - Fork 0
/
record.cpp
48 lines (39 loc) · 1.03 KB
/
record.cpp
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
#include "record.h"
#include "utils.h"
Record::Record(msg_type_t msg_type, int pid)
: msg_type_(msg_type), pid_(pid)
{
time_ = get_date();
}
Record::Record(msg_type_t msg_type, Process_info process_info)
: msg_type_(msg_type)
{
pid_ = process_info.get_pid();
time_ = get_date();
}
msg_type_t Record::get_msg_type() const {
return this->msg_type_;
}
int Record::get_pid() const {
return this->pid_;
}
std::string Record::get_time() const {
return this->time_;
}
std::ostream& operator<<(std::ostream& out, const Record& record) {
switch (record.get_msg_type())
{
case REQUEST:
out << "[R] Request-" << record.get_pid() << "-" << record.get_time() << std::endl;
break;
case GRANT:
out << "[S] Grant-" << record.get_pid() << "-" << record.get_time() << std::endl;
break;
case RELEASE:
out << "[R] Release-" << record.get_pid() << "-" << record.get_time() << std::endl;
break;
default:
break;
}
return out;
}