-
Notifications
You must be signed in to change notification settings - Fork 0
/
DataItem.cpp
111 lines (88 loc) · 2.63 KB
/
DataItem.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
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
//
// Created by qiangqiang liu on 02/06/2017.
//
//
// DataItem.cpp
// Schedule
//
// Created by qiangqiang liu on 30/04/2017.
// Copyright © 2017 qiangqiang liu. All rights reserved.
//
#include "DataItem.h"
#include <iostream>
using namespace std;
//initial DataItem object
DataItem::DataItem(){}
DataItem::DataItem(int release_time, int deadline, int validity_interval, bool is_finished):
release_time(release_time), deadline(deadline), validity_interval(validity_interval), is_finished(false) {}
DataItem::~DataItem(){}
// void setAvailableTime(int available_time) {
// this->available_time = available_time;
// }
// int getAvailableTime() {
// return available_time;
// }
// void setAvailablePeriod(int available_period) {
// this->available_period = available_period;
// }
// int getAvailablePeriod() {
// return available_period;
// }
void DataItem::setReleaseTime(int release_time) {
this->release_time = release_time;
}
int DataItem::getReleaseTime() {
return release_time;
}
void DataItem::setRetrievalTime(int retrieval_time) {
this->retrieval_time = retrieval_time;
}
int DataItem::getRetrievalTime() {
return retrieval_time;
}
void DataItem::setValidInterval(int validity_interval) {
this->validity_interval = validity_interval;
}
int DataItem::getValidInterval() {
return validity_interval;
}
// void DataItem::setAvailableFactor(double available_factor) {
// this->available_factor = available_factor;
// }
// double DataItem::getAvailableFactor() {
// return available_factor;
// }
void DataItem::setIsFinished(bool is_finished) {
this->is_finished = is_finished;
}
bool DataItem::getIsFinished() {
return is_finished;
}
void DataItem::setDeadline(int deadline) {
this->deadline = deadline;
}
int DataItem::getDeadline() {
return deadline;
}
// //confirm if current data item is finished
// void DataItem::isFinished() {
// if(isValid() && isAvailable())
// is_finished = true;
// else
// is_finished = false;
// }
// //confirm if current data item subjects to data freshness
// bool DataItem::isValid() {
// return available_time + validity_interval >= release_time + retrieval_time;
// }
// //confirm if current data item subject to data availability
// bool DataItem::isAvailable() {
// int wait = (release_time - available_time) % available_period;
// return (wait >= 0) && (wait <= available_factor * available_period);
// }
bool DataItem::isEqual(DataItem& left, DataItem& right) {
if(left.getDeadline() == right.getDeadline() && left.getValidInterval() == right.getValidInterval() && left.getReleaseTime() == right.getReleaseTime()) {
return true;
}
return false;
}