XGCa
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
step_trigger.hpp
Go to the documentation of this file.
1 #ifndef STEP_TRIGGER_HPP
2 #define STEP_TRIGGER_HPP
3 
4 class StepTrigger{
5  int period;
6  int first_step;
7 
8  public:
9 
11 
13  : period(period),
15 
16  /* Returns whether or not the action is triggered this step
17  * */
18  bool execute(int step){
19  int steps_since_first = step - first_step;
20  return (step>=first_step && steps_since_first%period==0);
21  }
22 };
23 
24 #endif
int period
Number of steps between trigger.
Definition: step_trigger.hpp:5
StepTrigger()
Definition: step_trigger.hpp:10
int first_step
First step it can be called.
Definition: step_trigger.hpp:6
StepTrigger(int period, int first_step=0)
Definition: step_trigger.hpp:12
bool execute(int step)
Definition: step_trigger.hpp:18
Definition: step_trigger.hpp:4