Skip to content
Snippets Groups Projects
Commit 037b942d authored by Udo Eisenbarth's avatar Udo Eisenbarth :speech_balloon:
Browse files

Work on alayzer structure

parent 212e0a37
No related branches found
No related tags found
No related merge requests found
trait Analyzer {}
struct AnalyzerEnergy{}
impl Analyzer for AnalyzerEnergy {}
struct AnalyzerRay{}
impl Analyzer for AnalyzerRay {}
trait Analyzable<T: Analyzer> {
fn analyze(&self, analyzer: T) {
println!("Default Analyze");
}
}
trait Optical {}
struct Lens {}
impl Analyzable<AnalyzerEnergy> for Lens {
fn analyze(&self, analyzer: AnalyzerEnergy) {
println!("Lens Analyze Energy");
}
}
impl Analyzable<AnalyzerRay> for Lens {
fn analyze(&self, analyzer: AnalyzerRay) {
println!("Lens Analyze Ray");
}
}
impl Optical for Lens {}
struct Mirror {}
impl Analyzable<AnalyzerEnergy> for Mirror {
fn analyze(&self, analyzer: AnalyzerEnergy) {
println!("Mirror Analyze Energy");
}
}
impl Analyzable<AnalyzerRay> for Mirror {
fn analyze(&self, analyzer: AnalyzerRay) {
println!("Mirror Analyze Ray");
}
}
impl Optical for Mirror {}
fn main() {
let lens= Lens{};
let mirror= Mirror{};
let comp: Vec<Box<dyn Optical>> = vec![Box::new(lens), Box::new(mirror)];
//comp[0].analyze(AnalyzerEnergy{});
// lens.analyze(AnalyzerRay{});
// mirror.analyze(AnalyzerEnergy{});
// mirror.analyze(AnalyzerRay{});
}
\ No newline at end of file
use crate::optic_scenery::OpticScenery;
pub trait Analyzer {}
#[derive(Debug)]
pub struct AnalyzerEnergy {
scene: OpticScenery
scene: OpticScenery,
}
impl AnalyzerEnergy {
pub fn new(scenery: &OpticScenery) -> Self {
Self { scene: (*scenery).to_owned()}
}
pub fn analyze(&self) {
for node in self.scene.nodes_topological().unwrap() {
println!("Node: {}", node.name())
pub fn new(scenery: &OpticScenery) -> Self {
Self {
scene: (*scenery).to_owned(),
}
}
pub fn analyze(&self) {
for node in self.scene.nodes_topological().unwrap() {
println!("Node: {}", node.name())
}
}
}
}
\ No newline at end of file
}
impl Analyzer for AnalyzerEnergy {}
\ No newline at end of file
use std::{fmt::Debug, rc::Rc};
use std::fmt::Debug;
use crate::analyzer::{Analyzer, AnalyzerEnergy};
use crate::nodes::NodeDummy;
use crate::optic_ports::OpticPorts;
/// An [`OpticNode`] is the basic struct representing an optical component.
pub struct OpticNode {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment