-
Notifications
You must be signed in to change notification settings - Fork 1
/
Location.h
114 lines (87 loc) · 5.5 KB
/
Location.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
107
108
109
110
111
112
113
114
// Location.h
// A location, which is basically a building.
// Maintains lists of which humans are in the building at 3 points in the day
#ifndef __LOCATION_H
#define __LOCATION_H
#include <queue>
class Person;
class Location {
// TODO -- create derived classes for different types of locations
public:
Location();
Location(const Location& o) {
_ID = o._ID;
_essential = o._essential;
_riskiness = o._riskiness;
_public_transmission_risk = o._public_transmission_risk;
_type = o._type;
_person = o._person;
_visitors = o._visitors;
_visit_durations = o._visit_durations;
_neighbors = o._neighbors;
_hospital = o._hospital;
_coord = o._coord;
};
virtual ~Location();
struct LocPtrComp { bool operator()(const Location* A, const Location* B) const { return A->getID() < B->getID(); } };
int getID() const { return _ID; }
static void reset_ID_counter() { NEXT_ID = 0; } // for use by community destructor
LocationType getType() const { return _type; }
void setType(LocationType t) { _type = t; }
void setEssential(bool e) { _essential = e; }
bool isEssential() const { return _essential; }
bool isNonEssential() const { return !_essential; }
int getNumPeople() const { return _person.size(); } // employees, residents, etc.; not including visitors
int getNumVisitors() const { return _visitors.size(); } // visitors change daily
std::vector<Person*> getPeople() { return _person; }
inline Person* getPerson(int idx) { return _person[idx]; }
void setPeople(std::vector<Person*> p) { _person = p; }
void addPerson(Person *p) { _person.push_back(p); }
bool removePerson(Person *p);
std::vector<Person*> getVisitors() { return _visitors; }
void setVisitors(std::vector<Person*> v) { _visitors = v; }
std::vector<double> getVisitDurations() { return _visit_durations; }
void addVisitor(Person *p, double dur) { _visitors.push_back(p); _visit_durations.push_back(dur); }
void clearVisitors() { _visitors.clear(); _visit_durations.clear(); } // likey don't want to resize
std::set<Location*, LocPtrComp> getNeighbors() { return _neighbors; }
int getNumNeighbors() const { return _neighbors.size(); }
void setNeighbors(std::set<Location*, LocPtrComp> n) { _neighbors = n; }
void addNeighbor(Location* loc);
Location* getHospital() const { return _hospital; }
void setHospital(Location* hosp) { _hospital = hosp; }
void setCoordinates(std::pair<double, double> c) { _coord = c; }
std::pair<double, double> getCoordinates() { return _coord; }
double getX() const { return _coord.first; }
void setX(double x) { _coord.first = x; }
double getY() const { return _coord.second; }
void setY(double y) { _coord.second = y; }
void setPixel(double xP, double yP) { _xPixel = xP; _yPixel = yP; }
std::pair<double, double> getPixel() const { return {_xPixel, _yPixel}; }
double getXPixel() const { return _xPixel; }
double getYPixel() const { return _yPixel; }
float getRiskiness() const { return _riskiness; }
void setRiskiness(float ra) { _riskiness = ra; }
PublicTransmissionType getPublicTransmissionRisk() const { return _public_transmission_risk; }
void setPublicTransmissionRisk(PublicTransmissionType pt) { _public_transmission_risk = pt; }
bool operator == ( const Location* other ) const { return _ID == other->_ID; }
void dumper() const;
void revertState();
// We use this to make sure that locations are iterated through in a well-defined order (by ID), rather than by mem address
protected:
// TODO -- figure out how to represent people coming to a place for different reasons,
// e.g. hospital patients/staff, nursinghome residents/staff
int _ID; // original identifier in location file
bool _essential;
float _riskiness; // score on U(0,1) of household's risk threshold
PublicTransmissionType _public_transmission_risk; // is this a location where there is (high, low, or no) risk of tranmission to e.g. customers
LocationType _type;
std::vector<Person*> _person; // people who predictably come to this location
std::vector<Person*> _visitors; // people who probabilistically visit this location (currently only for businesses)
std::vector<double> _visit_durations; // people who probabilistically visit this location (currently only for businesses)
std::set<Location*, LocPtrComp> _neighbors;
Location* _hospital; // for houses, the associated hospital (nullptr for others)
static size_t NEXT_ID; // unique ID to assign to the next Location allocated
std::pair<double, double> _coord; // (x,y) coordinates for location
double _xPixel, _yPixel;
};
#endif