use crate::{
db::{atom::AtomDB, keys::ClauseKey},
structures::{
clause::{vClause, Clause},
literal::abLiteral,
},
};
use std::ops::Deref;
#[doc(hidden)]
mod subsumption;
#[doc(hidden)]
mod watches;
#[allow(non_camel_case_types)]
pub struct dbClause {
key: ClauseKey,
clause: vClause,
active: bool,
watch_ptr: usize,
}
impl dbClause {
pub fn from(key: ClauseKey, clause: vClause, atoms: &mut AtomDB) -> Self {
let mut db_clause = Self {
key,
clause,
active: true,
watch_ptr: 0,
};
db_clause.initialise_watches(atoms);
db_clause
}
pub const fn key(&self) -> ClauseKey {
self.key
}
pub fn is_active(&self) -> bool {
self.active
}
pub fn activate(&mut self) {
self.active = true
}
pub fn deactivate(&mut self) {
self.active = false
}
}
impl std::fmt::Display for dbClause {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{}", self.clause.as_string())
}
}
impl Deref for dbClause {
type Target = [abLiteral];
fn deref(&self) -> &Self::Target {
&self.clause
}
}