refactor: finish refactor of kernel
This commit is contained in:
@@ -105,15 +105,15 @@ pub struct App {
|
||||
impl App {
|
||||
/// Create a new app with the given configuration.
|
||||
pub fn new(config: AppConfig) -> Result<Self> {
|
||||
let datasets = SpecCatalog::from_file(
|
||||
config.get_resistor_dataset(),
|
||||
config.get_capacitor_dataset(),
|
||||
config.get_inductor_dataset(),
|
||||
let sepcs = SpecCatalog::from_file(
|
||||
config.get_resistor_spec(),
|
||||
config.get_capacitor_specs(),
|
||||
config.get_inductor_specs(),
|
||||
)?;
|
||||
|
||||
let resolver: Box<dyn Resolver> = match config.get_resolver() {
|
||||
AppResolver::Lut => Box::new(LutResolver::new(&datasets)?),
|
||||
AppResolver::Bfs => Box::new(BfsResolver::new(datasets)),
|
||||
AppResolver::Lut => Box::new(LutResolver::new(&sepcs)?),
|
||||
AppResolver::Bfs => Box::new(BfsResolver::new(sepcs)),
|
||||
};
|
||||
|
||||
Ok(Self { resolver })
|
||||
|
||||
@@ -6,12 +6,12 @@ use clap::{Parser, ValueEnum};
|
||||
pub struct AppConfig {
|
||||
/// The resolver for the app.
|
||||
resolver: AppResolver,
|
||||
/// The path to the resistor dataset file.
|
||||
resistor_dataset: PathBuf,
|
||||
/// The path to the capacitor dataset file.
|
||||
capacitor_dataset: PathBuf,
|
||||
/// The path to the inductor dataset file.
|
||||
inductor_dataset: PathBuf,
|
||||
/// The path to the resistor specs file.
|
||||
resistor_specs: PathBuf,
|
||||
/// The path to the capacitor specs file.
|
||||
capacitor_specs: PathBuf,
|
||||
/// The path to the inductor specs file.
|
||||
inductor_specs: PathBuf,
|
||||
}
|
||||
|
||||
impl AppConfig {
|
||||
@@ -19,17 +19,17 @@ impl AppConfig {
|
||||
pub fn get_resolver(&self) -> &AppResolver {
|
||||
&self.resolver
|
||||
}
|
||||
/// Get the path to the resistor dataset file.
|
||||
pub fn get_resistor_dataset(&self) -> &Path {
|
||||
&self.resistor_dataset
|
||||
/// Get the path to the resistor specs file.
|
||||
pub fn get_resistor_spec(&self) -> &Path {
|
||||
&self.resistor_specs
|
||||
}
|
||||
/// Get the path to the capacitor dataset file.
|
||||
pub fn get_capacitor_dataset(&self) -> &Path {
|
||||
&self.capacitor_dataset
|
||||
/// Get the path to the capacitor specs file.
|
||||
pub fn get_capacitor_specs(&self) -> &Path {
|
||||
&self.capacitor_specs
|
||||
}
|
||||
/// Get the path to the inductor dataset file.
|
||||
pub fn get_inductor_dataset(&self) -> &Path {
|
||||
&self.inductor_dataset
|
||||
/// Get the path to the inductor specs file.
|
||||
pub fn get_inductor_specs(&self) -> &Path {
|
||||
&self.inductor_specs
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,41 +57,41 @@ struct Cli {
|
||||
#[arg(short = 's', long = "resolver", required = true, value_enum)]
|
||||
resolver: AppResolver,
|
||||
|
||||
/// The path to the resistor dataset file.
|
||||
/// The path to the resistor specs file.
|
||||
#[arg(
|
||||
short = 'r',
|
||||
long = "resistor",
|
||||
required = true,
|
||||
value_name = "RESISTOR.TXT"
|
||||
)]
|
||||
resistor_dataset: PathBuf,
|
||||
resistor_specs: PathBuf,
|
||||
|
||||
/// The path to the inductor dataset file.
|
||||
/// The path to the inductor specs file.
|
||||
#[arg(
|
||||
short = 'l',
|
||||
long = "inductor",
|
||||
required = true,
|
||||
value_name = "INDUCTOR.TXT"
|
||||
)]
|
||||
inductor_dataset: PathBuf,
|
||||
inductor_specs: PathBuf,
|
||||
|
||||
/// The path to the capacitor dataset file.
|
||||
/// The path to the capacitor specs file.
|
||||
#[arg(
|
||||
short = 'c',
|
||||
long = "capacitor",
|
||||
required = true,
|
||||
value_name = "CAPACITOR.TXT"
|
||||
)]
|
||||
capacitor_dataset: PathBuf,
|
||||
capacitor_specs: PathBuf,
|
||||
}
|
||||
|
||||
impl From<Cli> for AppConfig {
|
||||
fn from(args: Cli) -> Self {
|
||||
Self {
|
||||
resolver: args.resolver,
|
||||
resistor_dataset: args.resistor_dataset,
|
||||
capacitor_dataset: args.capacitor_dataset,
|
||||
inductor_dataset: args.inductor_dataset,
|
||||
resistor_specs: args.resistor_specs,
|
||||
capacitor_specs: args.capacitor_specs,
|
||||
inductor_specs: args.inductor_specs,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user