Flowlessly  0.1
Minimum cost maximum cost solver
 All Classes Functions Pages
solver.h
1 // The Flowlessly project
2 // Copyright (c) 2013-2016 Ionel Gog <ionel.gog@cl.cam.ac.uk>
3 
4 #ifndef FLOWLESSLY_SOLVER_H
5 #define FLOWLESSLY_SOLVER_H
6 
7 #include <boost/thread/latch.hpp>
8 
9 #include "misc/statistics.h"
10 #include "misc/utils.h"
11 
12 namespace flowlessly {
13 
14 class Solver {
15  public:
16  explicit Solver(Statistics* stats) : stats_(stats), latch_(NULL) {}
17  virtual ~Solver() {
18  // The solver is not the owner of the stats object.
19  }
20 
21  inline void LogStatistics() {
22  stats_->LogStatistics();
23  }
24 
25  inline void ResetStatistics() {
26  stats_->ResetStatistics();
27  }
28 
33  virtual bool Run() = 0;
34 
35  virtual void PrepareState() = 0;
36 
37  void SetLatch(boost::latch* latch) {
38  latch_ = latch;
39  }
40 
41  protected:
42  Statistics* stats_;
43  boost::latch* latch_;
44 };
45 
46 } // namespace flowlessly
47 #endif // FLOWLESSLY_SOLVER_H
Definition: statistics.h:19
Definition: solver.h:14
virtual bool Run()=0