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

Use rc as underlying node...

parent 66d1e2e9
No related branches found
No related tags found
No related merge requests found
......@@ -4,12 +4,12 @@ use crate::optic_node::{OpticNode, Optical};
/// A virtual component referring to another existing component. This node type is necessary in order to model resonators (loops) or double-pass systems.
pub struct NodeReference {
reference: Weak<OpticNode>,
reference: Rc<dyn Optical>,
}
impl NodeReference {
pub fn new(node: OpticNode) -> Self {
Self { reference: Rc::downgrade(&Rc::new(node)) }
pub fn new(node: &OpticNode) -> Self {
Self { reference: node.node_ref() }
}
}
......
use std::fmt::Debug;
use std::{fmt::Debug, rc::Rc};
use crate::optic_ports::OpticPorts;
/// An [`OpticNode`] is the basic struct representing an optical component.
pub struct OpticNode {
name: String,
node: Box<dyn Optical>,
node: Rc<dyn Optical>,
ports: OpticPorts
}
......@@ -24,7 +24,7 @@ impl OpticNode {
let ports=node_type.ports();
Self {
name: name.into(),
node: Box::new(node_type),
node: Rc::new(node_type),
ports
}
}
......@@ -59,6 +59,9 @@ impl OpticNode {
pub fn ports(&self) -> &OpticPorts {
&self.ports
}
pub fn node_ref(&self) -> Rc<dyn Optical> {
self.node.clone()
}
}
impl Debug for 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