use crate::{
config::Config,
db::{
atom::AtomDB, clause::ClauseDB, consequence_q::ConsequenceQ, literal::LiteralDB, ClauseKey,
},
reports::Report,
resolution_buffer::ResolutionBuffer,
types::err::ErrorKind,
};
use super::{callbacks::CallbackTerminate, ContextState, Counters};
pub struct GenericContext<R: rand::Rng + std::default::Default> {
pub config: Config,
pub counters: Counters,
pub atom_db: AtomDB,
pub clause_db: ClauseDB,
pub literal_db: LiteralDB,
pub consequence_q: ConsequenceQ,
pub state: ContextState,
pub rng: R,
pub resolution_buffer: ResolutionBuffer,
pub(super) callback_terminate: Option<Box<CallbackTerminate>>,
}
impl<R: rand::Rng + std::default::Default> GenericContext<R> {
pub fn report(&self) -> Report {
use crate::context::ContextState;
match self.state {
ContextState::Configuration | ContextState::Input | ContextState::Solving => {
Report::Unknown
}
ContextState::Satisfiable => Report::Satisfiable,
ContextState::Unsatisfiable(_) => Report::Unsatisfiable,
}
}
pub fn unsatisfiable_clause(&self) -> Result<ClauseKey, ErrorKind> {
match self.state {
ContextState::Unsatisfiable(key) => Ok(key),
_ => Err(ErrorKind::InvalidState),
}
}
}