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)]
100pub struct ExactTableRow {
101 /// The defining (x) value.
102 pub defining: ExactTypedValue,
103 /// The defined (y) value.
104 pub defined: ExactTypedValue,
105}
106
107/// An `IfcPropertyReferenceValue`: a named pointer to another entity.
108#[derive(Debug, Clone, PartialEq, Eq)]
109#[non_exhaustive]
110pub struct ExactReferenceValue {
111 /// `UsageName`, when stated.
112 pub usage_name: Option<Arc<str>>,
113 /// `PropertyReference`: an entity the release's
114 /// `IfcObjectReferenceSelect` accepts. Required in IFC2X3, optional in
115 /// IFC4 and IFC4X3.
116 pub target: Option<ExactEntityRef>,
117}
118
119/// An `IfcComplexProperty` or `IfcPhysicalComplexQuantity` (#208).
120///
121/// A complex groups named members and is no value itself, so an IDS data
122/// type or value restriction on it cannot hold, while its presence does.
123#[derive(Debug, Clone, PartialEq)]
124#[non_exhaustive]
125pub struct ExactComplexValue {
126 /// `IfcComplexProperty.UsageName`, or `IfcPhysicalComplexQuantity.Usage`
127 /// when stated.
128 pub usage: Option<Arc<str>>,
129 /// `IfcPhysicalComplexQuantity.Discrimination`; `None` for a complex
130 /// property.
131 pub discrimination: Option<Arc<str>>,
132 /// `IfcPhysicalComplexQuantity.Quality` when stated; `None` for a
133 /// complex property.
134 pub quality: Option<Arc<str>>,
135 /// `HasProperties` or `HasQuantities` in file order, never empty.
136 pub members: Vec<ExactComplexMember>,
137}
138
139/// One member of an [`ExactComplexValue`], resolved as a set member is.
140#[derive(Debug, Clone, PartialEq)]
141#[non_exhaustive]
142pub struct ExactComplexMember {
143 /// Its `Name`; unique within the complex where the release requires.
144 pub name: Arc<str>,
145 /// Entity id of the member property or quantity.
146 pub id: EntityId,
147 /// As [`ExactProperty::value_type`](super::ExactProperty::value_type).
148 pub value_type: Option<Arc<str>>,
149 /// As [`ExactProperty::unit_id`](super::ExactProperty::unit_id).
150 pub unit_id: Option<EntityId>,
151 /// The resolved value; [`ExactValue::Complex`] for a nested complex.
152 pub value: ExactValue,
153}