Skip to main content

ecitygml_core/model/building/
building_constructive_element.rs

1use crate::model::construction::{
2    AbstractConstructiveElement, AsAbstractConstructiveElement, AsAbstractConstructiveElementMut,
3};
4use crate::model::core::{
5    AsAbstractOccupiedSpace, AsAbstractOccupiedSpaceMut, CityObjectKind, CityObjectRef,
6};
7use crate::operations::{Visitable, Visitor};
8use egml::model::basic::Code;
9
10#[derive(Debug, Clone, PartialEq)]
11pub struct BuildingConstructiveElement {
12    pub abstract_constructive_element: AbstractConstructiveElement,
13    pub(crate) class: Option<Code>,
14    pub(crate) functions: Vec<Code>,
15    pub(crate) usages: Vec<Code>,
16}
17
18impl BuildingConstructiveElement {
19    pub fn new(abstract_constructive_element: AbstractConstructiveElement) -> Self {
20        Self {
21            abstract_constructive_element,
22            class: None,
23            functions: Vec::new(),
24            usages: Vec::new(),
25        }
26    }
27
28    pub fn class(&self) -> &Option<Code> {
29        &self.class
30    }
31
32    pub fn set_class(&mut self, class: Option<Code>) {
33        self.class = class;
34    }
35
36    pub fn functions(&self) -> &Vec<Code> {
37        &self.functions
38    }
39
40    pub fn set_functions(&mut self, functions: Vec<Code>) {
41        self.functions = functions;
42    }
43
44    pub fn usages(&self) -> &Vec<Code> {
45        &self.usages
46    }
47
48    pub fn set_usages(&mut self, usages: Vec<Code>) {
49        self.usages = usages;
50    }
51
52    pub fn iter_city_object<'a>(&'a self) -> impl Iterator<Item = CityObjectRef<'a>> + 'a {
53        std::iter::once(CityObjectRef::BuildingConstructiveElement(self))
54    }
55}
56
57impl AsAbstractConstructiveElement for BuildingConstructiveElement {
58    fn abstract_constructive_element(&self) -> &AbstractConstructiveElement {
59        &self.abstract_constructive_element
60    }
61}
62
63impl AsAbstractConstructiveElementMut for BuildingConstructiveElement {
64    fn abstract_constructive_element_mut(&mut self) -> &mut AbstractConstructiveElement {
65        &mut self.abstract_constructive_element
66    }
67}
68
69crate::impl_abstract_constructive_element_traits!(BuildingConstructiveElement);
70
71impl From<BuildingConstructiveElement> for CityObjectKind {
72    fn from(item: BuildingConstructiveElement) -> Self {
73        CityObjectKind::BuildingConstructiveElement(item)
74    }
75}
76
77impl Visitable for BuildingConstructiveElement {
78    fn accept<V: Visitor>(&self, visitor: &mut V) {
79        visitor.visit_building_constructive_element(self);
80    }
81}