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 "populationinterfaces.h"
10 #include <assert.h>
11 #include <string>
12 #include <list>
13 #include <set>
14 #include <iostream>
15 
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  // These are for internal use
47  void setPersonID(int64_t id);
48  int64_t getPersonID() const { return m_personID; }
49 
51  Gender getGender() const { return m_gender; }
52 
54  std::string getName() const { return m_name; }
55 
57  double getDateOfBirth() const { return m_dateOfBirth; }
58 
60  double getAgeAt(double t0) const { double age = t0 - m_dateOfBirth; assert(age >= 0); return age; }
61 
63  bool hasDied() const { return ! (m_timeOfDeath < 0); }
64 
66  void setTimeOfDeath(double t) { assert(m_timeOfDeath < 0); m_timeOfDeath = t; }
67 
69  double getTimeOfDeath() const { return m_timeOfDeath; }
70 
74  void setAlgorithmInfo(PersonAlgorithmInfo *pAlgInfo) { delete m_pAlgInfo; m_pAlgInfo = pAlgInfo; }
75 
77  PersonAlgorithmInfo *getAlgorithmInfo() const { return m_pAlgInfo; }
78 private:
79  Gender m_gender;
80  std::string m_name;
81  double m_dateOfBirth, m_timeOfDeath;
82 
83  int64_t m_personID;
84  PersonAlgorithmInfo *m_pAlgInfo;
85 };
86 
87 class GlobalEventDummyPerson : public PersonBase
88 {
89 public:
90  GlobalEventDummyPerson() : PersonBase(GlobalEventDummy, -11111) { }
91  ~GlobalEventDummyPerson() { }
92 };
93 
94 #endif // PERSONBASE_H
95 
Base class to be able to store algorithm-specific information in the PersonBase object for a person i...
Definition: populationinterfaces.h:145
This is the base class for a person in a population-based simulation.
Definition: personbase.h:24
void setAlgorithmInfo(PersonAlgorithmInfo *pAlgInfo)
This is only meant to be used by the implementation of an algorithm, and allows you to store algorith...
Definition: personbase.h:74
void setTimeOfDeath(double t)
Marks the person as deceased and stores the specified time of death.
Definition: personbase.h:66
PersonAlgorithmInfo * getAlgorithmInfo() const
Returns what was stored using PersonBase::PersonAlgorithmInfo.
Definition: personbase.h:77
double getAgeAt(double t0) const
Returns the age of the person at time t0.
Definition: personbase.h:60
Gender getGender() const
Returns the gender of the person as set at construction time.
Definition: personbase.h:51
double getTimeOfDeath() const
Retrieves the time of death of the person, negative meaning that the person is still alive.
Definition: personbase.h:69
bool hasDied() const
Returns a flag indicating if the person has died.
Definition: personbase.h:63
std::string getName() const
Returns a name with which the person can be identified.
Definition: personbase.h:54
Gender
The gender of a person.
Definition: personbase.h:28
@ Male
The person is a man.
Definition: personbase.h:30
@ Female
The person is a woman.
Definition: personbase.h:32
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
double getDateOfBirth() const
Returns the time at which the person was born, as specified in the constructor.
Definition: personbase.h:57