ReUseX  0.0.5
3D Point Cloud Processing for Building Reuse
Loading...
Searching...
No Matches
materialepas_traits.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2025 Povl Filip Sonne-Frederiksen
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
5#pragma once
6
8#include <array>
9#include <cstddef>
10
11namespace reusex::core::traits {
12
21 const char *field_name;
22
24 const char *leksikon_guid;
25
29 const char *json_name;
30
33
35 size_t offset;
36
39
41 size_t nested_count = 0;
42};
43
54template <typename T> struct PropertyTraits {
59 static constexpr const PropertyDescriptor *properties() noexcept;
60
65 static constexpr size_t property_count() noexcept;
66
71 static constexpr const char *struct_name() noexcept;
72};
73
74// ============================================================================
75// Helper Functions for Creating PropertyDescriptors
76// ============================================================================
77
78namespace detail {
79
94template <typename T>
96 const char* field_name,
97 const char* leksikon_guid,
98 const char* json_name,
99 PropertyType type,
100 size_t field_offset) noexcept {
101 return PropertyDescriptor{
102 field_name,
103 leksikon_guid,
104 json_name,
105 type,
106 field_offset,
107 nullptr,
108 0
109 };
110}
111
125template <typename T, typename NestedT>
127 const char* field_name,
128 const char* json_name,
129 size_t field_offset) noexcept {
130 return PropertyDescriptor{
131 field_name,
132 "", // No GUID for nested arrays
133 json_name,
135 field_offset,
138 };
139}
140
141} // namespace detail
142
143} // namespace reusex::core::traits
144
145// ===========================================================================
146// Include types before specializations
147// ===========================================================================
148
149#include "materialepas_types.hpp"
150
151namespace reusex::core::traits {
152
153// Bring types into scope for convenience
154using ::reusex::core::Owner;
166
167// ===========================================================================
168// Template Specializations
169// ===========================================================================
170
171// ===========================================================================
172// Section 1: Owner (3 properties)
173// ===========================================================================
174
175template <>
177 static inline constexpr std::array properties_array = {
179 "contact_email", "0Bwj05D$55V931bq9VaBE5",
180 "materialpassport owner contact email",
181 PropertyType::String, offsetof(Owner, contact_email)),
183 "contact_name", "17BdeQk152gR5YUt5oSLfp",
184 "materialpassport owner contact name",
185 PropertyType::String, offsetof(Owner, contact_name)),
187 "company_name", "1bb51PIefCe9uHGCmR0gFJ",
188 "materialpassport owner company name",
189 PropertyType::String, offsetof(Owner, company_name))
190 };
191
192 static constexpr const PropertyDescriptor* properties() noexcept {
193 return properties_array.data();
194 }
195
196 static constexpr size_t property_count() noexcept {
197 return properties_array.size();
198 }
199
200 static constexpr const char* struct_name() noexcept {
201 return "Owner";
202 }
203};
204
205// ===========================================================================
206// Section 2: Construction Item Description (8 properties)
207// ===========================================================================
208
209template <>
211 static inline constexpr std::array properties_array = {
213 "designation", "2_mYRkA$9EcwXAxqBGoMrM",
214 "construction item designation",
215 PropertyType::String, offsetof(ConstructionItemDescription, designation)),
217 "images", "1dvQfmc2z9lB_rwknYkM3y",
218 "construction item image",
221 "has_qr_code", "06moAxe0j7EutROb0dD3B7",
222 "has QR code",
223 PropertyType::Boolean, offsetof(ConstructionItemDescription, has_qr_code)),
225 "has_rfid_tag", "2$Owq1iHrAuw$ASWOXAk9p",
226 "has RFID tag",
227 PropertyType::Boolean, offsetof(ConstructionItemDescription, has_rfid_tag)),
229 "materials", "1R_z75Gd52OQYxVkJ$E3ZU",
230 "material",
233 "assembly_methods", "0N7Qwopp125xrULezqArw4",
234 "assembly method",
235 PropertyType::StringArray, offsetof(ConstructionItemDescription, assembly_methods)),
237 "year_of_installation", "294ZkUyYn6TfdwCsbo2X63",
238 "year of installation",
239 PropertyType::Integer, offsetof(ConstructionItemDescription, year_of_installation)),
241 "year_of_construction", "17LFECVML6buNXwBLz416Y",
242 "year of construction of the building",
243 PropertyType::Integer, offsetof(ConstructionItemDescription, year_of_construction))
244 };
245
246 static constexpr const PropertyDescriptor* properties() noexcept {
247 return properties_array.data();
248 }
249
250 static constexpr size_t property_count() noexcept {
251 return properties_array.size();
252 }
253
254 static constexpr const char* struct_name() noexcept {
255 return "ConstructionItemDescription";
256 }
257};
258
259// ===========================================================================
260// Section 3: Product Information (5 properties)
261// ===========================================================================
262
263template <>
265 static inline constexpr std::array properties_array = {
267 "manufacturer", "1QwFy1F3T4dPe2N2cbsuRv",
268 "manufacturer",
269 PropertyType::String, offsetof(ProductInformation, manufacturer)),
271 "gtin", "1rQ9Z5vy5AygUSncyWuhXr",
272 "global trade item number (GTIN)",
275 "product_name", "198tMTFIX5PecEfAwMEIeo",
276 "product name",
277 PropertyType::String, offsetof(ProductInformation, product_name)),
279 "model_label", "06t2gkj49FNvMebmltrHXV",
280 "model label",
281 PropertyType::String, offsetof(ProductInformation, model_label)),
283 "production_year", "3nif2XJKH8r9I09LfEYaRm",
284 "production year",
285 PropertyType::Integer, offsetof(ProductInformation, production_year))
286 };
287
288 static constexpr const PropertyDescriptor* properties() noexcept {
289 return properties_array.data();
290 }
291
292 static constexpr size_t property_count() noexcept {
293 return properties_array.size();
294 }
295
296 static constexpr const char* struct_name() noexcept {
297 return "ProductInformation";
298 }
299};
300
301// ===========================================================================
302// Section 4: Certifications (13 properties)
303// ===========================================================================
304
305template <>
307 static inline constexpr std::array properties_array = {
309 "has_epd", "2_jn1$mEr1780H5QOiEj6O",
310 "environmental product declaration (EPD)",
311 PropertyType::Boolean, offsetof(Certifications, has_epd)),
313 "epd_programme_operator", "0ORiYBKRnCFQzUwOsNqbYn",
314 "EPD programme operator",
315 PropertyType::String, offsetof(Certifications, epd_programme_operator)),
317 "epd_operator_web_domain", "2kqTixLBr9sBqGKYs9lNSI",
318 "EPD programme operator web domain",
319 PropertyType::String, offsetof(Certifications, epd_operator_web_domain)),
321 "epd_registration_number", "2aCraAVB91qw8CzrM6x3ia",
322 "EPD registration number",
323 PropertyType::String, offsetof(Certifications, epd_registration_number)),
325 "reference_service_life", "28mSsPe_z69BksBt5oRXMl",
326 "reference service life",
327 PropertyType::Double, offsetof(Certifications, reference_service_life)),
329 "has_safety_data_sheet", "3D1KFVwbDBuumnIBZZHQId",
330 "has safety data sheet",
331 PropertyType::Boolean, offsetof(Certifications, has_safety_data_sheet)),
333 "declaration_of_performance", "1tqCmrJwn3yvF$k2lU2fFa",
334 "declaration of performance",
335 PropertyType::StringArray, offsetof(Certifications, declaration_of_performance)),
337 "technical_documentation", "1IfrbnqGv5Pu3GBuocLZgi",
338 "technical documentation",
339 PropertyType::StringArray, offsetof(Certifications, technical_documentation)),
341 "non_destructive_tests", "0aTBceworF$QTXM6CqyOdV",
342 "non-destructive tests",
343 PropertyType::StringArray, offsetof(Certifications, non_destructive_tests)),
345 "assessed_period_of_use", "3xW23JRMTAzOQb79uZW3qC",
346 "assessed period of use",
347 PropertyType::Double, offsetof(Certifications, assessed_period_of_use)),
349 "avg_service_life_build", "2TtVRWo_56mBphAcSiFIHG",
350 "average service life (BUILD)",
351 PropertyType::Double, offsetof(Certifications, avg_service_life_build)),
353 "remaining_service_life_rsl", "2id4UZ8ynAF9DEzV0NC_wT",
354 "service life (RSL)",
355 PropertyType::Double, offsetof(Certifications, remaining_service_life_rsl)),
357 "remaining_service_life_build", "27gXAA5Iz7lgcOytMRqOBv",
358 "remaining service life (BUILD)",
359 PropertyType::Double, offsetof(Certifications, remaining_service_life_build))
360 };
361
362 static constexpr const PropertyDescriptor* properties() noexcept {
363 return properties_array.data();
364 }
365
366 static constexpr size_t property_count() noexcept {
367 return properties_array.size();
368 }
369
370 static constexpr const char* struct_name() noexcept {
371 return "Certifications";
372 }
373};
374
375// ===========================================================================
376// Section 5: Dimensions (11 properties)
377// ===========================================================================
378
379template <>
381 static inline constexpr std::array properties_array = {
383 "width_mm", "3NHBUedX9438Hi3mwD15$Z",
384 "width",
385 PropertyType::Double, offsetof(Dimensions, width_mm)),
387 "height_mm", "2G$wMhUvL2LgKNY0J66oAT",
388 "height",
389 PropertyType::Double, offsetof(Dimensions, height_mm)),
391 "length_mm", "1uUn3YWZfBaPqYQMo_$Om$",
392 "length",
393 PropertyType::Double, offsetof(Dimensions, length_mm)),
395 "thickness_mm", "0SyXPZ9an9vh49k$Lgkvly",
396 "thickness",
397 PropertyType::Double, offsetof(Dimensions, thickness_mm)),
399 "depth_mm", "1$OV5du3LFWwa$P7SfJhAr",
400 "depth",
401 PropertyType::Double, offsetof(Dimensions, depth_mm)),
403 "volume_m3", "3IHRMkfs9EDPXVvPJ0hbFn",
404 "volume",
405 PropertyType::Double, offsetof(Dimensions, volume_m3)),
407 "surface_area_m2", "3Cs4d96Ff1nPGHWlsTyYIS",
408 "surface area of product",
409 PropertyType::Double, offsetof(Dimensions, surface_area_m2)),
411 "inner_diameter_mm", "0ayREcz2zBuPWmCDTem2a8",
412 "inner diameter",
413 PropertyType::Double, offsetof(Dimensions, inner_diameter_mm)),
415 "outer_diameter_mm", "3BWwvo0lf3iAd_34y7ac$4",
416 "outer diameter",
417 PropertyType::Double, offsetof(Dimensions, outer_diameter_mm)),
419 "weight_kg", "1XyLvnxf94pwJW6LWaD6Zw",
420 "weight",
421 PropertyType::Double, offsetof(Dimensions, weight_kg)),
423 "technical_drawing", "2d01jZqvP7GOR3V$coAprV",
424 "technical drawing",
425 PropertyType::String, offsetof(Dimensions, technical_drawing))
426 };
427
428 static constexpr const PropertyDescriptor* properties() noexcept {
429 return properties_array.data();
430 }
431
432 static constexpr size_t property_count() noexcept {
433 return properties_array.size();
434 }
435
436 static constexpr const char* struct_name() noexcept {
437 return "Dimensions";
438 }
439};
440
441// ===========================================================================
442// Section 6: Condition (8 properties)
443// ===========================================================================
444
445template <>
447 static inline constexpr std::array properties_array = {
449 "photo_documentation", "3$DH1Zm_r9_gzqdwKK39Ua",
450 "photo documentation",
451 PropertyType::StringArray, offsetof(Condition, photo_documentation)),
453 "visual_inspection_performed", "2jB20LC_nEzBN4_j2ypip8",
454 "visual inspection performed",
455 PropertyType::Boolean, offsetof(Condition, visual_inspection_performed)),
457 "has_signs_of_damage", "0rQimGJFHEueqtqwbwBaC5",
458 "has signs of damage",
459 PropertyType::Boolean, offsetof(Condition, has_signs_of_damage)),
461 "is_deformed", "1g6mt3SrvDlho6YqBIu1lW",
462 "is deformed",
463 PropertyType::Boolean, offsetof(Condition, is_deformed)),
465 "is_scratched", "365luGupDCfwgtD32gGGrS",
466 "is scratched",
467 PropertyType::Boolean, offsetof(Condition, is_scratched)),
469 "is_surface_intact", "2GO932BuX5EvXOecmhbbl3",
470 "is surface intact",
471 PropertyType::Boolean, offsetof(Condition, is_surface_intact)),
473 "has_intact_edges", "0AoBmqQ9v1pw7ca1VVp_Za",
474 "has intact edges",
475 PropertyType::Boolean, offsetof(Condition, has_intact_edges)),
477 "has_signs_of_degradation", "01lVHQF$XAneE8CFtajgr_",
478 "has signs of degradation",
479 PropertyType::Boolean, offsetof(Condition, has_signs_of_degradation))
480 };
481
482 static constexpr const PropertyDescriptor* properties() noexcept {
483 return properties_array.data();
484 }
485
486 static constexpr size_t property_count() noexcept {
487 return properties_array.size();
488 }
489
490 static constexpr const char* struct_name() noexcept {
491 return "Condition";
492 }
493};
494
495// ===========================================================================
496// Section 7: Pollution - Nested Types (DangerousSubstance, Emission)
497// ===========================================================================
498
499// DangerousSubstance (5 properties - nested)
500template <>
502 static inline constexpr std::array properties_array = {
504 "content_method", "2ympiI4PL6c8ooh9Agqnz4",
505 "content of dangerous substances",
506 PropertyType::EnumValue, offsetof(DangerousSubstance, content_method)),
508 "analyzed_substance", "3Y2oTiV9r3NfoZQBVP_Bpx",
509 "analyzed for chemical substances",
510 PropertyType::String, offsetof(DangerousSubstance, analyzed_substance)),
512 "cas_number", "2tZYDby2H2PADWYcTMn50O",
513 "CAS-number",
514 PropertyType::String, offsetof(DangerousSubstance, cas_number)),
516 "ec_number", "1cV5alHQ93Zu44Uv4Iuqoj",
517 "EC-number",
518 PropertyType::String, offsetof(DangerousSubstance, ec_number)),
520 "concentration_mg_per_kg", "0yw_0Ggsf6ihdShOA1niRl",
521 "concentration of substance",
522 PropertyType::Double, offsetof(DangerousSubstance, concentration_mg_per_kg))
523 };
524
525 static constexpr const PropertyDescriptor* properties() noexcept {
526 return properties_array.data();
527 }
528
529 static constexpr size_t property_count() noexcept {
530 return properties_array.size();
531 }
532
533 static constexpr const char* struct_name() noexcept {
534 return "DangerousSubstance";
535 }
536};
537
538// Emission (7 properties - nested)
539template <>
541 static inline constexpr std::array properties_array = {
543 "standard", "1Kx6G$uIXEZO3Br$MEsdaB",
544 "emission standard",
545 PropertyType::String, offsetof(Emission, standard)),
547 "type", "12ZQ3obYHB1OhXiyy3LcfK",
548 "emission type",
549 PropertyType::String, offsetof(Emission, type)),
551 "lower_interval", "1dSnTNTGD5YQPcgcbzMJaD",
552 "emission lower Interval",
553 PropertyType::Double, offsetof(Emission, lower_interval)),
555 "upper_interval", "3YTotdivHEeQS4ij2Xa7PU",
556 "emission upper Interval",
557 PropertyType::Double, offsetof(Emission, upper_interval)),
559 "quantity_type", "33HQrsPDn9uhOu$7D3HhWU",
560 "emission quantity type",
561 PropertyType::EnumValue, offsetof(Emission, quantity_type)),
563 "measuring_unit", "3d1HQUJVb23ReixUzvSyvS",
564 "measuring unit",
565 PropertyType::String, offsetof(Emission, measuring_unit)),
567 "quantity", "0lZ6gflK18WBte7dMyQQ$h",
568 "",
569 PropertyType::Double, offsetof(Emission, quantity))
570 };
571
572 static constexpr const PropertyDescriptor* properties() noexcept {
573 return properties_array.data();
574 }
575
576 static constexpr size_t property_count() noexcept {
577 return properties_array.size();
578 }
579
580 static constexpr const char* struct_name() noexcept {
581 return "Emission";
582 }
583};
584
585// Pollution (9 properties including 2 nested arrays)
586template <>
588 static inline constexpr std::array properties_array = {
590 "contains_reach_substances", "2E6_MQ4Cn36f0s6CVYxQOR",
591 "contains substances on REACH's candidate list",
592 PropertyType::TriState, offsetof(Pollution, contains_reach_substances)),
594 "is_chemically_treated", "1Cf0jFllr2HAk8FOmT2VGr",
595 "is construction item chemically treated",
596 PropertyType::TriState, offsetof(Pollution, is_chemically_treated)),
598 "surface_treatments", "1zV5ZyYKT6CPWjKdTEZ1K0",
599 "surface treatment",
600 PropertyType::StringArray, offsetof(Pollution, surface_treatments)),
602 "dangerous_substances", "dangerous substances",
603 offsetof(Pollution, dangerous_substances)),
605 "emissions", "release of dangerous substances",
606 offsetof(Pollution, emissions)),
608 "intended_for_indoor_use", "2W1zl8TFb459xOVytRmX3J",
609 "intended for indoor use",
610 PropertyType::Boolean, offsetof(Pollution, intended_for_indoor_use)),
612 "labelling_scheme", "3Txv$QA7zCp8azbWeuubx2",
613 "labelling scheme",
614 PropertyType::String, offsetof(Pollution, labelling_scheme)),
616 "emission_level", "3areU4Rpv9gfbeDNE9eBgA",
617 "emission level",
618 PropertyType::String, offsetof(Pollution, emission_level)),
620 "has_asbestos_analysis", "2962p$Lwj68Br6satSNLAn",
621 "has asbestos analysis",
622 PropertyType::Boolean, offsetof(Pollution, has_asbestos_analysis))
623 };
624
625 static constexpr const PropertyDescriptor* properties() noexcept {
626 return properties_array.data();
627 }
628
629 static constexpr size_t property_count() noexcept {
630 return properties_array.size();
631 }
632
633 static constexpr const char* struct_name() noexcept {
634 return "Pollution";
635 }
636};
637
638// ===========================================================================
639// Section 8: Environmental Potential (2 properties)
640// ===========================================================================
641
642template <>
644 static inline constexpr std::array properties_array = {
646 "takeback_scheme_available", "2__I$nkL94YRI_YCBy0ou8",
647 "take-back scheme available",
648 PropertyType::Boolean, offsetof(EnvironmentalPotential, takeback_scheme_available)),
650 "consists_of_separate_parts", "2nZqcaXkz7YPHhKI$FMowg",
651 "construction item consists of separate parts naturally ",
652 PropertyType::Boolean, offsetof(EnvironmentalPotential, consists_of_separate_parts))
653 };
654
655 static constexpr const PropertyDescriptor* properties() noexcept {
656 return properties_array.data();
657 }
658
659 static constexpr size_t property_count() noexcept {
660 return properties_array.size();
661 }
662
663 static constexpr const char* struct_name() noexcept {
664 return "EnvironmentalPotential";
665 }
666};
667
668// ===========================================================================
669// Section 9: Fire Properties (4 properties)
670// ===========================================================================
671
672template <>
674 static inline constexpr std::array properties_array = {
676 "reaction_to_fire", "2bipZ4JrzDnwNZZHkwfk8O",
677 "reaction to fire",
678 PropertyType::String, offsetof(FireProperties, reaction_to_fire)),
680 "resistance_to_fire", "0NlhENUQr4YA5$p0zBrXSp",
681 "resistance to fire",
682 PropertyType::String, offsetof(FireProperties, resistance_to_fire)),
684 "documentation_of_fire_classification", "1DdkDjj1H7POQtnzDtu7CC",
685 "documentation of fire classification",
686 PropertyType::String, offsetof(FireProperties, documentation_of_fire_classification)),
688 "field_of_application", "37sNiQNwHC399AW2B60MrY",
689 "field of application in relation to fire",
690 PropertyType::String, offsetof(FireProperties, field_of_application))
691 };
692
693 static constexpr const PropertyDescriptor* properties() noexcept {
694 return properties_array.data();
695 }
696
697 static constexpr size_t property_count() noexcept {
698 return properties_array.size();
699 }
700
701 static constexpr const char* struct_name() noexcept {
702 return "FireProperties";
703 }
704};
705
706// ===========================================================================
707// Section 10: History (1 property)
708// ===========================================================================
709
710template <>
712 static inline constexpr std::array properties_array = {
714 "previous_usage_environments", "3BiwSSLEz9l8YLgoWcixHq",
715 "previous usage environment",
716 PropertyType::StringArray, offsetof(History, previous_usage_environments))
717 };
718
719 static constexpr const PropertyDescriptor* properties() noexcept {
720 return properties_array.data();
721 }
722
723 static constexpr size_t property_count() noexcept {
724 return properties_array.size();
725 }
726
727 static constexpr const char* struct_name() noexcept {
728 return "History";
729 }
730};
731
732} // namespace reusex::core::traits
constexpr PropertyDescriptor make_nested_property(const char *field_name, const char *json_name, size_t field_offset) noexcept
Create a nested object array property descriptor.
constexpr PropertyDescriptor make_property(const char *field_name, const char *leksikon_guid, const char *json_name, PropertyType type, size_t field_offset) noexcept
Create a simple property descriptor (non-nested).
PropertyType
Property type enumeration for MaterialPassport serialization.
@ TriState
TriState enum (yes/no/unknown).
@ ObjectArray
std::vector<StructType> (nested objects)
Certifications, approvals and declarations for the item.
Condition assessment of the construction item.
Description of the reused construction item.
Dangerous substance analysis record.
Physical dimensions and geometry of the construction item.
Emission measurement record.
Environmental and resource potential for sustainable utilization.
Fire-related properties of the construction item.
Historical usage information for the construction item.
Owner contact information for the material passport.
Pollution, content and emission information.
Original product information.
size_t nested_count
For nested types: number of properties in nested array.
const PropertyDescriptor * nested_properties
For nested types (ObjectArray): pointer to nested property array.
const char * field_name
C++ field name (e.g., "contact_email").
size_t offset
Offset of field in struct (calculated via offsetof macro).
const char * leksikon_guid
Molio leksiCon GUID (e.g., "0Bwj05D$55V931bq9VaBE5").
const char * json_name
JSON export name matching the Danish standard template (e.g., "materialpassport owner contact email")...
static constexpr const char * struct_name() noexcept
static constexpr const PropertyDescriptor * properties() noexcept
static constexpr const char * struct_name() noexcept
static constexpr const PropertyDescriptor * properties() noexcept
static constexpr const PropertyDescriptor * properties() noexcept
static constexpr const PropertyDescriptor * properties() noexcept
static constexpr const PropertyDescriptor * properties() noexcept
static constexpr const char * struct_name() noexcept
static constexpr const char * struct_name() noexcept
static constexpr const PropertyDescriptor * properties() noexcept
static constexpr const PropertyDescriptor * properties() noexcept
static constexpr const PropertyDescriptor * properties() noexcept
static constexpr const char * struct_name() noexcept
static constexpr const PropertyDescriptor * properties() noexcept
static constexpr size_t property_count() noexcept
static constexpr const char * struct_name() noexcept
static constexpr const char * struct_name() noexcept
static constexpr size_t property_count() noexcept
static constexpr const PropertyDescriptor * properties() noexcept
static constexpr const char * struct_name() noexcept
static constexpr const PropertyDescriptor * properties() noexcept
static constexpr const PropertyDescriptor * properties() noexcept
Trait interface for property metadata.
static constexpr const char * struct_name() noexcept
Get human-readable struct name.
static constexpr const PropertyDescriptor * properties() noexcept
Get array of property descriptors.
static constexpr size_t property_count() noexcept
Get number of properties in the struct.