Skip to main content

ifc_resource/inventory/
definition.rs

1//! `IfcInventory` — bounded IFC4 asset-inventory metadata projection.
2
3use ifc_model::EntityId;
4
5use crate::error::ResourceResult;
6use crate::view::Record;
7
8/// A borrowed, schema-resolved `IfcInventory` projection.
9///
10/// `IfcInventory` is an `IfcGroup`: its members are resolved separately
11/// through `IfcRelAssignsToGroup` (see `items.rs`), never carried on this
12/// projection directly.
13#[derive(Debug, Clone, Copy)]
14pub struct Inventory<'m, 's> {
15    record: Record<'m, 's>,
16}
17
18impl<'m, 's> Inventory<'m, 's> {
19    pub(crate) fn from_record(record: Record<'m, 's>) -> ResourceResult<Self> {
20        Ok(Self { record })
21    }
22
23    /// The entity id of the projected `IfcInventory`.
24    #[must_use]
25    pub fn id(&self) -> EntityId {
26        self.record.id
27    }
28
29    /// The `Name` attribute, when authored.
30    pub fn name(&self) -> ResourceResult<Option<&'m str>> {
31        self.record.optional_text("Name")
32    }
33
34    /// The `Description` attribute, when authored.
35    pub fn description(&self) -> ResourceResult<Option<&'m str>> {
36        self.record.optional_text("Description")
37    }
38
39    /// The `PredefinedType` enumeration, when authored.
40    pub fn predefined_type(&self) -> ResourceResult<Option<&'m str>> {
41        self.record.optional_enum("PredefinedType")
42    }
43
44    /// `IfcActorSelect`: an `IfcPerson`, `IfcOrganization`, or
45    /// `IfcPersonAndOrganization`.
46    pub fn jurisdiction(&self) -> ResourceResult<Option<EntityId>> {
47        self.record.optional_ref_select(
48            "Jurisdiction",
49            "IfcActorSelect",
50            &["IfcPerson", "IfcOrganization", "IfcPersonAndOrganization"],
51        )
52    }
53
54    /// The `ResponsiblePersons` attribute, when authored.
55    pub fn responsible_person_ids(&self) -> ResourceResult<Vec<EntityId>> {
56        self.record
57            .refs("ResponsiblePersons", "IfcPerson", 1, true, true)
58    }
59
60    /// The `LastUpdateDate` attribute, when authored.
61    pub fn last_update_date(&self) -> ResourceResult<Option<&'m str>> {
62        self.record.optional_text("LastUpdateDate")
63    }
64
65    /// The `CurrentValue` attribute, when authored.
66    pub fn current_value(&self) -> ResourceResult<Option<EntityId>> {
67        self.record.optional_ref("CurrentValue", "IfcCostValue")
68    }
69
70    /// The `OriginalValue` attribute, when authored.
71    pub fn original_value(&self) -> ResourceResult<Option<EntityId>> {
72        self.record.optional_ref("OriginalValue", "IfcCostValue")
73    }
74}