-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRollbackStack.h
More file actions
executable file
·68 lines (54 loc) · 1.42 KB
/
Copy pathRollbackStack.h
File metadata and controls
executable file
·68 lines (54 loc) · 1.42 KB
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
// Jaden Heller
// 2328279
// jaheller@chapman.edu
// CPSC-350-01
// Assignment 6
#ifndef ROLLBACKSTACK_H
#define ROLLBACKSTACK_H
#include "ListInterface.h"
#include "SchoolDatabase.h"
//Stack used to undo actions that modify the database in any way. Not implimented in final program
//but here's what I have of my attempt
class RollbackStack{
public:
RollbackStack();
RollbackStack(int maxSize);
~RollbackStack();
myList<SchoolDatabase*> *stack;
SchoolDatabase* Pop();
SchoolDatabase* Peek();
void Push(SchoolDatabase *newDatabase);
bool isEmpty();
bool isFull();
int getSize();
private:
SchoolDatabase *database; //might end up being **
int mSize;
SchoolDatabase *top;
};
RollbackStack::RollbackStack(){
stack = new myList<SchoolDatabase*>();
mSize = 3;
}
RollbackStack::RollbackStack(int maxSize){
stack = new myList<SchoolDatabase*>();
mSize = maxSize;
}
RollbackStack::~RollbackStack(){
delete top, database, stack;
}
void RollbackStack::Push(SchoolDatabase *newDatabase){
stack->Prepend(newDatabase);
if(stack->GetLength() > mSize){
stack->RemoveBack();
}
}
SchoolDatabase* RollbackStack::Peek(){
return stack->ReturnFront();
}
SchoolDatabase* RollbackStack::Pop(){
SchoolDatabase* oldTop = Peek();
stack->RemoveFront();
return oldTop;
}
#endif