-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBank.h
63 lines (54 loc) · 1.25 KB
/
Bank.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
/*
* Bank.h
*
* Created on: Oct 16, 2013
* Author: cbr4830
*/
#ifndef BANK_H_
#define BANK_H_
#include <teller.h>
#include <queue.h>
#include <time.h>
#include <stdio.h>
#include <unistd.h>
#include <pthread.h>
#include <Constants.h>
#include <TimerSys.h>
#include "Metrics.h"
extern Metrics* metrics;
class Bank {
public:
/**
* Function: Constructor
* Description: Instantiates the customer queue and tellers.
*
* @param t A ptr to the system timer.
*/
Bank(TimerSys* t);
/**
* Function: Destructor
* Description: Deletes the tellers and the customer queue and the metrics object upon desctruction.
*/
virtual ~Bank();
/**
* Function: openAndRunBank()
* Description: Opens the bank, starts running the global timer, and
* adds customers to queue while bank is open. When bank is
* operating hours end, closes the bank.
*/
void openAndRunBank();
/**
* Function: closeBank()
* Description: Closes the bank by first telling the tellers to finish the remaining
* customers in the queue and clean themselves up. Then, it stops the timer.
*/
void closeBank();
private:
Teller* tellers[NUM_TELLERS];
Queue* customerQueue;
bool open;
bool timerOn;
pthread_t thread;
TimerSys* timer;
};
#endif /* BANK_H_ */