-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrunProgram.cpp
63 lines (53 loc) · 1.92 KB
/
runProgram.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
#include "runProgram.h"
#include "invoker.h"
#include <string>
//initializes the private variable programOn to false
runProgram::runProgram():
programOn(0)
{
}
//destructor
runProgram::~runProgram()
{
}
//forces changes the state of the program to true to run the simulator
void runProgram::startProgram(){
if ( programOn != 1 ){
programOn = 1;
}
}
/*while programOn is true manageProgram acts
as a mediator to the request class updating the user
options/choices and serves to terminate
the program when prompted to do so by the user*/
void runProgram::manageProgram(){
request newR; //new request is created
int go = 0; //go is a variable used to control the user request loop
while (go!=77){ //random value that go is only changed to from the Exit option
go = newR.getRequest(); //go becomes set to the value returned from getRequest
switchTask(newR.returnRequest()); //switchTask calls class & method for users choice, pass in rType from user
//std::cout << "task check ";
};
newR.~request();
killProgram();
}
/***********************************************************
WHERE REQUEST OBJECT GETS PASSED TO INVOKER CLASS!
***********************************************************/
void runProgram::switchTask(std::string response){ //switchTask takes in rType as parameter
invoker newI; /* an instance of the invoker is created here. Since switchTask takes in rTypr as the parameter
rType (being a string) is then passed into the invoker. The string is evaluated within the
invoker class and from there the appropriate class will be called to execute the task (ie. pcbController)
*/
newI.evaluateRequest(response);
newI.~invoker();
}
void runProgram::killProgram(){
if (programOn != 0 ){
programOn = 0;
}
runProgram();
}
bool runProgram::getState(){
return programOn;
}