-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathController.h
67 lines (47 loc) · 1.4 KB
/
Controller.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
//
// Created by Admin on 6/18/2021.
//
#ifndef UNTITLED2_CONTROLLER_H
#define UNTITLED2_CONTROLLER_H
#include <list>
#include <cstdio>
#include <sstream>
#include "Sim_object.h"
#include "Model.h"
class Controller {
public:
Controller(View *viewPtr);
virtual ~Controller() = default;
//get a path to a file as input and adds all the ports in the file
static void init(std::string Filepath);
// creates View object, runs the program by accepting user commands, then destroys View object
void run();
static void CreateObject(string command);
int getCommandIndex(string first);
const list<string>& getCommandList() const;
void setCommandList(const list<string> &commandList);
int getTime() const;
void setTime(int time);
View* getViewPtr() const;
void setViewPtr(View *viewPtr);
void pan(string command);
void zoom(string command);
void size(string command);
void defaultSettings();
/* the function separate the word "line" by the character del and returns the words as vector
* for example tokenize("cpp hw2 ", ' ') => { "hw2" , "cpp" } */
vector<string> tokenize(string line, char del) {
vector<string> tokens;
stringstream check1(line);
string intermediate;
while (getline(check1, intermediate, del)) {
tokens.push_back(intermediate);
}
return tokens;
}
private:
std::list<string> _commandList;
int _time = 0;
View *_view_ptr { };
};
#endif //UNTITLED2_CONTROLLER_H