-
Notifications
You must be signed in to change notification settings - Fork 0
/
Action.h
57 lines (52 loc) · 1.43 KB
/
Action.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
#pragma once
#include "repository.h"
#include "domain.h"
class Action
{
public:
virtual void doAction() = 0;
virtual void undoAction() = 0;
virtual ~Action() {}
};
class AddAction :
public Action
{
private:
RepoInterface* repo;
Tower tower;
public:
AddAction(RepoInterface* repo, Tower tower) : repo{ repo }, tower{ tower } {}
AddAction(const AddAction& other) : repo{ other.repo }, tower{ other.tower } {}
void doAction() override;
void undoAction() override;
~AddAction() {}
};
class RemoveAction :
public Action
{
private:
RepoInterface* repo;
RepoInterface* saved;
Tower tower;
public:
RemoveAction(RepoInterface* repo, Tower tower, RepoInterface* saved = nullptr) : repo{ repo }, saved{ saved }, tower{ tower } {}
RemoveAction(const RemoveAction& other) : repo{ other.repo }, saved{ other.saved }, tower{ other.tower } {}
void doAction() override;
void undoAction() override;
~RemoveAction() {}
};
class UpdateAction :
public Action
{
private:
RepoInterface* repo;
RepoInterface* saved;
Tower oldTower;
Tower newTower;
public:
UpdateAction(RepoInterface* repo, Tower oldTower, Tower newTower, RepoInterface* saved = nullptr) : repo{ repo }, saved{ saved }, oldTower{ oldTower }, newTower{ newTower } {}
UpdateAction(const UpdateAction& other) : repo{ other.repo }, saved{ other.saved }, oldTower{ other.oldTower }, newTower{ other.newTower } {}
void doAction() override;
void undoAction() override;
~UpdateAction() {}
};