use bitflags::bitflags;
use crate::{Label, KDELTA};
bitflags! {
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct FactorWeightType: u32 {
const FACTOR_FINAL_WEIGHTS = 0b01;
const FACTOR_ARC_WEIGHTS = 0b10;
}
}
#[cfg(test)]
impl FactorWeightType {
pub fn from_bools(factor_final_weights: bool, factor_tr_weights: bool) -> FactorWeightType {
match (factor_final_weights, factor_tr_weights) {
(true, true) => {
FactorWeightType::FACTOR_FINAL_WEIGHTS | FactorWeightType::FACTOR_ARC_WEIGHTS
}
(true, false) => FactorWeightType::FACTOR_FINAL_WEIGHTS,
(false, true) => FactorWeightType::FACTOR_ARC_WEIGHTS,
(false, false) => Self::empty(),
}
}
}
#[derive(Clone, Debug, PartialEq)]
pub struct FactorWeightOptions {
pub delta: f32,
pub mode: FactorWeightType,
pub final_ilabel: Label,
pub final_olabel: Label,
pub increment_final_ilabel: bool,
pub increment_final_olabel: bool,
}
impl FactorWeightOptions {
#[allow(unused)]
pub fn new(mode: FactorWeightType) -> FactorWeightOptions {
FactorWeightOptions {
delta: KDELTA,
mode,
final_ilabel: 0,
final_olabel: 0,
increment_final_ilabel: false,
increment_final_olabel: false,
}
}
}