Stride Reference Manual  - generated for commit 9643b11
Health.cpp
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, 2018 Kuylen E, Willem L, Broeckhove J
14  */
15 
21 #include "Health.h"
22 
23 #include "util/Assert.h"
24 
25 namespace stride {
26 
27 Health::Health(unsigned short int start_infectiousness, unsigned short int start_symptomatic,
28  unsigned short int time_infectious, unsigned short int time_symptomatic)
29  : m_disease_counter(0U), m_status(HealthStatus::Susceptible), m_start_infectiousness(start_infectiousness),
30  m_start_symptomatic(start_symptomatic), m_end_infectiousness(start_infectiousness + time_infectious),
31  m_end_symptomatic(start_symptomatic + time_symptomatic)
32 {
33 }
34 
36 {
37  AssertThrow(m_status == HealthStatus::Susceptible, "Inconsistent Health change", nullptr);
40 }
41 
43 {
44  AssertThrow(IsInfected(), "Person not infected", nullptr);
46 }
47 
49 {
50  if (IsInfected()) {
55  } else {
57  }
58  }
62  } else {
64  }
65  }
69  } else {
70  StopInfection();
71  }
72  }
76  } else {
77  StopInfection();
78  }
79  }
80  }
81 }
82 
83 } // namespace stride
unsigned short int m_end_infectiousness
Days after infection to end infectious state.
Definition: Health.h:119
unsigned short int m_end_symptomatic
Days after infection to end symptomatic state.
Definition: Health.h:120
unsigned short int GetDiseaseCounter() const
Get the disease counter.
Definition: Health.h:105
HealthStatus m_status
The current status of the person w.r.t. the disease.
Definition: Health.h:115
#define AssertThrow(CONDITION, MESSAGE, LOGGER)
Definition: Assert.h:68
Header for the Health class.
HealthStatus
Enumerate the various health states with respect to the infection.
Definition: Health.h:26
Definition of .
bool IsInfected() const
Is this person infected?
Definition: Health.h:61
Health(unsigned short int start_infectiousness=0U, unsigned int short start_symptomatic=0U, unsigned short int time_infectious=0U, unsigned short int time_symptomatic=0U)
Definition: Health.cpp:27
unsigned short int m_start_symptomatic
Days after infection to become symptomatic.
Definition: Health.h:118
unsigned short int m_start_infectiousness
Days after infection to become infectious.
Definition: Health.h:117
void Update()
Update progress of the disease.
Definition: Health.cpp:48
Namespace for the simulator and related classes.
Definition: Calendar.cpp:28
void StopInfection()
Stop the infection.
Definition: Health.cpp:42
void StartInfection()
Start the infection.
Definition: Health.cpp:35
void ResetDiseaseCounter()
Reset the disease counter.
Definition: Health.h:111
void IncrementDiseaseCounter()
Increment disease counter.
Definition: Health.h:108