Skip to main content

egml_core/model/geometry/primitives/
shell_property.rs

1use crate::model::base::{
2    AssociationAttributes, HasAssociationAttributes, HasAssociationAttributesMut,
3    HasOwnershipAttributes, HasOwnershipAttributesMut, OwnershipAttributes,
4};
5use crate::model::geometry::primitives::shell::Shell;
6use crate::model::xlink::HRef;
7
8#[derive(Debug, Clone, PartialEq)]
9pub struct ShellProperty {
10    object: Option<Shell>,
11    association: AssociationAttributes,
12    ownership: OwnershipAttributes,
13}
14
15impl ShellProperty {
16    pub fn new(
17        object: Option<Shell>,
18        association: AssociationAttributes,
19        ownership: OwnershipAttributes,
20    ) -> Self {
21        Self {
22            object,
23            association,
24            ownership,
25        }
26    }
27
28    pub fn from_object(object: Shell) -> Self {
29        Self {
30            object: Some(object),
31            association: AssociationAttributes::default(),
32            ownership: OwnershipAttributes::default(),
33        }
34    }
35
36    pub fn from_href(href: HRef) -> Self {
37        Self {
38            object: None,
39            association: AssociationAttributes::new_href(href),
40            ownership: OwnershipAttributes::default(),
41        }
42    }
43
44    pub fn object(&self) -> Option<&Shell> {
45        self.object.as_ref()
46    }
47
48    pub fn object_mut(&mut self) -> Option<&mut Shell> {
49        self.object.as_mut()
50    }
51
52    pub fn take_object(&mut self) -> Option<Shell> {
53        self.object.take()
54    }
55
56    pub fn set_object(&mut self, object: Shell) {
57        self.object = Some(object);
58    }
59
60    pub fn set_object_opt(&mut self, object: Option<Shell>) {
61        self.object = object;
62    }
63
64    pub fn clear_object(&mut self) {
65        self.object = None;
66    }
67}
68
69impl HasAssociationAttributes for ShellProperty {
70    fn association(&self) -> &AssociationAttributes {
71        &self.association
72    }
73}
74
75impl HasAssociationAttributesMut for ShellProperty {
76    fn association_mut(&mut self) -> &mut AssociationAttributes {
77        &mut self.association
78    }
79}
80
81impl HasOwnershipAttributes for ShellProperty {
82    fn ownership(&self) -> &OwnershipAttributes {
83        &self.ownership
84    }
85}
86
87impl HasOwnershipAttributesMut for ShellProperty {
88    fn ownership_mut(&mut self) -> &mut OwnershipAttributes {
89        &mut self.ownership
90    }
91}