Stride Reference Manual  1.0
Person.h
Go to the documentation of this file.
1 #pragma once
2 /*
3  * This is free software: you can redistribute it and/or modify it
4  * under the terms of the GNU General Public License as published by
5  * the Free Software Foundation, either version 3 of the License, or
6  * any later version.
7  * The software is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  * You should have received a copy of the GNU General Public License
12  * along with the software. If not, see <http://www.gnu.org/licenses/>.
13  *
14  * Copyright 2017, Willem L, Kuylen E, Stijven S & Broeckhove J
15  */
16 
22 #include "core/Health.h"
23 
24 #include <cstddef>
25 #include <iostream>
26 #include <memory>
27 
30 
33 
34 namespace stride {
35 
36 class Calendar;
37 
38 enum class ClusterType;
39 
40 template<typename T>
41 class Traveller;
42 
46 template<class BehaviourPolicy, class BeliefPolicy>
47 class Person {
48 public:
50  Person(unsigned int id, double age, unsigned int household_id, unsigned int school_id,
51  unsigned int work_id, unsigned int primary_community_id, unsigned int secondary_community_id,
52  unsigned int start_infectiousness,
53  unsigned int start_symptomatic, unsigned int time_infectious, unsigned int time_symptomatic,
54  double risk_averseness = 0, bool is_on_vacation = false)
55  : m_id(id), m_age(age), m_gender('M'),
56  m_household_id(household_id), m_school_id(school_id),
57  m_work_id(work_id), m_primary_community_id(primary_community_id),
58  m_secondary_community_id(secondary_community_id),
61  m_health(start_infectiousness, start_symptomatic, time_infectious, time_symptomatic),
62  m_is_participant(false), m_is_on_vacation(is_on_vacation) {
63  BeliefPolicy::initialize(m_belief_data, risk_averseness);
64  }
65 
67  bool operator!=(const Person& p) const { return p.m_id != m_id; }
68 
70  double getAge() const { return m_age; }
71 
73  unsigned int getClusterId(ClusterType cluster_type) const;
74 
76  char getGender() const { return m_gender; }
77 
79  Health& getHealth() { return m_health; }
80 
82  const Health& getHealth() const { return m_health; }
83 
85  const typename BeliefPolicy::Data& getBeliefData() const { return m_belief_data; }
86 
88  unsigned int getId() const { return m_id; }
89 
91  bool isInCluster(ClusterType c) const;
92 
94  bool isParticipatingInSurvey() const { return m_is_participant; }
95 
98 
100  void update(bool is_work_off, bool is_school_off, double fraction_infected);
101 
103  void update(const Person* p);
104 
105  bool isOnVacation() const { return m_is_on_vacation; }
106 
107  void setOnVacation(bool is_on_vacation) { m_is_on_vacation = is_on_vacation; }
108 
109  template<class PersonType> friend
110  class Traveller;
111 
112 private:
113  unsigned int m_id;
114  double m_age;
115  char m_gender;
117  unsigned int m_household_id;
118  unsigned int m_school_id;
119  unsigned int m_work_id;
120  unsigned int m_primary_community_id;
121  unsigned int m_secondary_community_id;
124  bool m_at_school;
125  bool m_at_work;
130  typename BeliefPolicy::Data m_belief_data;
133  bool m_is_on_vacation;
134 
136 private:
137  friend class Hdf5Saver;
139  friend class Hdf5Loader;
141  friend class Traveller<Person<BehaviourPolicy, BeliefPolicy>>;
142 };
143 
145 extern template
147 
148 extern template
150 
151 extern template
153 
154 extern template
156 
157 }
158 
bool isParticipatingInSurvey() const
Does this person participates in the social contact study?
Definition: Person.h:94
unsigned int m_household_id
The household id.
Definition: Person.h:116
unsigned int m_secondary_community_id
The secondary community id.
Definition: Person.h:120
unsigned int m_id
The id.
Definition: Person.h:112
unsigned int m_work_id
The work cluster id.
Definition: Person.h:118
double getAge() const
Get the age.
Definition: Person.h:70
bool m_is_participant
Is participating in the social contact study.
Definition: Person.h:131
bool m_at_household
Is person present at household today?
Definition: Person.h:122
Time Dependent Person DataType.
Definition: NoBehaviour.h:17
bool m_at_primary_community
Is person present at primary_community today?
Definition: Person.h:125
const Health & getHealth() const
Return person&#39;s health status.
Definition: Person.h:82
Health m_health
Health info for this person.
Definition: Person.h:128
void setOnVacation(bool is_on_vacation)
Definition: Person.h:107
bool m_at_school
Is person present at school today?
Definition: Person.h:123
bool isOnVacation() const
Definition: Person.h:105
bool m_at_secondary_community
Is person present at secundary_community today?
Definition: Person.h:126
unsigned int m_primary_community_id
The primary community id.
Definition: Person.h:119
bool m_is_on_vacation
Is currently on a vacation and should be included in calculations.
Definition: Person.h:132
Forward declaration of class Person.
Definition: ThresholdData.h:15
const BeliefPolicy::Data & getBeliefData() const
Return person&#39;s belief status.
Definition: Person.h:85
Health & getHealth()
Return person&#39;s health status.
Definition: Person.h:79
unsigned int m_school_id
The school cluster id.
Definition: Person.h:117
void participateInSurvey()
Participate in social contact study and log person details.
Definition: Person.h:97
char getGender() const
Return person&#39;s gender.
Definition: Person.h:76
double m_age
The age.
Definition: Person.h:113
unsigned int getId() const
Get the id.
Definition: Person.h:88
char m_gender
The gender.
Definition: Person.h:114
unsigned int getClusterId(ClusterType cluster_type) const
Get cluster ID of cluster_type.
Definition: Person.cpp:27
bool isInCluster(ClusterType c) const
Check if a person is present today in a given cluster.
Definition: Person.cpp:45
ClusterType
Enumerates the cluster types.
Definition: ClusterType.h:28
bool operator!=(const Person &p) const
Is this person not equal to the given person?
Definition: Person.h:67
Person(unsigned int id, double age, unsigned int household_id, unsigned int school_id, unsigned int work_id, unsigned int primary_community_id, unsigned int secondary_community_id, unsigned int start_infectiousness, unsigned int start_symptomatic, unsigned int time_infectious, unsigned int time_symptomatic, double risk_averseness=0, bool is_on_vacation=false)
Constructor: set the person data.
Definition: Person.h:50
void update(bool is_work_off, bool is_school_off, double fraction_infected)
Update the health status and presence in clusters.
Definition: Person.cpp:63
bool m_at_work
Is person present at work today?
Definition: Person.h:124
BeliefPolicy::Data m_belief_data
Info w.r.t. this Person&#39;s health beliefs.
Definition: Person.h:129