aboutsummaryrefslogtreecommitdiff
path: root/Command.cpp
blob: f497f0f71dbf3c638fe051fb622b8611729d2982 (plain)
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
#include "Command.h"
#include "Exception.h"

Command::Command(const Command * c) {
	this->set_museum(*c->museum);
	this->set_view(*c->view);
	this->set_controller(*c->controller);
}

Command::Command(Museum & m, View & v, ViewController & c) {
	this->set_museum(m);
	this->set_view(v);
	this->set_controller(c);
}

Command::Command(Museum & m, View & v) {
	this->set_museum(m);
	this->set_view(v);
}

Command::Command(Museum & m) {
	this->set_museum(m);
}

Museum & Command::get_museum() {
	if (this->museum == nullptr)
		throw Exception("Command error: command needs museum");
	return *this->museum;
}

View & Command::get_view() {
	if (this->view == nullptr)
		throw Exception("Command error: command needs view");
	return *this->view;
}

ViewController & Command::get_controller() {
	if (this->controller == nullptr)
		throw Exception("Command error: command needs controller");
	return *this->controller;
}

void Command::set_museum(Museum & museum) {
	this->museum = &museum;
}

void Command::set_view(View & view) {
	this->view = &view;
}

void Command::set_controller(ViewController & controller) {
	this->controller = &controller;
}