Skip to main content

ifc_classification/classification/
system.rs

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