1 #ifndef POPULATIONEVENT_H
3 #define POPULATIONEVENT_H
15 #define POPULATIONEVENT_MAXPERSONS 2
80 void setGlobalEventPerson(
PersonBase *pDummyPerson);
81 void setEventID(int64_t
id) { assert(m_eventID < 0); assert(
id >= 0); m_eventID = id; }
82 int64_t getEventID()
const {
return m_eventID; }
88 int getNumberOfPersons()
const { assert(m_numPersons >= 0 && m_numPersons <= POPULATIONEVENT_MAXPERSONS);
return (
int)m_numPersons; }
110 virtual std::string
getDescription(
double tNow)
const {
return std::string(
"No description given"); }
114 void setEventIndex(
PersonBase *pPerson,
int idx);
117 void setScheduledForRemoval() { m_scheduledForRemoval =
true; }
118 bool isScheduledForRemoval()
const {
return m_scheduledForRemoval; }
120 bool isNoLongerUseful();
128 void commonConstructor();
130 PersonBase *m_pPersons[POPULATIONEVENT_MAXPERSONS];
131 int m_eventIndex[POPULATIONEVENT_MAXPERSONS];
134 bool m_scheduledForRemoval;
138 inline void PopulationEvent::setEventIndex(
PersonBase *pPerson,
int idx)
140 assert(pPerson != 0);
141 int num = m_numPersons;
143 for (
int i = 0 ; i < num ; i++)
145 assert(m_pPersons[i] != 0);
147 if (pPerson == m_pPersons[i])
149 m_eventIndex[i] = idx;
154 std::cerr <<
"PopulationEvent::setEventIndex: Consistency error: invalid Person object in setEventIndex" << std::endl;
158 inline int PopulationEvent::getEventIndex(
PersonBase *pPerson)
const
160 assert(pPerson != 0);
161 int num = m_numPersons;
163 for (
int i = 0 ; i < num ; i++)
165 assert(m_pPersons[i] != 0);
167 if (pPerson == m_pPersons[i])
168 return m_eventIndex[i];
171 std::cerr <<
"PopulationEvent::getEventIndex: Consistency error: invalid Person object in getEventIndex" << std::endl;
178 return m_pPersons[idx];
182 #endif // POPULATIONEVENT_H
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:126
int getNumberOfPersons() const
Returns the number of people specified during the creation of the event (will be one for global event...
Definition: populationevent.h:88
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:82
PopulationEvent()
Constructs a 'global' event.
Definition: populationevent.cpp:26
This is the base class for events in population-based simulations.
Definition: populationevent.h:61
virtual bool areGlobalEventsAffected() const
If global events (not referring to a particular person) are affected, this function can be overridden...
Definition: populationevent.h:104
This is the base class for a person in a population-based simulation.
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:110
virtual void markOtherAffectedPeople(const PopulationStateInterface &population)
If other people than the one(s) mentioned in the constructor are also affected by this event...
Definition: populationevent.h:100
virtual bool isEveryoneAffected() const
If the entire population is affected by this event (should be avoided!), this function can be overrid...
Definition: populationevent.h:96
This is the base class for events in the mNRM algorithm.
Definition: eventbase.h:55
Interface for a simulation state for the population-based algorithm, specifying member functions that...
Definition: populationinterfaces.h:26