ifc_properties/exact/values.rs
1//! Public shapes of exact values that are more than one scalar (#150), and
2//! of entity-valued attributes (#149).
3//!
4//! Every scalar inside them is an [`ExactTypedValue`]: its value together
5//! with the IFC type the file declared for it, since a list, a bound or a
6//! table cell is an `IfcValue` select member and carries its own type.
7
8use std::sync::Arc;
9
10use ifc_model::EntityId;
11
12use super::ExactValue;
13
14/// One present `IfcValue` with its declared type.
15#[derive(Debug, Clone, PartialEq)]
16pub struct ExactTypedValue {
17 /// Declared IFC type as written, for example `IFCLABEL` or
18 /// `IFCLENGTHMEASURE`.
19 pub value_type: Arc<str>,
20 /// The scalar payload; never [`ExactValue::Null`] and never a
21 /// composite value.
22 pub value: ExactValue,
23}
24
25/// A referenced entity, identified exactly and not followed further.
26#[derive(Debug, Clone, PartialEq, Eq)]
27pub struct ExactEntityRef {
28 /// The referenced entity's id.
29 pub id: EntityId,
30 /// Its IFC type name as written in the file (upper-case).
31 pub type_name: Arc<str>,
32}
33
34/// An `IfcPropertyEnumeratedValue`: the selected values and the
35/// enumeration they are selected from.
36#[derive(Debug, Clone, PartialEq)]
37#[non_exhaustive]
38pub struct ExactEnumeratedValue {
39 /// `EnumerationValues`, in file order. Empty only when the attribute is
40 /// `$`, which IFC4 and IFC4X3 allow (no value selected); IFC2X3
41 /// requires it, and a present list is never empty (`LIST [1:?]`).
42 pub values: Vec<ExactTypedValue>,
43 /// `EnumerationReference`, when stated. Every selected value is one of
44 /// its values (the release's WHERE rule is checked).
45 pub enumeration: Option<ExactEnumeration>,
46}
47
48/// An `IfcPropertyEnumeration`: the permitted values of an enumerated
49/// property.
50#[derive(Debug, Clone, PartialEq)]
51#[non_exhaustive]
52pub struct ExactEnumeration {
53 /// Entity id of the `IfcPropertyEnumeration`.
54 pub id: EntityId,
55 /// Its `Name`.
56 pub name: Arc<str>,
57 /// Its `EnumerationValues`: nonempty, unique, of one declared type.
58 pub values: Vec<ExactTypedValue>,
59}
60
61/// An `IfcPropertyBoundedValue`: a range, and in IFC4/IFC4X3 a set point.
62///
63/// The shared `Unit` is [`ExactProperty::unit_id`](super::ExactProperty::unit_id).
64/// All stated values have one declared type (the release's WHERE rules are
65/// checked).
66#[derive(Debug, Clone, PartialEq)]
67#[non_exhaustive]
68pub struct ExactBoundedValue {
69 /// `LowerBoundValue`, when stated.
70 pub lower: Option<ExactTypedValue>,
71 /// `UpperBoundValue`, when stated.
72 pub upper: Option<ExactTypedValue>,
73 /// `SetPointValue`, when stated. Always `None` in IFC2X3, which does not
74 /// declare the attribute.
75 pub set_point: Option<ExactTypedValue>,
76}
77
78/// An `IfcPropertyTableValue`: rows mapping a defining to a defined value.
79#[derive(Debug, Clone, PartialEq)]
80#[non_exhaustive]
81pub struct ExactTableValue {
82 /// `DefiningValues` zipped with `DefinedValues`, in file order. The two
83 /// lists have equal length, each of one declared type, and the defining
84 /// values are unique. Empty only when both are `$` (IFC4/IFC4X3).
85 pub rows: Vec<ExactTableRow>,
86 /// `Expression`, when stated.
87 pub expression: Option<Arc<str>>,
88 /// `DefiningUnit`, when stated.
89 pub defining_unit: Option<EntityId>,
90 /// `DefinedUnit`, when stated.
91 pub defined_unit: Option<EntityId>,
92 /// `CurveInterpolation` (an `IfcCurveInterpolationEnum` member such as
93 /// `LINEAR`), when stated. Always `None` in IFC2X3, which does not
94 /// declare the attribute.
95 pub interpolation: Option<Arc<str>>,
96}
97
98/// One row of an [`ExactTableValue`].
99#[derive(Debug, Clone, PartialEq)]
100#[non_exhaustive]
101pub struct ExactTableRow {
102 /// The defining (x) value.
103 pub defining: ExactTypedValue,
104 /// The defined (y) value.
105 pub defined: ExactTypedValue,
106}
107
108/// An `IfcPropertyReferenceValue`: a named pointer to another entity.
109#[derive(Debug, Clone, PartialEq, Eq)]
110#[non_exhaustive]
111pub struct ExactReferenceValue {
112 /// `UsageName`, when stated.
113 pub usage_name: Option<Arc<str>>,
114 /// `PropertyReference`: an entity the release's
115 /// `IfcObjectReferenceSelect` accepts. Required in IFC2X3, optional in
116 /// IFC4 and IFC4X3.
117 pub target: Option<ExactEntityRef>,
118}
119
120/// An `IfcComplexProperty` or `IfcPhysicalComplexQuantity` (#208).
121///
122/// A complex groups named members and is no value itself, so an IDS data
123/// type or value restriction on it cannot hold, while its presence does.
124#[derive(Debug, Clone, PartialEq)]
125#[non_exhaustive]
126pub struct ExactComplexValue {
127 /// `IfcComplexProperty.UsageName`, or `IfcPhysicalComplexQuantity.Usage`
128 /// when stated.
129 pub usage: Option<Arc<str>>,
130 /// `IfcPhysicalComplexQuantity.Discrimination`; `None` for a complex
131 /// property.
132 pub discrimination: Option<Arc<str>>,
133 /// `IfcPhysicalComplexQuantity.Quality` when stated; `None` for a
134 /// complex property.
135 pub quality: Option<Arc<str>>,
136 /// `HasProperties` or `HasQuantities` in file order, never empty.
137 pub members: Vec<ExactComplexMember>,
138}
139
140/// One member of an [`ExactComplexValue`], resolved as a set member is.
141#[derive(Debug, Clone, PartialEq)]
142#[non_exhaustive]
143pub struct ExactComplexMember {
144 /// Its `Name`; unique within the complex where the release requires.
145 pub name: Arc<str>,
146 /// Entity id of the member property or quantity.
147 pub id: EntityId,
148 /// As [`ExactProperty::value_type`](super::ExactProperty::value_type).
149 pub value_type: Option<Arc<str>>,
150 /// As [`ExactProperty::unit_id`](super::ExactProperty::unit_id).
151 pub unit_id: Option<EntityId>,
152 /// The resolved value; [`ExactValue::Complex`] for a nested complex.
153 pub value: ExactValue,
154}