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