egml_core/model/geometry/
abstract_geometry_property.rs1use crate::model::base::{
2 AssociationAttributes, HasAssociationAttributes, HasAssociationAttributesMut,
3 HasOwnershipAttributes, HasOwnershipAttributesMut, OwnershipAttributes,
4};
5use crate::model::geometry::abstract_geometry_kind::AbstractGeometryKind;
6use crate::model::xlink::HRef;
7
8#[derive(Debug, Clone, PartialEq)]
9pub struct AbstractGeometryProperty {
10 object: Option<AbstractGeometryKind>,
11 association: AssociationAttributes,
12 ownership: OwnershipAttributes,
13}
14
15impl AbstractGeometryProperty {
16 pub fn new(
17 object: Option<AbstractGeometryKind>,
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: AbstractGeometryKind) -> 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<&AbstractGeometryKind> {
45 self.object.as_ref()
46 }
47
48 pub fn object_mut(&mut self) -> Option<&mut AbstractGeometryKind> {
49 self.object.as_mut()
50 }
51
52 pub fn take_object(&mut self) -> Option<AbstractGeometryKind> {
53 self.object.take()
54 }
55
56 pub fn set_object(&mut self, object: AbstractGeometryKind) {
57 self.object = Some(object);
58 }
59
60 pub fn set_object_opt(&mut self, object: Option<AbstractGeometryKind>) {
61 self.object = object;
62 }
63
64 pub fn clear_object(&mut self) {
65 self.object = None;
66 }
67}
68
69impl HasAssociationAttributes for AbstractGeometryProperty {
70 fn association(&self) -> &AssociationAttributes {
71 &self.association
72 }
73}
74
75impl HasAssociationAttributesMut for AbstractGeometryProperty {
76 fn association_mut(&mut self) -> &mut AssociationAttributes {
77 &mut self.association
78 }
79}
80
81impl HasOwnershipAttributes for AbstractGeometryProperty {
82 fn ownership(&self) -> &OwnershipAttributes {
83 &self.ownership
84 }
85}
86
87impl HasOwnershipAttributesMut for AbstractGeometryProperty {
88 fn ownership_mut(&mut self) -> &mut OwnershipAttributes {
89 &mut self.ownership
90 }
91}