-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontroller.cpp
More file actions
42 lines (38 loc) · 1.12 KB
/
controller.cpp
File metadata and controls
42 lines (38 loc) · 1.12 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
#include "controller.h"
#include "observer.h"
#include "queries.h"
#include "red_black_tree.h"
#include "utility.h"
namespace DSVisualization {
Controller::Controller(Model& model)
: observer_view_controller_(
[this](const TreeQuery& x) {
OnNotifyFromView(x);
}),
model_ptr_(&model) {
PRINT_WHERE_AM_I();
}
Controller::~Controller() {
PRINT_WHERE_AM_I();
}
Observer<TreeQuery>* Controller::GetObserver() {
PRINT_WHERE_AM_I();
return &observer_view_controller_;
}
void Controller::OnNotifyFromView(const TreeQuery& query) {
PRINT_WHERE_AM_I();
switch (query.query_type) {
case TreeQueryType::insert:
model_ptr_->Insert(query.value);
break;
case TreeQueryType::erase:
model_ptr_->Erase(query.value);
break;
case TreeQueryType::find:
model_ptr_->Find(query.value);
break;
default:
break;
}
}
}// namespace DSVisualization