-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModel.h
106 lines (64 loc) · 2.32 KB
/
Model.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
//
// Created by Admin on 6/18/2021.
//
#ifndef UNTITLED2_MODEL_H
#define UNTITLED2_MODEL_H
#include <list>
#include <cstdio>
#include <vector>
#include <memory>
#include <cmath>
#include "Sim_object.h"
#include "View.h"
#include "Ship.h"
#include "Port.h"
class Model {
protected:
static std::unique_ptr<Model> _ptr;
private:
std::vector<std::unique_ptr<Sim_object>> _Sim_object_vector;
std::vector<std::unique_ptr<Ship>> _ship_vector;
std::vector<std::unique_ptr<Port>> _port_vector;
std::vector<std::unique_ptr<View>> _view_vector;
Model();
public:
static Model& get_Instance();
Model(const Model&) = delete;
Model& operator=(const Model&) = delete;
Model(const Model&&) = delete;
Model& operator=(const Model&&) = delete;
void update();
const vector<std::unique_ptr<Sim_object>>& getSimObjectVector();
const vector<std::unique_ptr<Ship>>& getShipVector() const;
const vector<std::unique_ptr<Port>>& getPortVector() const;
const vector<std::unique_ptr<View>>& getViewVector() const;
void addShip(Ship *newShip);
void addCruiser(std::string name, Point position, int power,
double captureRange);
void addFreighter(string &name, const Point &position,
const int &resistance, int container);
void addBoatPatrol(string &name, Point position, const int &resistance);
void addPort(Port *a);
void addPort(std::string name, double x, double y, double Fuel = 10000,
int containers = 0, int FPH = 0);
void addView(View *newView);
void Attatch(Ship &newShip, Port &newPort);
void Dettatch(Ship &newShip, Port &newPort);
int getShipByName(const std::string &name);
Port* getPortByName(std::string name);
void course(std::string shipName, double angle, double speed);
void position(std::string shipName, double x, double y, double speed);
void destination(std::string shipName, std::string portName, double speed);
void load_at(std::string shipName, std::string portName);
void unload_at(std::string shipName, std::string portName,
double numberOfShipmentsToUnload);
Port* findClosestPort(const Point &point);
virtual ~Model() = default;
/* Implementation of the function make_unique */
template<typename T, typename ... Args>
std::unique_ptr<T> make_unique(Args &&... args) {
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
}
void status();
};
#endif //UNTITLED2_MODEL_H