ifc_template_catalog/definition/set.rs
1//! Property-set and quantity-set template definitions.
2
3use super::{Applicability, LocalizedText, PropertyTemplate, QuantityTemplate, TemplateSource};
4
5/// External PSD/QTO set template.
6#[derive(Debug, Clone, PartialEq, Eq, bincode::Encode, bincode::Decode)]
7pub struct SetTemplate {
8 /// `Name` as declared by the publication, e.g. `Pset_WallCommon`.
9 pub name: String,
10 /// Publication `GlobalId`, absent when the source did not assign one.
11 pub guid: Option<String>,
12 /// `Definition` prose, absent when the publication omitted it.
13 pub definition: Option<String>,
14 /// Localized alternates for `name` in other publication languages.
15 pub name_aliases: Vec<LocalizedText>,
16 /// Localized alternates for `definition` in other publication languages.
17 pub definition_aliases: Vec<LocalizedText>,
18 /// Which source publication contributed this template, absent for
19 /// synthesized or corrected templates with no direct source file.
20 pub source: Option<TemplateSource>,
21 /// Publication `ApplicableTypeValue` before normalization.
22 pub raw_applicability: Option<String>,
23 /// Parsed entity/predefined-type selectors derived from `raw_applicability`.
24 pub applicability: Vec<Applicability>,
25 /// Whether this is a property set or quantity set, and its typed payload.
26 pub kind: SetTemplateKind,
27}
28
29impl SetTemplate {
30 /// True when `kind` is [`SetTemplateKind::Property`].
31 pub fn is_property_set(&self) -> bool {
32 matches!(self.kind, SetTemplateKind::Property { .. })
33 }
34
35 /// True when `kind` is [`SetTemplateKind::Quantity`].
36 pub fn is_quantity_set(&self) -> bool {
37 matches!(self.kind, SetTemplateKind::Quantity { .. })
38 }
39}
40
41/// Set-level PSD or QTO payload.
42#[derive(Debug, Clone, PartialEq, Eq, bincode::Encode, bincode::Decode)]
43#[non_exhaustive]
44pub enum SetTemplateKind {
45 /// An `IfcPropertySetTemplate`: `TemplateType` category plus its property templates.
46 Property {
47 /// Applicability mode declared by `TemplateType`.
48 set_type: PropertySetType,
49 /// Property templates in publication order.
50 properties: Vec<PropertyTemplate>,
51 },
52 /// An `IfcElementQuantity` template: `TemplateType` category, measurement
53 /// method, and quantity templates.
54 Quantity {
55 /// Applicability mode declared by `TemplateType`.
56 set_type: QuantitySetType,
57 /// Free-text `MethodOfMeasurement`, absent when the publication omitted it.
58 method_of_measurement: Option<String>,
59 /// Quantity templates in publication order.
60 quantities: Vec<QuantityTemplate>,
61 },
62}
63
64/// IFC quantity-set template applicability mode.
65#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, bincode::Encode, bincode::Decode)]
66#[non_exhaustive]
67pub enum QuantitySetType {
68 /// `QTO_TYPEDRIVENOVERRIDE`: values from the type may be overridden per occurrence.
69 TypeDrivenOverride,
70 /// `QTO_TYPEDRIVENONLY`: values come only from the type, never the occurrence.
71 TypeDrivenOnly,
72 /// `QTO_OCCURRENCEDRIVEN`: values are authored per occurrence, not from a type.
73 OccurrenceDriven,
74 /// The publication omitted its optional `templatetype` classification.
75 Unspecified,
76}
77
78/// IFC property-set template applicability mode.
79#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, bincode::Encode, bincode::Decode)]
80#[non_exhaustive]
81pub enum PropertySetType {
82 /// `PSD_TYPEDRIVENOVERRIDE`: values from the type may be overridden per occurrence.
83 TypeDrivenOverride,
84 /// `PSD_TYPEDRIVENONLY`: values come only from the type, never the occurrence.
85 TypeDrivenOnly,
86 /// `PSD_OCCURRENCEDRIVEN`: values are authored per occurrence, not from a type.
87 OccurrenceDriven,
88 /// `PSD_PERFORMANCEDRIVEN`: values describe required/target performance,
89 /// distinct from as-built occurrence values.
90 PerformanceDriven,
91 /// The publication omitted its optional `templatetype` classification.
92 Unspecified,
93}