Molecular Dynamics Simulation  1.0
SimulationInterceptor.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <functional>
4 #include <memory>
5 
7 
9  public:
13  virtual ~SimulationInterceptor() = default;
14 
20  virtual void onSimulationStart(Simulation& simulation) = 0;
21 
30  virtual void operator()(size_t iteration, Simulation& simulation) = 0;
31 
39  virtual void onSimulationEnd(size_t iteration, Simulation& simulation) = 0;
40 
50  void notify(size_t iteration, Simulation& simulation) {
51  if (iteration % every_nth_iteration == 0) {
52  (*this)(iteration, simulation);
53  }
54  }
55 
64  virtual explicit operator std::string() const = 0;
65 
71  virtual void logSummary(int depth) const = 0;
72 
73  protected:
74  size_t every_nth_iteration = 1;
75 };
virtual void operator()(size_t iteration, Simulation &simulation)=0
Called on every nth iteration. This function should perform the desired action.
virtual void logSummary(int depth) const =0
Summary of the interceptor.
virtual ~SimulationInterceptor()=default
Destroy the Simulation Interceptor object.
virtual void onSimulationEnd(size_t iteration, Simulation &simulation)=0
Called after the simulation loop ends.
virtual void onSimulationStart(Simulation &simulation)=0
Called before the simulation loop starts.
void notify(size_t iteration, Simulation &simulation)
This function is called by the simulation loop on every iteration. Whenever the iteration is a multip...
Class to run a simulation.
Definition: Simulation.h:20