Skip to content

Commit

Permalink
Added FSTI_HOOK_AGENT_INIT hook.
Browse files Browse the repository at this point in the history
  • Loading branch information
nathangeffen committed Sep 18, 2019
1 parent 8d63136 commit 7d91221
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/fsti-defaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ unsigned total_partners;
fsti_generate_infected(simulation, agent); \
fsti_generate_treated(simulation, agent); \
fsti_generate_resistant(simulation, agent); \
FSTI_HOOK_GENERATE_AGENT(simulation, agent) \
FSTI_HOOK_AGENT_GENERATE(simulation, agent) \
} while(0)
#endif

Expand Down Expand Up @@ -410,15 +410,15 @@ unsigned total_partners;
/*
Hook after an agent is created, but before being put in the agent array.
*/
#ifndef FSTI_HOOK_CREATE_AGENT
#define FSTI_HOOK_CREATE_AGENT(simulation, agent)
#ifndef FSTI_HOOK_AGENT_INIT
#define FSTI_HOOK_AGENT_INIT(simulation, agent)
#endif

/*
Hook after when an agent is generated at beginning of simulation.
*/
#ifndef FSTI_HOOK_GENERATE_AGENT
#define FSTI_HOOK_GENERATE_AGENT(simulation, agent)
#ifndef FSTI_HOOK_AGENT_GENERATE
#define FSTI_HOOK_AGENT_GENERATE(simulation, agent)
#endif


Expand Down
3 changes: 3 additions & 0 deletions src/fsti-events.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ make_agent(struct fsti_simulation *simulation,
#endif
simulation->csv_agent.iter_death = FSTI_MAX_ITERATION;
simulation->csv_agent.iter_cured = FSTI_MAX_ITERATION;
FSTI_HOOK_AGENT_INIT(simulation, (&simulation->csv_agent) );
for (j = 0; j < cs->rows[i].len; ++j) {
process_cell(simulation, &simulation->csv_agent,
cs->rows[i].cells[j],
Expand Down Expand Up @@ -438,6 +439,7 @@ fsti_event_generate_agents(struct fsti_simulation *simulation)
#endif
agent.iter_death = FSTI_MAX_ITERATION;
agent.iter_cured = FSTI_MAX_ITERATION;
FSTI_HOOK_AGENT_INIT(simulation, (&agent));
FSTI_AGENT_GENERATE(simulation, &agent);
fsti_agent_arr_push(&simulation->agent_arr, &agent);
}
Expand Down Expand Up @@ -525,6 +527,7 @@ fsti_event_birth(struct fsti_simulation *simulation)
#endif
agent.iter_death = FSTI_MAX_ITERATION;
agent.iter_cured = FSTI_MAX_ITERATION;
FSTI_HOOK_AGENT_INIT(simulation, (&agent));
FSTI_AGENT_BIRTH(simulation, &agent);
fsti_agent_arr_push(&simulation->agent_arr, &agent);
agent.id = simulation->agent_arr.len - 1;
Expand Down

0 comments on commit 7d91221

Please sign in to comment.