-
Notifications
You must be signed in to change notification settings - Fork 0
/
barbershopec.h
executable file
·87 lines (61 loc) · 2.32 KB
/
barbershopec.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/////////////////////////////////////////////////////////////////////
// barbershopec.h: Event Manager classes definition
// Variable with simulated systems
/////////////////////////////////////////////////////////////////////
// Resources declaration
class Barber;
/////////////////////////////////////////////////////////////////////
// CLASS EventManager
/////////////////////////////////////////////////////////////////////
// Simulation events management
/////////////////////////////////////////////////////////////////////
// The Event Manager must "know" all resources.
class EventManager {
public:
// Methods
EventManager(Simulation *sim); // Constructor
~EventManager(); // Destructor
void ExecuteEvent(int code, Client *client); // Event execution
void Init(); // Initialization
void InitRep(); // Replication initialization
void Stats(); // Stats computation (end of replication)
void DisplayStats(); // Statistics display
private:
// Attributes
Simulation *simul; // Pointer toward simulation object
// Resources
Barber *barber;
};
/////////////////////////////////////////////////////////////////////
// CLASS Client
/////////////////////////////////////////////////////////////////////
// Custom simulation entity
/////////////////////////////////////////////////////////////////////
class Client {
public:
// Add here (in public) additional attributes
Client();
void setName(char n[STRS]);
char* getName();
Client *next;
Client *previous;
char name[STRS];
};
/////////////////////////////////////////////////////////////////////
// CLASS Barber
/////////////////////////////////////////////////////////////////////
class Barber: public Resource {
public:
// Constructor
Barber(char n[STRS], int cap, Simulation *sim);
// Events
void Event0(Client *client); //The initial event
void Event1(Client *client); //Client arrives
void Event2(Client *client); //Client being served
void Event3(Client *client); //Finish serving/leave shop
private:
int stack_size; //Nr of chairs
int c_stack_size; //Nr of free chairs
int arrived; //Nr of arrived clients
int production; //counter
};