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

Add node_type to Optical trait.

parent ce3f1493
No related branches found
No related tags found
No related merge requests found
use crate::optic_node::Optical;
/// A fake / dummy conponent without any functions. It is mainly used for development and debugging purposes.
/// A fake / dummy component without any functions. It is mainly used for development and debugging purposes.
pub struct NodeDummy;
impl Optical for NodeDummy {
/// Returns "dummy" as node type.
fn node_type(&self) -> String {
"dummy".into()
}
}
\ No newline at end of file
......@@ -32,6 +32,10 @@ impl OpticNode {
pub fn to_dot(&self) -> String {
format!(" \"{}\"\n", self.name)
}
/// Returns the concrete node type as string representation.
pub fn node_type(&self) -> String {
self.node.node_type()
}
}
impl Debug for OpticNode {
......@@ -39,7 +43,14 @@ impl Debug for OpticNode {
write!(f, "{}", self.name)
}
}
pub trait Optical {}
/// This trait must be implemented by all concrete optical components.
pub trait Optical {
/// Return the type of the optical component (lens, filter, ...). The default implementation returns "undefined".
fn node_type(&self) -> String {
"undefined".into()
}
}
#[cfg(test)]
mod test {
......
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