1 #ifndef POPULATIONEVENT_H
3 #define POPULATIONEVENT_H
16 #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; }
108 virtual std::string
getDescription(
double tNow)
const {
return std::string(
"No description given"); }
112 void setEventIndex(
PersonBase *pPerson,
int idx);
115 void setScheduledForRemoval() { m_scheduledForRemoval =
true; }
116 bool isScheduledForRemoval()
const {
return m_scheduledForRemoval; }
118 bool isNoLongerUseful();
126 void commonConstructor();
128 PersonBase *m_pPersons[POPULATIONEVENT_MAXPERSONS];
129 int m_eventIndex[POPULATIONEVENT_MAXPERSONS];
132 bool m_scheduledForRemoval;
136 inline void PopulationEvent::setEventIndex(
PersonBase *pPerson,
int idx)
138 assert(pPerson != 0);
139 int num = m_numPersons;
141 for (
int i = 0 ; i < num ; i++)
143 assert(m_pPersons[i] != 0);
145 if (pPerson == m_pPersons[i])
147 m_eventIndex[i] = idx;
152 std::cerr <<
"PopulationEvent::setEventIndex: Consistency error: invalid Person object in setEventIndex" << std::endl;
156 inline int PopulationEvent::getEventIndex(
PersonBase *pPerson)
const
158 assert(pPerson != 0);
159 int num = m_numPersons;
161 for (
int i = 0 ; i < num ; i++)
163 assert(m_pPersons[i] != 0);
165 if (pPerson == m_pPersons[i])
166 return m_eventIndex[i];
169 std::cerr <<
"PopulationEvent::getEventIndex: Consistency error: invalid Person object in getEventIndex" << std::endl;
176 return m_pPersons[idx];
180 #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:124
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
This class provides functions for a population-based simulation using the modified Next Reaction Meth...
Definition: population.h:83
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:83
PopulationEvent()
Constructs a 'global' event.
Definition: populationevent.cpp:27
virtual void markOtherAffectedPeople(const Population &population)
If other people than the one(s) mentioned in the constructor are also affected by this event...
Definition: populationevent.h:100
This is the base class for events in population-based simulations which use the Population class...
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 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:108
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:62