Skip to main content

ifc_classification/document/
information.rs

1//! Borrowed `IfcDocumentInformation` projection, read by attribute name in
2//! the bound release.
3use crate::view::{
4    borrowed_entity, optional_enum, optional_ref, optional_refs, optional_text, required_text,
5    ClassificationView,
6};
7use crate::ClassificationResult;
8borrowed_entity!(DocumentInformation, "IFCDOCUMENTINFORMATION");
9impl<'m> DocumentInformation<'m> {
10    /// The required `Identification` code of the document.
11    pub fn identification(self) -> ClassificationResult<&'m str> {
12        required_text(
13            "IFCDOCUMENTINFORMATION",
14            self.id(),
15            self.entity(),
16            self.text_slot("Identification")?,
17            "Identification",
18        )
19    }
20    /// The required `Name` of the document.
21    pub fn name(self) -> ClassificationResult<&'m str> {
22        required_text(
23            "IFCDOCUMENTINFORMATION",
24            self.id(),
25            self.entity(),
26            self.text_slot("Name")?,
27            "Name",
28        )
29    }
30    /// The `Description` of the document, when authored.
31    pub fn description(self) -> ClassificationResult<Option<&'m str>> {
32        optional_text(
33            "IFCDOCUMENTINFORMATION",
34            self.id(),
35            self.entity(),
36            self.text_slot("Description")?,
37            "Description",
38        )
39    }
40    /// The `Location` (e.g. a URI) of the document, when authored.
41    pub fn location(self) -> ClassificationResult<Option<&'m str>> {
42        optional_text(
43            "IFCDOCUMENTINFORMATION",
44            self.id(),
45            self.entity(),
46            self.text_slot("Location")?,
47            "Location",
48        )
49    }
50    /// The `Purpose` the document serves, when authored.
51    pub fn purpose(self) -> ClassificationResult<Option<&'m str>> {
52        optional_text(
53            "IFCDOCUMENTINFORMATION",
54            self.id(),
55            self.entity(),
56            self.text_slot("Purpose")?,
57            "Purpose",
58        )
59    }
60    /// The `IntendedUse` of the document, when authored.
61    pub fn intended_use(self) -> ClassificationResult<Option<&'m str>> {
62        optional_text(
63            "IFCDOCUMENTINFORMATION",
64            self.id(),
65            self.entity(),
66            self.text_slot("IntendedUse")?,
67            "IntendedUse",
68        )
69    }
70    /// The `Scope` of the document, when authored.
71    pub fn scope(self) -> ClassificationResult<Option<&'m str>> {
72        optional_text(
73            "IFCDOCUMENTINFORMATION",
74            self.id(),
75            self.entity(),
76            self.text_slot("Scope")?,
77            "Scope",
78        )
79    }
80    /// The `Revision` label of the document, when authored.
81    pub fn revision(self) -> ClassificationResult<Option<&'m str>> {
82        optional_text(
83            "IFCDOCUMENTINFORMATION",
84            self.id(),
85            self.entity(),
86            self.text_slot("Revision")?,
87            "Revision",
88        )
89    }
90    /// Id of the `DocumentOwner` (an `IfcActorSelect`), when authored.
91    pub fn document_owner_id(self) -> ClassificationResult<Option<ifc_model::EntityId>> {
92        optional_ref(
93            "IFCDOCUMENTINFORMATION",
94            self.id(),
95            self.entity(),
96            self.slot("DocumentOwner")?,
97            "DocumentOwner",
98        )
99    }
100    /// Ids of the `Editors` (`IfcActorSelect` members) who worked on the document, when authored.
101    pub fn editors(self) -> ClassificationResult<Option<Vec<ifc_model::EntityId>>> {
102        optional_refs(
103            "IFCDOCUMENTINFORMATION",
104            self.id(),
105            self.entity(),
106            self.slot("Editors")?,
107            "Editors",
108        )
109    }
110    /// The `CreationTime` of the document, when authored.
111    pub fn creation_time(self) -> ClassificationResult<Option<&'m str>> {
112        optional_text(
113            "IFCDOCUMENTINFORMATION",
114            self.id(),
115            self.entity(),
116            self.text_slot("CreationTime")?,
117            "CreationTime",
118        )
119    }
120    /// The `LastRevisionTime` of the document, when authored.
121    pub fn last_revision_time(self) -> ClassificationResult<Option<&'m str>> {
122        optional_text(
123            "IFCDOCUMENTINFORMATION",
124            self.id(),
125            self.entity(),
126            self.text_slot("LastRevisionTime")?,
127            "LastRevisionTime",
128        )
129    }
130    /// The `ElectronicFormat` (e.g. a MIME type) of the document, when authored.
131    pub fn electronic_format(self) -> ClassificationResult<Option<&'m str>> {
132        optional_text(
133            "IFCDOCUMENTINFORMATION",
134            self.id(),
135            self.entity(),
136            self.text_slot("ElectronicFormat")?,
137            "ElectronicFormat",
138        )
139    }
140    /// The `ValidFrom` date of the document, when authored.
141    pub fn valid_from(self) -> ClassificationResult<Option<&'m str>> {
142        optional_text(
143            "IFCDOCUMENTINFORMATION",
144            self.id(),
145            self.entity(),
146            self.text_slot("ValidFrom")?,
147            "ValidFrom",
148        )
149    }
150    /// The `ValidUntil` date of the document, when authored.
151    pub fn valid_until(self) -> ClassificationResult<Option<&'m str>> {
152        optional_text(
153            "IFCDOCUMENTINFORMATION",
154            self.id(),
155            self.entity(),
156            self.text_slot("ValidUntil")?,
157            "ValidUntil",
158        )
159    }
160    /// The `Confidentiality` enumerator of the document, when authored: one
161    /// of the bound release's `IfcDocumentConfidentialityEnum` values
162    /// (`PUBLIC`, `RESTRICTED`, `CONFIDENTIAL`, `PERSONAL`, `USERDEFINED`,
163    /// `NOTDEFINED` in IFC2X3, IFC4 and IFC4X3).
164    pub fn confidentiality(self) -> ClassificationResult<Option<&'m str>> {
165        self.enumerated("Confidentiality")
166    }
167    /// The `Status` enumerator of the document, when authored: one of the
168    /// bound release's `IfcDocumentStatusEnum` values (`DRAFT`, `FINALDRAFT`,
169    /// `FINAL`, `REVISION`, `NOTDEFINED` in IFC2X3, IFC4 and IFC4X3).
170    pub fn status(self) -> ClassificationResult<Option<&'m str>> {
171        self.enumerated("Status")
172    }
173    fn enumerated(self, attribute: &'static str) -> ClassificationResult<Option<&'m str>> {
174        const ENTITY: &str = "IFCDOCUMENTINFORMATION";
175        let allowed = self.release().enumerators(ENTITY, self.id(), attribute)?;
176        optional_enum(
177            ENTITY,
178            self.id(),
179            self.entity(),
180            self.slot(attribute)?,
181            attribute,
182            &allowed,
183        )
184    }
185}
186impl<'m> ClassificationView<'m> {
187    /// All `IfcDocumentInformation` instances in the model.
188    pub fn documents(self) -> impl Iterator<Item = DocumentInformation<'m>> + 'm {
189        self.model()
190            .of_type("IFCDOCUMENTINFORMATION")
191            .map(move |(id, e)| DocumentInformation::from_known(id, e, self.release()))
192    }
193}