Stride Reference Manual  - generated for commit 9643b11
Health.h
Go to the documentation of this file.
1 /*
2  * This is free software: you can redistribute it and/or modify it
3  * under the terms of the GNU General Public License as published by
4  * the Free Software Foundation, either version 3 of the License, or
5  * any later version.
6  * The software is distributed in the hope that it will be useful,
7  * but WITHOUT ANY WARRANTY; without even the implied warranty of
8  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9  * GNU General Public License for more details.
10  * You should have received a copy of the GNU General Public License
11  * along with the software. If not, see <http://www.gnu.org/licenses/>.
12  *
13  * Copyright 2017, Kuylen E, Willem L, Broeckhove J
14  */
15 
21 #pragma once
22 
23 namespace stride {
24 
26 enum class HealthStatus : unsigned short int
27 {
28  Susceptible = 0U,
29  Exposed = 1U,
30  Infectious = 2U,
31  Symptomatic = 3U,
33  Recovered = 5U,
34  Immune = 6U
35 };
36 
38 class Health
39 {
40 public:
42  explicit Health(unsigned short int start_infectiousness = 0U, unsigned int short start_symptomatic = 0U,
43  unsigned short int time_infectious = 0U, unsigned short int time_symptomatic = 0U);
44 
46  unsigned short int GetEndInfectiousness() const { return m_end_infectiousness; }
47 
49  unsigned short int GetEndSymptomatic() const { return m_end_symptomatic; }
50 
52  unsigned short int GetStartInfectiousness() const { return m_start_infectiousness; }
53 
55  unsigned short int GetStartSymptomatic() const { return m_start_symptomatic; }
56 
58  bool IsImmune() const { return m_status == HealthStatus::Immune; }
59 
61  bool IsInfected() const
62  {
63  return m_status == HealthStatus::Exposed || m_status == HealthStatus::Infectious ||
65  }
66 
68  bool IsInfectious() const
69  {
70  return m_status == HealthStatus::Infectious || m_status == HealthStatus::InfectiousAndSymptomatic;
71  }
72 
74  bool IsRecovered() const { return m_status == HealthStatus::Recovered; }
75 
77  bool IsSusceptible() const { return m_status == HealthStatus::Susceptible; }
78 
80  bool IsSymptomatic() const
81  {
82  return m_status == HealthStatus::Symptomatic || m_status == HealthStatus::InfectiousAndSymptomatic;
83  }
84 
86  bool SymptomsStartedToday() const { return GetDiseaseCounter() == m_start_symptomatic; }
87 
89  void SetImmune() { m_status = HealthStatus::Immune; }
90 
93 
95  void StartInfection();
96 
98  void StopInfection();
99 
101  void Update();
102 
103 private:
105  unsigned short int GetDiseaseCounter() const { return m_disease_counter; }
106 
108  void IncrementDiseaseCounter() { m_disease_counter++; }
109 
111  void ResetDiseaseCounter() { m_disease_counter = 0U; }
112 
113 private:
114  unsigned short int m_disease_counter;
116 
117  unsigned short int m_start_infectiousness;
118  unsigned short int m_start_symptomatic;
119  unsigned short int m_end_infectiousness;
120  unsigned short int m_end_symptomatic;
121 };
122 
123 } // namespace stride
unsigned short int m_end_infectiousness
Days after infection to end infectious state.
Definition: Health.h:119
bool IsSymptomatic() const
Is this person symptomatic?
Definition: Health.h:80
bool IsImmune() const
Is this person immune?
Definition: Health.h:58
unsigned short int GetEndSymptomatic() const
Definition: Health.h:49
unsigned short int m_end_symptomatic
Days after infection to end symptomatic state.
Definition: Health.h:120
Holds a person&#39;s health data.
Definition: Health.h:38
unsigned short int GetDiseaseCounter() const
Get the disease counter.
Definition: Health.h:105
void SetImmune()
Set health state to immune.
Definition: Health.h:89
HealthStatus m_status
The current status of the person w.r.t. the disease.
Definition: Health.h:115
void SetSusceptible()
Set health state to susceptible.
Definition: Health.h:92
bool IsRecovered() const
Is this person recovered?
Definition: Health.h:74
HealthStatus
Enumerate the various health states with respect to the infection.
Definition: Health.h:26
unsigned short int m_disease_counter
The disease counter.
Definition: Health.h:114
unsigned short int GetStartInfectiousness() const
Definition: Health.h:52
bool IsInfected() const
Is this person infected?
Definition: Health.h:61
bool IsInfectious() const
Is this person infectious.
Definition: Health.h:68
unsigned short int GetStartSymptomatic() const
Definition: Health.h:55
unsigned short int m_start_symptomatic
Days after infection to become symptomatic.
Definition: Health.h:118
bool SymptomsStartedToday() const
Have the symptoms started today?
Definition: Health.h:86
unsigned short int GetEndInfectiousness() const
Definition: Health.h:46
unsigned short int m_start_infectiousness
Days after infection to become infectious.
Definition: Health.h:117
Namespace for the simulator and related classes.
Definition: Calendar.cpp:28
bool IsSusceptible() const
Is this person susceptible?
Definition: Health.h:77
void ResetDiseaseCounter()
Reset the disease counter.
Definition: Health.h:111
void IncrementDiseaseCounter()
Increment disease counter.
Definition: Health.h:108