delpi  0.0.1
DElta-complete LP solver
Loading...
Searching...
No Matches
Driver.h
1
7#pragma once
8
9#include <iosfwd>
10#include <string>
11
12#include "delpi/solver/LpSolver.h"
13#include "delpi/util/Stats.h"
14
15namespace delpi {
16
22class Driver {
23 public:
25 explicit Driver(LpSolver &lp_solver, const std::string &class_name = "Driver");
26 virtual ~Driver() = default;
27
35 bool ParseStream(std::istream &in, const std::string &sname = "stream input");
36
44 bool ParseString(std::string_view input, const std::string &sname = "string stream");
45
54 virtual bool ParseFile(const std::string &filename);
55
57 static void Error(const std::string &m);
58
60 void Solve();
65 void GetInfo(const std::string &key) const;
71 void SetInfo(const std::string &key, const std::string &value);
77 void SetOption(const std::string &key, const std::string &value);
78
80 void Exit();
81
83 [[nodiscard]] const LpSolver &lp_solver() const { return lp_solver_; }
85 [[nodiscard]] const Config &config() const { return lp_solver_.config(); }
87 [[nodiscard]] const std::string &stream_name() const { return input_name_; }
89 std::string &m_stream_name() { return input_name_; }
91 [[nodiscard]] const Stats &stats() const { return stats_; }
92
93 protected:
100 virtual bool ParseStreamCore(std::istream &in) = 0;
107 virtual bool ParseFileCore(const std::string &filename) = 0;
114 virtual bool ParseStringCore(std::string_view input) = 0;
116 std::string input_name_;
117
119
121};
122
123} // namespace delpi
Simple dataclass used to store the configuration of the program.
Definition Config.h:36
virtual bool ParseStreamCore(std::istream &in)=0
Parse the stream.
virtual bool ParseFileCore(const std::string &filename)=0
Parse the input file.
bool ParseString(std::string_view input, const std::string &sname="string stream")
Invoke the scanner and parser on an input string.
Definition Driver.cpp:28
LpSolver & lp_solver_
LP parser that will store the parsed data.
Definition Driver.h:113
Driver(LpSolver &lp_solver, const std::string &class_name="Driver")
construct a new parser driver context
Definition Driver.cpp:19
std::string input_name_
The name of the stream being parsed.
Definition Driver.h:111
virtual bool ParseStringCore(std::string_view input)=0
Parse the string.
static void Error(const std::string &m)
General error handling.
Definition Driver.cpp:39
virtual bool ParseFile(const std::string &filename)
Invoke the scanner and parser on a file.
Definition Driver.cpp:34
void Solve()
Call context_.CheckSat() and print proper output messages to the standard output.
Definition Driver.cpp:41
IterationStats stats_
Statistics for the driver.
Definition Driver.h:115
bool ParseStream(std::istream &in, const std::string &sname="stream input")
Invoke the scanner and parser for a stream.
Definition Driver.cpp:22
Dataclass collecting statistics about some operation or process.
Definition Stats.h:71
Facade class that hides the underlying LP solver used by delpi.
Definition LpSolver.h:60
Dataclass collecting statistics about some operation or process.
Definition Stats.h:22
Global namespace for the delpi library.