See

<project-file type=“source”/>

<content> #ifndef SIM_EMINDIVIDUAL_H #define SIM_EMINDIVIDUAL_H

#include <map> #include <simagent.h> #include <simpathogen.h>

class SimImmuneSystem {

  public:
      /** constructor */
      SimImmuneSystem();
      /** destructor */
      virtual ~SimImmuneSystem();
      
      /** immunity returns the probability of the pathogen to invade this individual */
      virtual float immunity(const SimPathogen*, float time)=0;
      /** infect informs the immune system of the infection of a new pathogen */
      virtual void infect(const SimPathogen *, float time)=0;

};

class SimInfectionHistory: public SimImmuneSystem {

  public:
      SimInfectionHistory();
      virtual ~SimInfectionHistory();
      
      virtual float immunity(const SimPathogen *, float time);
      virtual void infect(const SimPathogen *, float time);
  protected:
      /** History keeps track of all the previous infected pathogens and the infection time */
      std::map<SimID, float> History;

};

class SimEMIndividual; class SimInfectionState : public SimSchedule {

  public:
      enum SimInfectionStates {SIM_PROGRESS, SIM_DIE, SIM_MUTATE};
      /** the constructor */
      SimInfectionState(const SimPathogen * pathogen, float CurrentTime);
      /** destructor */ 
      virtual ~SimInfectionState();
      float infectivity() const {
          return (Stage == NULL) ? 0 : Stage->infectivity();
      }
      const SimPathogen *pathogen() const { return Pathogen; }
      const SimInfectionStage *stage() const { return Stage; }
      const SimPathogen *mutant() const { return Mutant; }
      enum SimInfectionStates nextState() const { return NextState; }

      /* implementing interfaces of CurrentGroup.Group-> */
      virtual void handler(float Time, SimProcess *process);
      class InvalidPathogen {};
  protected:
      void updateEvent(float CurrentTime);

      /** the pathogen */
      const SimPathogen *Pathogen;
      /** the current stage */
      const SimInfectionStage *Stage;
      union {
          /** next stage in progression */
          const SimInfectionStage *NextStage;
          /** the mutant */
          SimPathogen *Mutant;
      };
      /** current state */
      enum SimInfectionStates NextState;

};

class SimEMIndividual : public SimAgent {

  public:
      /** constructor */
      SimEMIndividual(SimID, SimImmuneSystem *);
      /** destructor */
      virtual ~SimEMIndividual();
      /** am I Infectious? */
      bool infectious() const;
      /** number of current infections */
      int infections() const { return Infections.size(); }
      /** the i-th infection */
      const SimInfectionState *infection(int i) const { return Infections[i]; }
      virtual void infectionStateChanged(float CurrentTime, SimInfectionState *State);
      /** infect infects this individual with a pathogen. If infected, 
       *  return true, otherwise return false. */
      virtual bool infect(const SimPathogen *p, float CurrentTime, SimProcess *process);
      /** pass all the infections to a victim */
      bool transmit(double Time, SimEMIndividual *victim, SimProcess *process);
  protected:
      /** the immune system */
      SimImmuneSystem *ImmuneSystem;
      /** the list all infections */
      std::vector<SimInfectionState*> Infections;

};

#endif </content>