Simpact Cyan
Population based event driven simulation using mNRM
personbase.h
Go to the documentation of this file.
1 #ifndef PERSONBASE_H
2 
3 #define PERSONBASE_H
4 
9 #include "personaleventlist.h"
10 #include <assert.h>
11 #include <string>
12 #include <list>
13 #include <set>
14 #include <iostream>
15 
16 class Population;
17 
23 class PersonBase : public PersonalEventList
24 {
25 public:
27  enum Gender
28  {
30  Male,
33  };
34 protected:
40  PersonBase(Gender g, double dateOfBirth);
41 public:
42  virtual ~PersonBase();
43 
44  void setPersonID(int64_t id);
45  int64_t getPersonID() const { return m_personID; }
46 
48  Gender getGender() const { return m_gender; }
49 
51  std::string getName() const { return m_name; }
52 
54  double getDateOfBirth() const { return m_dateOfBirth; }
55 
57  double getAgeAt(double t0) const { double age = t0 - m_dateOfBirth; assert(age >= 0); return age; }
58 
60  bool hasDied() const { return ! (m_timeOfDeath < 0); }
61 
63  void setTimeOfDeath(double t) { assert(m_timeOfDeath < 0); m_timeOfDeath = t; }
64 
65  // TODO: Move this to a base class or shield from user in
66  // some other way?
67  // "PersonalEventList" is a good candidate, but conceptually
68  // it doesn't really make that much sense
69  void setListIndex(int i) { m_listIndex = i; }
70  int getListIndex() const { return m_listIndex; }
71 private:
72  Gender m_gender;
73  std::string m_name;
74  double m_dateOfBirth, m_timeOfDeath;
75 
76  int64_t m_personID;
77  int m_listIndex;
78 };
79 
80 #endif // PERSONBASE_H
81 
The person is a man.
Definition: personbase.h:30
double getAgeAt(double t0) const
Returns the age of the person at time t0.
Definition: personbase.h:57
Gender getGender() const
Returns the gender of the person as set at construction time.
Definition: personbase.h:48
bool hasDied() const
Returns a flag indicating if the person has died.
Definition: personbase.h:60
std::string getName() const
Returns a name with which the person can be identified.
Definition: personbase.h:51
This class provides functions for a population-based simulation using the modified Next Reaction Meth...
Definition: population.h:77
The person is a woman.
Definition: personbase.h:32
Gender
The gender of a person.
Definition: personbase.h:27
double getDateOfBirth() const
Returns the time at which the person was born, as specified in the constructor.
Definition: personbase.h:54
PersonBase(Gender g, double dateOfBirth)
Create a new person of gender g and which was born at the specified time in the simulation.
Definition: personbase.cpp:6
This is the base class for a person in a population-based simulation that used the Population class...
Definition: personbase.h:23
void setTimeOfDeath(double t)
Marks the person as deceased and stores the specified time of death.
Definition: personbase.h:63