-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restructure input processor modules.
- Loading branch information
SutekhVRC
committed
Dec 9, 2023
1 parent
2221b46
commit 7a1f642
Showing
6 changed files
with
93 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 0 additions & 44 deletions
44
src-tauri/src/toy_handling/input_processor/penetration_systems.rs
This file was deleted.
Oops, something went wrong.
51 changes: 51 additions & 0 deletions
51
src-tauri/src/toy_handling/input_processor/penetration_systems/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
pub mod sps; | ||
pub mod tps; | ||
|
||
use serde::{Deserialize, Serialize}; | ||
use ts_rs::TS; | ||
|
||
use crate::{ | ||
frontend::{frontend_types::FePenetrationSystem, ToFrontend}, | ||
toy_handling::toyops::{ProcessingMode, ProcessingModeValues}, | ||
}; | ||
|
||
use super::InputProcessor; | ||
|
||
#[derive(Clone, Debug, Serialize, Deserialize, TS)] | ||
#[ts(export)] | ||
pub enum PenetrationSystemType { | ||
NONE, | ||
TPS, | ||
SPS, | ||
} | ||
|
||
#[derive(Clone, Debug, Serialize, Deserialize, TS)] | ||
pub struct PenetrationSystem { | ||
#[serde(skip)] | ||
pub pen_system: Option<Box<dyn InputProcessor>>, | ||
pub pen_system_type: PenetrationSystemType, | ||
pub pen_system_processing_mode: ProcessingMode, | ||
#[serde(skip)] | ||
pub pen_system_processing_mode_values: ProcessingModeValues, | ||
} | ||
|
||
impl Default for PenetrationSystem { | ||
fn default() -> Self { | ||
Self { | ||
pen_system: None, | ||
pen_system_type: PenetrationSystemType::NONE, | ||
pen_system_processing_mode: ProcessingMode::Raw, | ||
pen_system_processing_mode_values: ProcessingModeValues::Raw, | ||
} | ||
} | ||
} | ||
|
||
impl ToFrontend<FePenetrationSystem> for PenetrationSystem { | ||
type OutputType = FePenetrationSystem; | ||
fn to_frontend(&self) -> Self::OutputType { | ||
FePenetrationSystem { | ||
pen_system_type: self.pen_system_type.clone(), | ||
pen_system_processing_mode: self.pen_system_processing_mode.to_frontend(), | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src-tauri/src/toy_handling/input_processor/penetration_systems/sps/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use serde::{Deserialize, Serialize}; | ||
use ts_rs::TS; | ||
|
||
use crate::toy_handling::{input_processor::InputProcessor, ModeProcessorInputType}; | ||
|
||
#[derive(Clone, Debug, Serialize, Deserialize, TS)] | ||
pub struct SPSProcessor { | ||
pub parameter_list: Vec<String>, | ||
} | ||
|
||
impl InputProcessor for SPSProcessor { | ||
fn is_parameter(&self, param: &String) -> bool { | ||
self.parameter_list.contains(param) | ||
} | ||
|
||
fn process(&self, _input: ModeProcessorInputType) -> Option<f64> { | ||
todo!() | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src-tauri/src/toy_handling/input_processor/penetration_systems/tps/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use serde::{Deserialize, Serialize}; | ||
use ts_rs::TS; | ||
|
||
use crate::toy_handling::{input_processor::InputProcessor, ModeProcessorInputType}; | ||
|
||
#[derive(Clone, Debug, Serialize, Deserialize, TS)] | ||
pub struct TPSProcessor { | ||
pub parameter_list: Vec<String>, | ||
} | ||
|
||
impl InputProcessor for TPSProcessor { | ||
fn is_parameter(&self, param: &String) -> bool { | ||
self.parameter_list.contains(param) | ||
} | ||
|
||
fn process(&self, _input: ModeProcessorInputType) -> Option<f64> { | ||
todo!() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters