openbim-loin 0.2.0

ISO 7817-3 / EN 17412-3 LOIN (Level of Information Need).
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
//! ISO 7817-3 contracts that directly consume ISO 23387-owned types.

use openbim_dt::{
    Concept, DateTime, Dimension, GroupOfProperties, Guid, Language, MultiLanguageText, ObjectType,
    Property, QuantityKind, Reference, ReferenceDocument, Unit,
};

/// LOIN `PurposeType`; its identity, text, and references are DT-owned contracts.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Purpose {
    guid: Guid,
    name: MultiLanguageText,
    definition: Option<MultiLanguageText>,
    reference_documents: Vec<Reference>,
    descriptions: Vec<MultiLanguageText>,
    language: Option<Language>,
    region: Option<String>,
    dictionary_ref: Option<Reference>,
}

impl Purpose {
    #[must_use]
    pub const fn new(guid: Guid, name: MultiLanguageText) -> Self {
        Self {
            guid,
            name,
            definition: None,
            reference_documents: Vec::new(),
            descriptions: Vec::new(),
            language: None,
            region: None,
            dictionary_ref: None,
        }
    }

    #[must_use]
    pub const fn guid(&self) -> &Guid {
        &self.guid
    }
    #[must_use]
    pub const fn name(&self) -> &MultiLanguageText {
        &self.name
    }
    pub fn set_definition(&mut self, value: Option<MultiLanguageText>) {
        self.definition = value;
    }
    pub fn add_reference_document(&mut self, value: Reference) {
        self.reference_documents.push(value);
    }
    pub fn add_description(&mut self, value: MultiLanguageText) {
        self.descriptions.push(value);
    }
    pub fn set_language(&mut self, value: Option<Language>) {
        self.language = value;
    }
    #[must_use]
    pub const fn language(&self) -> Option<&Language> {
        self.language.as_ref()
    }
    pub fn set_region(&mut self, value: Option<String>) {
        self.region = value;
    }
    pub fn set_dictionary_ref(&mut self, value: Option<Reference>) {
        self.dictionary_ref = value;
    }
}

/// LOIN `ActorType`, using DT identity and multilingual text.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Actor {
    guid: Guid,
    role: MultiLanguageText,
    description: Option<MultiLanguageText>,
}

impl Actor {
    #[must_use]
    pub const fn new(guid: Guid, role: MultiLanguageText) -> Self {
        Self {
            guid,
            role,
            description: None,
        }
    }
    #[must_use]
    pub const fn guid(&self) -> &Guid {
        &self.guid
    }
    #[must_use]
    pub const fn role(&self) -> &MultiLanguageText {
        &self.role
    }
    pub fn set_role(&mut self, value: MultiLanguageText) {
        self.role = value;
    }
    pub fn set_description(&mut self, value: Option<MultiLanguageText>) {
        self.description = value;
    }
}

/// LOIN `InformationDeliveryMilestoneType`.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct InformationDeliveryMilestone {
    guid: Guid,
    name: MultiLanguageText,
    descriptions: Vec<MultiLanguageText>,
    reference_documents: Vec<Reference>,
    date: Option<DateTime>,
}

impl InformationDeliveryMilestone {
    #[must_use]
    pub const fn new(guid: Guid, name: MultiLanguageText) -> Self {
        Self {
            guid,
            name,
            descriptions: Vec::new(),
            reference_documents: Vec::new(),
            date: None,
        }
    }
    #[must_use]
    pub const fn guid(&self) -> &Guid {
        &self.guid
    }
    #[must_use]
    pub const fn name(&self) -> &MultiLanguageText {
        &self.name
    }
    pub fn add_description(&mut self, value: MultiLanguageText) {
        self.descriptions.push(value);
    }
    pub fn add_reference_document(&mut self, value: Reference) {
        self.reference_documents.push(value);
    }
    pub fn set_date(&mut self, value: Option<DateTime>) {
        self.date = value;
    }
}

/// LOIN prerequisites; all referenced identities are DT-owned GUID contracts.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Prerequisites {
    guid: Guid,
    purpose: Purpose,
    milestone: InformationDeliveryMilestone,
    providing_actor: Actor,
    receiving_actor: Actor,
}

impl Prerequisites {
    #[must_use]
    pub const fn new(
        guid: Guid,
        purpose: Purpose,
        milestone: InformationDeliveryMilestone,
        providing_actor: Actor,
        receiving_actor: Actor,
    ) -> Self {
        Self {
            guid,
            purpose,
            milestone,
            providing_actor,
            receiving_actor,
        }
    }
    #[must_use]
    pub const fn guid(&self) -> &Guid {
        &self.guid
    }
    #[must_use]
    pub const fn purpose(&self) -> &Purpose {
        &self.purpose
    }
    #[must_use]
    pub const fn milestone(&self) -> &InformationDeliveryMilestone {
        &self.milestone
    }
    #[must_use]
    pub const fn providing_actor(&self) -> &Actor {
        &self.providing_actor
    }
    #[must_use]
    pub const fn receiving_actor(&self) -> &Actor {
        &self.receiving_actor
    }
}

