1 #ifndef POPULATIONEVENT_H
3 #define POPULATIONEVENT_H
16 #define POPULATIONEVENT_MAXPERSONS 2
70 void setEventID(int64_t
id) { assert(m_eventID < 0); assert(
id >= 0); m_eventID = id; }
71 int64_t getEventID()
const {
return m_eventID; }
75 int getNumberOfPersons()
const { assert(m_numPersons >= 0 && m_numPersons <= POPULATIONEVENT_MAXPERSONS);
return (
int)m_numPersons; }
94 virtual std::string
getDescription(
double tNow)
const {
return std::string(
"No description given"); }
98 void setEventIndex(
PersonBase *pPerson,
int idx);
101 void setScheduledForRemoval() { m_scheduledForRemoval =
true; }
102 bool isScheduledForRemoval()
const {
return m_scheduledForRemoval; }
104 bool isNoLongerUseful();
112 void commonConstructor();
114 PersonBase *m_pPersons[POPULATIONEVENT_MAXPERSONS];
115 int m_eventIndex[POPULATIONEVENT_MAXPERSONS];
118 bool m_scheduledForRemoval;
122 inline void PopulationEvent::setEventIndex(
PersonBase *pPerson,
int idx)
124 assert(pPerson != 0);
125 int num = m_numPersons;
127 for (
int i = 0 ; i < num ; i++)
129 assert(m_pPersons[i] != 0);
131 if (pPerson == m_pPersons[i])
133 m_eventIndex[i] = idx;
138 std::cerr <<
"PopulationEvent::setEventIndex: Consistency error: invalid Person object in setEventIndex" << std::endl;
142 inline int PopulationEvent::getEventIndex(
PersonBase *pPerson)
const
144 assert(pPerson != 0);
145 int num = m_numPersons;
147 for (
int i = 0 ; i < num ; i++)
149 assert(m_pPersons[i] != 0);
151 if (pPerson == m_pPersons[i])
152 return m_eventIndex[i];
155 std::cerr <<
"PopulationEvent::getEventIndex: Consistency error: invalid Person object in getEventIndex" << std::endl;
162 return m_pPersons[idx];
166 #endif // POPULATIONEVENT_H
virtual PersonBase * getNextOtherAffectedPerson()
Retrieves an affected person and advaces the iteration (should return 0 if no more persons are affect...
Definition: populationevent.h:90
virtual bool isUseless()
This function can be used to inform the algorithm that an event is no longer of any use and should be...
Definition: populationevent.h:110
virtual void startOtherAffectedPersonIteration()
Starts the iteration of the other affected persons.
Definition: populationevent.h:86
int getNumberOfPersons() const
Returns the number of people specified during the creation of the event.
Definition: populationevent.h:75
PersonBase * getPerson(int idx) const
Returns a person that was specified when the event was constructed, where idx can range from 0 to Pop...
Definition: populationevent.cpp:74
This is the base class for events in population-based simulations which use the Population class...
Definition: populationevent.h:58
This is the base class for a person in a population-based simulation that used the Population class...
Definition: personbase.h:23
virtual std::string getDescription(double tNow) const
Returns a short description of the event, can be useful for logging/debugging purposes.
Definition: populationevent.h:94
This is the base class for events in the mNRM algorithm.
Definition: eventbase.h:60
virtual int getNumberOfOtherAffectedPersons() const
Returns the number of persons that are also affected by the firing of the event (see the detailed des...
Definition: populationevent.h:83