Stride Reference Manual  1.0
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, Willem L, Kuylen E, Stijven S & Broeckhove J
14  */
15 
16 #include "Health.h"
17 
18 #include <assert.h>
19 
20 namespace stride {
21 
22 
23 Health::Health(unsigned int start_infectiousness, unsigned int start_symptomatic,
24  unsigned int time_infectious, unsigned int time_symptomatic) :
25  m_disease_counter(0U), m_status(HealthStatus::Susceptible),
26  m_start_infectiousness(start_infectiousness), m_start_symptomatic(start_symptomatic) {
27  m_end_infectiousness = start_infectiousness + time_infectious;
28  m_end_symptomatic = start_symptomatic + time_symptomatic;
29 }
30 
36  m_end_symptomatic = 0U;
37 }
38 
40  // TODO why does assertion this fail?
41  //assert(m_status == HealthStatus::Susceptible
42  // && "Health::startInfection: m_health_status == DiseaseStatus::Susceptible fails.");
45 }
46 
50  && "Health::stopInfection> person not infected");
52 }
53 
55  const bool infected = m_status == HealthStatus::Exposed
59 
60  if (infected) {
65  } else {
67  }
68  } else if (getDiseaseCounter() == m_end_infectiousness) {
71  } else {
72  stopInfection();
73  }
74  } else if (getDiseaseCounter() == m_start_symptomatic) {
77  } else {
79  }
80  } else if (getDiseaseCounter() == m_end_symptomatic) {
83  } else {
84  stopInfection();
85  }
86  }
87  }
88 }
89 
90 }
91 
unsigned int getDiseaseCounter() const
Get the disease counter.
Definition: Health.h:89
Health(unsigned int start_infectiousness, unsigned int start_symptomatic, unsigned int time_infectious, unsigned int time_symptomatic)
Definition: Health.cpp:23
void stopInfection()
Stop the infection.
Definition: Health.cpp:47
Time Dependent Person DataType.
Definition: NoBehaviour.h:17
void resetDiseaseCounter()
Reset the disease counter.
Definition: Health.h:95
void incrementDiseaseCounter()
Increment disease counter.
Definition: Health.h:92
unsigned int m_start_infectiousness
Days after infection to become infectious.
Definition: Health.h:101
unsigned int m_end_infectiousness
Days after infection to end infectious state.
Definition: Health.h:103
HealthStatus m_status
The current status of the person w.r.t. the disease.
Definition: Health.h:99
HealthStatus
Definition: Health.h:19
void update()
Update progress of the disease.
Definition: Health.cpp:54
unsigned int m_start_symptomatic
Days after infection to become symptomatic.
Definition: Health.h:102
unsigned int m_end_symptomatic
Days after infection to end symptomatic state.
Definition: Health.h:104
void startInfection()
Start the infection.
Definition: Health.cpp:39
void setImmune()
Set immune to true.
Definition: Health.cpp:31