diff --git a/src/nodes/node_dummy.rs b/src/nodes/node_dummy.rs index d71d07d116c46cd62b14236d509bf633d3972cc4..5ee52a0ba69ac6395d0dd06c421b47087e7c7578 100644 --- a/src/nodes/node_dummy.rs +++ b/src/nodes/node_dummy.rs @@ -1,8 +1,11 @@ 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 diff --git a/src/optic_node.rs b/src/optic_node.rs index 57cc26baed7a0320e83abc07ff2056582cfaec58..484eaf4d427adbbfbabc847641c721ad573481e8 100644 --- a/src/optic_node.rs +++ b/src/optic_node.rs @@ -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 {