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  // This is for internal use only, global events will be registered with a 'dummy' person instance
34  GlobalEventDummy
35  };
36 protected:
42  PersonBase(Gender g, double dateOfBirth);
43 public:
44  virtual ~PersonBase();
45 
46  void setPersonID(int64_t id);
47  int64_t getPersonID() const { return m_personID; }
48 
50  Gender getGender() const { return m_gender; }
51 
53  std::string getName() const { return m_name; }
54 
56  double getDateOfBirth() const { return m_dateOfBirth; }
57 
59  double getAgeAt(double t0) const { double age = t0 - m_dateOfBirth; assert(age >= 0); return age; }
60 
62  bool hasDied() const { return ! (m_timeOfDeath < 0); }
63 
65  void setTimeOfDeath(double t) { assert(m_timeOfDeath < 0); m_timeOfDeath = t; }
66 
68  double getTimeOfDeath() const { return m_timeOfDeath; }
69 
70  // TODO: Move this to a base class or shield from user in
71  // some other way?
72  // "PersonalEventList" is a good candidate, but conceptually
73  // it doesn't really make that much sense
74  void setListIndex(int i) { m_listIndex = i; }
75  int getListIndex() const { return m_listIndex; }
76 private:
77  Gender m_gender;
78  std::string m_name;
79  double m_dateOfBirth, m_timeOfDeath;
80 
81  int64_t m_personID;
82  int m_listIndex;
83 };
84 
85 class GlobalEventDummyPerson : public PersonBase
86 {
87 public:
88  GlobalEventDummyPerson() : PersonBase(GlobalEventDummy, -11111) { }
89  ~GlobalEventDummyPerson() { }
90 };
91 
92 #endif // PERSONBASE_H
93 
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:59
Gender getGender() const
Returns the gender of the person as set at construction time.
Definition: personbase.h:50
bool hasDied() const
Returns a flag indicating if the person has died.
Definition: personbase.h:62
std::string getName() const
Returns a name with which the person can be identified.
Definition: personbase.h:53
This class provides functions for a population-based simulation using the modified Next Reaction Meth...
Definition: population.h:83
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:56
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:65
double getTimeOfDeath() const
Retrieves the time of death of the person, negative meaning that the person is still alive...
Definition: personbase.h:68