Helios++
Helios software for LiDAR simulations
StepLoop.h
1 #pragma once
2 
21 template <typename ... StepInput>
22 class StepLoop{
23 protected:
24  // *** ATTRIBUTES *** //
25  // ******************** //
51 
52 public:
53  // *** CONSTRUCTION / DESTRUCTION *** //
54  // ************************************ //
59  StepLoop(int const stepInterval) :
61  currentStep(0)
62  {}
63  virtual ~StepLoop() = default;
64 
65  // *** LOOP METHODS *** //
66  // ********************** //
72  virtual bool doStep(StepInput ... input){
73  bool computed = false;
74  if(currentStep == 0){
75  handleStep(input ...);
76  computed = true;
77  }
78  nextStep();
79  return computed;
80  }
81 
90  virtual void handleStep(StepInput ... input) = 0;
91 
96  virtual void nextStep(){
97  ++currentStep;
99  }
100 
101  // *** GETTERs and SETTERs *** //
102  // ***************************** //
108  virtual int getStepInterval() const {return stepInterval;}
114  virtual void setStepInterval(int const stepInterval)
115  {this->stepInterval = stepInterval;}
121  virtual int getCurrentStep() const {return currentStep;}
127  virtual void setCurrentStep(int const currentStep)
128  {this->currentStep = currentStep;}
129 
130 };
Abstract class providing the basics to handle loops inside simulation time, which is discrete because...
Definition: StepLoop.h:22
int currentStep
Stores the current step.
Definition: StepLoop.h:50
virtual void handleStep(StepInput ... input)=0
Handle the current step itself, before proceeding to next one.
virtual int getCurrentStep() const
Obtain the current step of the step loop.
Definition: StepLoop.h:121
virtual void nextStep()
Advances to current loop iteration, restarting the loop when as many steps as step interval have been...
Definition: StepLoop.h:96
virtual int getStepInterval() const
Obtain the step interval.
Definition: StepLoop.h:108
virtual void setStepInterval(int const stepInterval)
Set the step interval.
Definition: StepLoop.h:114
virtual bool doStep(StepInput ... input)
Handle current loop iteration and advances to next one by calling StepLoop::nextStep.
Definition: StepLoop.h:72
StepLoop(int const stepInterval)
Step loop constructor receiving interval and computation region function.
Definition: StepLoop.h:59
int stepInterval
Specify how many simulation steps must elapse so the step loop enters its computation region.
Definition: StepLoop.h:36
virtual void setCurrentStep(int const currentStep)
Set the current step for the step loop.
Definition: StepLoop.h:127