Simpact Cyan
Population based event driven simulation using mNRM
populationstatesimpleadvancedcommon.h
1 #ifndef POPULATIONSTATESIMPLEADVANCEDCOMMON_H
2 
3 #define POPULATIONSTATESIMPLEADVANCEDCOMMON_H
4 
5 #include "populationinterfaces.h"
6 #include <assert.h>
7 #include <vector>
8 
9 class PersonBase;
10 
11 class PopulationStateSimpleAdvancedCommon : public PopulationStateInterface
12 {
13 public:
14  PopulationStateSimpleAdvancedCommon();
15  ~PopulationStateSimpleAdvancedCommon();
16 
17  PersonBase **getAllPeople() { if (m_people.size() == m_numGlobalDummies) return 0; return &(m_people[m_numGlobalDummies]); }
18  PersonBase **getMen();
19  PersonBase **getWomen();
20  PersonBase **getDeceasedPeople() { if (m_deceasedPersons.size() == 0) return 0; return &(m_deceasedPersons[0]); }
21 
22  int getNumberOfPeople() const { int num = (int)m_people.size() - m_numGlobalDummies; assert(num >= 0); return num; }
23  int getNumberOfMen() const { return m_numMen; }
24  int getNumberOfWomen() const { return m_numWomen; }
25  int getNumberOfDeceasedPeople() const { return m_deceasedPersons.size(); }
26 
27  void addNewPerson(PersonBase *pPerson);
28  void setPersonDied(PersonBase *pPerson);
29  void markAffectedPerson(PersonBase *pPerson) const;
30 protected:
31  virtual int64_t getNextPersonID() = 0;
32  virtual void addAlgorithmInfo(PersonBase *pPerson) = 0;
33  virtual void setListIndex(PersonBase *pPerson, int idx) = 0;
34  virtual int getListIndex(PersonBase *pPerson) = 0;
35 
36  // These are living persons, the first part men, the second are women
37  std::vector<PersonBase *> m_people;
38  int m_numMen, m_numWomen;
39  const int m_numGlobalDummies;
40 
41  // Deceased persons
42  std::vector<PersonBase *> m_deceasedPersons;
43  mutable std::vector<PersonBase *> m_otherAffectedPeople;
44 };
45 
46 #endif // POPULATIONSTATESIMPLEADVANCEDCOMMON_H
47 
virtual void setPersonDied(PersonBase *pPerson)=0
When a person has died, this function must be called to inform the simulation about this...
virtual PersonBase ** getWomen()=0
Same as PopulationStateInterface::getAllPeople, but only the women are returned.
virtual PersonBase ** getAllPeople()=0
Returns a list to the current living members in the population, introduced into the simulation using ...
virtual void markAffectedPerson(PersonBase *pPerson) const =0
This should only be called from within the PopulationEvent::markOtherAffectedPeople function...
virtual PersonBase ** getDeceasedPeople()=0
Returns the people who were part of the simulation but who are now deceased (intended for result anal...
virtual void addNewPerson(PersonBase *pPerson)=0
When a new person is introduced into the population, this function must be used to tell the simulatio...
virtual int getNumberOfMen() const =0
Returns the number of people in the array returned by PopulationStateInterface::getMen.
virtual int getNumberOfDeceasedPeople() const =0
Returns the number of people in the array returned by PopulationStateInterface::getDeceasedPeople.
virtual int getNumberOfPeople() const =0
Returns the number of people in the array returned by PopulationStateInterface::getAllPeople.
This is the base class for a person in a population-based simulation.
Definition: personbase.h:23
virtual int getNumberOfWomen() const =0
Returns the number of people in the array returned by PopulationStateInterface::getWomen.
virtual PersonBase ** getMen()=0
Same as PopulationStateInterface::getAllPeople, but only the men are returned.
Interface for a simulation state for the population-based algorithm, specifying member functions that...
Definition: populationinterfaces.h:26