/// Root LOIN specification contract.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Specification {
    guid: Guid,
    name: String,
    prerequisites: Prerequisites,
    per_object: Vec<SpecificationPerObjectType>,
}

impl Specification {
    #[must_use]
    pub fn new(guid: Guid, name: impl Into<String>, prerequisites: Prerequisites) -> Self {
        Self {
            guid,
            name: name.into(),
            prerequisites,
            per_object: Vec::new(),
        }
    }
    #[must_use]
    pub const fn guid(&self) -> &Guid {
        &self.guid
    }
    #[must_use]
    pub fn name(&self) -> &str {
        &self.name
    }
    #[must_use]
    pub const fn prerequisites(&self) -> &Prerequisites {
        &self.prerequisites
    }
    pub fn add_per_object(&mut self, value: SpecificationPerObjectType) {
        self.per_object.push(value);
    }
    #[must_use]
    pub fn per_object(&self) -> &[SpecificationPerObjectType] {
        &self.per_object
    }
}

/// Anonymous LOIN alphanumerical-information content using imported DT types.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct AlphanumericalInformation {
    properties: Vec<Property>,
    quantity_kinds: Vec<QuantityKind>,
    groups_of_properties: Vec<GroupOfProperties>,
    group_refs: Vec<Reference>,
    reference_documents: Vec<ReferenceDocument>,
    dimensions: Vec<Dimension>,
    units: Vec<Unit>,
}

impl Default for AlphanumericalInformation {
    fn default() -> Self {
        Self::new()
    }
}

impl AlphanumericalInformation {
    #[must_use]
    pub const fn new() -> Self {
        Self {
            properties: Vec::new(),
            quantity_kinds: Vec::new(),
            groups_of_properties: Vec::new(),
            group_refs: Vec::new(),
            reference_documents: Vec::new(),
            dimensions: Vec::new(),
            units: Vec::new(),
        }
    }
    pub fn add_property(&mut self, value: Property) {
        self.properties.push(value);
    }
    pub fn add_quantity_kind(&mut self, value: QuantityKind) {
        self.quantity_kinds.push(value);
    }
    pub fn add_group_of_properties(&mut self, value: GroupOfProperties) {
        self.groups_of_properties.push(value);
    }
    pub fn add_group_ref(&mut self, value: Reference) {
        self.group_refs.push(value);
    }
    pub fn add_reference_document(&mut self, value: ReferenceDocument) {
        self.reference_documents.push(value);
    }
    pub fn add_dimension(&mut self, value: Dimension) {
        self.dimensions.push(value);
    }
    pub fn add_unit(&mut self, value: Unit) {
        self.units.push(value);
    }
    #[must_use]
    pub fn properties(&self) -> &[Property] {
        &self.properties
    }
    #[must_use]
    pub fn quantity_kinds(&self) -> &[QuantityKind] {
        &self.quantity_kinds
    }
    #[must_use]
    pub fn groups_of_properties(&self) -> &[GroupOfProperties] {
        &self.groups_of_properties
    }
    #[must_use]
    pub fn group_refs(&self) -> &[Reference] {
        &self.group_refs
    }
    #[must_use]
    pub fn reference_documents(&self) -> &[ReferenceDocument] {
        &self.reference_documents
    }
    #[must_use]
    pub fn dimensions(&self) -> &[Dimension] {
        &self.dimensions
    }
    #[must_use]
    pub fn units(&self) -> &[Unit] {
        &self.units
    }
}

/// One LOIN requirement per object type; its base and imported content are DT-owned.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct SpecificationPerObjectType {
    concept: Concept,
    object_type: ObjectType,
    alphanumerical_information: Option<AlphanumericalInformation>,
    documentation: Option<Documentation>,
    geometrical_information: Option<GeometricalInformation>,
}

impl SpecificationPerObjectType {
    #[must_use]
    pub const fn new(concept: Concept, object_type: ObjectType) -> Self {
        Self {
            concept,
            object_type,
            alphanumerical_information: None,
            documentation: None,
            geometrical_information: None,
        }
    }
    #[must_use]
    pub const fn concept(&self) -> &Concept {
        &self.concept
    }
    #[must_use]
    pub const fn object_type(&self) -> &ObjectType {
        &self.object_type
    }
    pub fn set_alphanumerical_information(&mut self, value: Option<AlphanumericalInformation>) {
        self.alphanumerical_information = value;
    }
    #[must_use]
    pub const fn alphanumerical_information(&self) -> Option<&AlphanumericalInformation> {
        self.alphanumerical_information.as_ref()
    }
    pub fn set_documentation(&mut self, value: Option<Documentation>) {
        self.documentation = value;
    }
    #[must_use]
    pub const fn documentation(&self) -> Option<&Documentation> {
        self.documentation.as_ref()
    }
    pub fn set_geometrical_information(&mut self, value: Option<GeometricalInformation>) {
        self.geometrical_information = value;
    }
    #[must_use]
    pub const fn geometrical_information(&self) -> Option<&GeometricalInformation> {
        self.geometrical_information.as_ref()
    }
}

