Skip to main content

ifc_classification/classification/
system.rs

1//! Borrowed `IfcClassification` projection, read by attribute name in the
2//! bound release.
3use crate::view::{
4    borrowed_entity, optional_text, optional_texts, required_text, ClassificationView,
5};
6use crate::ClassificationResult;
7borrowed_entity!(ClassificationSystem, "IFCCLASSIFICATION");
8impl<'m> ClassificationSystem<'m> {
9    /// The `Source` (organization) that publishes this classification system, when authored.
10    pub fn source(self) -> ClassificationResult<Option<&'m str>> {
11        optional_text(
12            "IFCCLASSIFICATION",
13            self.id(),
14            self.entity(),
15            self.text_slot("Source")?,
16            "Source",
17        )
18    }
19    /// The `Edition` label of this classification system, when authored.
20    pub fn edition(self) -> ClassificationResult<Option<&'m str>> {
21        optional_text(
22            "IFCCLASSIFICATION",
23            self.id(),
24            self.entity(),
25            self.text_slot("Edition")?,
26            "Edition",
27        )
28    }
29    /// The `EditionDate` of this classification system, when authored.
30    pub fn edition_date(self) -> ClassificationResult<Option<&'m str>> {
31        optional_text(
32            "IFCCLASSIFICATION",
33            self.id(),
34            self.entity(),
35            self.text_slot("EditionDate")?,
36            "EditionDate",
37        )
38    }
39    /// The required `Name` of this classification system.
40    pub fn name(self) -> ClassificationResult<&'m str> {
41        required_text(
42            "IFCCLASSIFICATION",
43            self.id(),
44            self.entity(),
45            self.text_slot("Name")?,
46            "Name",
47        )
48    }
49    /// The `Description` of this classification system, when authored.
50    pub fn description(self) -> ClassificationResult<Option<&'m str>> {
51        optional_text(
52            "IFCCLASSIFICATION",
53            self.id(),
54            self.entity(),
55            self.text_slot("Description")?,
56            "Description",
57        )
58    }
59    /// The `Location` (e.g. a URI) of this classification system, when authored.
60    ///
61    /// IFC4X3 ADD2 names this attribute `Specification`, at the same position
62    /// and with the same type; it is read here. IFC2X3 has neither, which is
63    /// `NotInSchema`.
64    pub fn location(self) -> ClassificationResult<Option<&'m str>> {
65        optional_text(
66            "IFCCLASSIFICATION",
67            self.id(),
68            self.entity(),
69            self.text_slot("Location")?,
70            "Location",
71        )
72    }
73    /// The `ReferenceTokens` used to compose classification identifications, when authored.
74    pub fn reference_tokens(self) -> ClassificationResult<Option<Vec<&'m str>>> {
75        optional_texts(
76            "IFCCLASSIFICATION",
77            self.id(),
78            self.entity(),
79            self.text_slot("ReferenceTokens")?,
80            "ReferenceTokens",
81        )
82    }
83}
84impl<'m> ClassificationView<'m> {
85    /// All `IfcClassification` instances in the model.
86    pub fn systems(self) -> impl Iterator<Item = ClassificationSystem<'m>> + 'm {
87        self.model()
88            .of_type("IFCCLASSIFICATION")
89            .map(move |(id, e)| ClassificationSystem::from_known(id, e, self.release()))
90    }
91}