@@ -9,7 +9,8 @@ Author: Diffblue Ltd.
99#ifndef CPROVER_SOLVERS_SOLVER_HARDNESS_H
1010#define CPROVER_SOLVERS_SOLVER_HARDNESS_H
1111
12- #include < solvers/prop/literal.h>
12+ #include < solvers/hardness_collector.h>
13+ #include < solvers/prop/prop_conv_solver.h>
1314
1415#include < fstream>
1516#include < string>
@@ -38,7 +39,7 @@ Author: Diffblue Ltd.
3839// / derived class of \ref cnft for SAT solving). For this purpose the object
3940// / lives in the \ref solver_factoryt::solvert and pointers are passed to both
4041// / \ref decision_proceduret and \ref propt.
41- struct solver_hardnesst
42+ struct solver_hardnesst : public clause_hardness_collectort
4243{
4344 // From SAT solver we collect the number of clauses, the number of literals
4445 // and the number of distinct variables that were used in all clauses.
@@ -160,4 +161,26 @@ struct hash<solver_hardnesst::hardness_ssa_keyt>
160161};
161162} // namespace std
162163
164+ static inline void with_solver_hardness (
165+ decision_proceduret &maybe_hardness_collector,
166+ std::function<void (solver_hardnesst &hardness)> handler)
167+ {
168+ // FIXME I am wondering if there is a way to do this that is a bit less
169+ // dynamically typed.
170+ if (
171+ auto prop_conv_solver =
172+ dynamic_cast <prop_conv_solvert *>(&maybe_hardness_collector))
173+ {
174+ if (auto hardness_collector = prop_conv_solver->get_hardness_collector ())
175+ {
176+ if (hardness_collector->solver_hardness )
177+ {
178+ auto &solver_hardness = static_cast <solver_hardnesst &>(
179+ *(hardness_collector->solver_hardness ));
180+ handler (solver_hardness);
181+ }
182+ }
183+ }
184+ }
185+
163186#endif // CPROVER_SOLVERS_SOLVER_HARDNESS_H
0 commit comments