/// LOIN `FormatType` using DT multilingual text and references.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct DocumentFormat {
    names: Vec<MultiLanguageText>,
    versions: Vec<MultiLanguageText>,
    specifications: Vec<Reference>,
}

impl DocumentFormat {
    #[must_use]
    pub fn new(name: MultiLanguageText, version: MultiLanguageText) -> Self {
        Self {
            names: vec![name],
            versions: vec![version],
            specifications: Vec::new(),
        }
    }
    pub fn add_name(&mut self, value: MultiLanguageText) {
        self.names.push(value);
    }
    pub fn add_version(&mut self, value: MultiLanguageText) {
        self.versions.push(value);
    }
    pub fn add_specification(&mut self, value: Reference) {
        self.specifications.push(value);
    }
}

/// LOIN `DocumentationType`, whose identity attribute is DT-owned.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Documentation {
    guid: Guid,
    required_documents: Vec<RequiredDocument>,
}

impl Documentation {
    #[must_use]
    pub const fn new(guid: Guid) -> Self {
        Self {
            guid,
            required_documents: Vec::new(),
        }
    }
    #[must_use]
    pub const fn guid(&self) -> &Guid {
        &self.guid
    }
    pub fn add_required_document(&mut self, value: RequiredDocument) {
        self.required_documents.push(value);
    }
    #[must_use]
    pub fn required_documents(&self) -> &[RequiredDocument] {
        &self.required_documents
    }
}

/// LOIN geometrical-information identity using the imported DT GUID attribute.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct GeometricalInformation {
    guid: Guid,
}

impl GeometricalInformation {
    #[must_use]
    pub const fn new(guid: Guid) -> Self {
        Self { guid }
    }
    #[must_use]
    pub const fn guid(&self) -> &Guid {
        &self.guid
    }
}

/// LOIN `RequiredDocumentType`.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct RequiredDocument {
    guid: Guid,
    name: MultiLanguageText,
    format: DocumentFormat,
    references: Vec<Reference>,
    descriptions: Vec<MultiLanguageText>,
}

impl RequiredDocument {
    #[must_use]
    pub const fn new(guid: Guid, name: MultiLanguageText, format: DocumentFormat) -> Self {
        Self {
            guid,
            name,
            format,
            references: Vec::new(),
            descriptions: Vec::new(),
        }
    }
    #[must_use]
    pub const fn guid(&self) -> &Guid {
        &self.guid
    }
    pub fn add_reference(&mut self, value: Reference) {
        self.references.push(value);
    }
    pub fn add_description(&mut self, value: MultiLanguageText) {
        self.descriptions.push(value);
    }
}

/// LOIN threshold dimension importing DT unit and text contracts.
#[derive(Debug, Clone, PartialEq)]
pub struct ThresholdDimension {
    threshold: f64,
    unit: Unit,
    definition: MultiLanguageText,
}

impl ThresholdDimension {
    #[must_use]
    pub const fn new(threshold: f64, unit: Unit, definition: MultiLanguageText) -> Self {
        Self {
            threshold,
            unit,
            definition,
        }
    }
    #[must_use]
    pub const fn unit(&self) -> &Unit {
        &self.unit
    }
}

/// LOIN geometry detail with an optional DT dictionary reference.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Detail {
    dictionary: Option<Reference>,
}

impl Detail {
    #[must_use]
    pub const fn new(dictionary: Option<Reference>) -> Self {
        Self { dictionary }
    }
    #[must_use]
    pub const fn dictionary(&self) -> Option<&Reference> {
        self.dictionary.as_ref()
    }
}

/// LOIN datum-registry reference using DT text and reference types.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct DatumRegistryReference {
    name: MultiLanguageText,
    descriptions: Vec<MultiLanguageText>,
    registry_reference: Option<Reference>,
}

impl DatumRegistryReference {
    #[must_use]
    pub const fn new(name: MultiLanguageText) -> Self {
        Self {
            name,
            descriptions: Vec::new(),
            registry_reference: None,
        }
    }
    #[must_use]
    pub const fn name(&self) -> &MultiLanguageText {
        &self.name
    }
    #[must_use]
    pub fn descriptions(&self) -> &[MultiLanguageText] {
        &self.descriptions
    }
    pub fn add_description(&mut self, value: MultiLanguageText) {
        self.descriptions.push(value);
    }
    pub fn set_registry_reference(&mut self, value: Option<Reference>) {
        self.registry_reference = value;
    }
}