-
Notifications
You must be signed in to change notification settings - Fork 1
/
Level.cpp
44 lines (36 loc) · 903 Bytes
/
Level.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
//
// Created by Zhou Yitao on 2018-12-04.
//
#include "Level.h"
Level::Level(): volume(10), currentIndex(0) {
}
void Level::push(Packet packet, int index) {
packet.setInsertFifo(index);
packet.setFifoPosition(static_cast<int>(fifos[index].size()));
fifos[index].push_back(packet);
}
Packet Level::pull() {
if (isCurrentFifoEmpty()) {
Packet tmp(-1, -1, -1, -1, -1, -1);
return tmp;
}
Packet tmp = fifos[currentIndex].front();
fifos[currentIndex].pop_front();
return tmp;
}
int Level::getCurrentIndex() {
return currentIndex;
}
void Level::getAndIncrementIndex() {
if (currentIndex + 1 < volume) {
currentIndex++;
} else {
currentIndex = 0;
}
}
bool Level::isCurrentFifoEmpty() {
return fifos[currentIndex].empty();
}
int Level::getCurrentFifoSize() {
return static_cast<int>(fifos[currentIndex].size());
}