cg_construction_mode_2_parsing_schemas.h (5571B)
1 /* Copyright (C) 2022 Université de Pau et des Pays de l'Adour UPPA 2 * Copyright (C) 2022 CNRS 3 * Copyright (C) 2022 Sorbonne Université 4 * Copyright (C) 2022 Université Paul Sabatier 5 * Copyright (C) 2022 |Meso|Star> (contact@meso-star.com) 6 * 7 * This program is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program. If not, see <http://www.gnu.org/licenses/>. */ 19 20 #ifndef FG_MODE2_PARSING_SCHEMAS__ 21 #define FG_MODE2_PARSING_SCHEMAS__ 22 23 #include "cg_cyaml.h" 24 25 #include <rsys/str.h> 26 27 struct parsed_dataset_cmode_2 { 28 char* name; 29 double wall_thickness; /* must be > 0 */ 30 double floor_thickness; /* must be > 0 */ 31 double inter_floor_thickness; /* must be > 0 */ 32 double roof_thickness; /* must be > 0 */ 33 double internal_insulation_thickness; /* can be 0 */ 34 double external_insulation_thickness; /* can be 0 */ 35 double floor_insulation_thickness; /* can be 0 */ 36 double roof_insulation_thickness; /* can be 0 */ 37 double foundation_depth; /* can be 0 */ 38 double crawl_height; /* can be 0 */ 39 double glass_ratio; /* in [0, 1] */ 40 double windows_min_width; /* must be > 0 */ 41 double windows_max_width; /* must be >= windows_min_width */ 42 double windows_min_spacing; /* must be > 0 */ 43 double windows_height_ratio; /* in [0, 1] */ 44 int has_attic; 45 }; 46 47 /********************************************************/ 48 /* Types used for parsing and to define parsing schemas */ 49 /********************************************************/ 50 51 struct parsed_catalog_cmode_2 { 52 struct parsed_dataset_cmode_2* datasets; 53 size_t datasets_count; 54 }; 55 56 static const cyaml_schema_field_t dataset_cmode_2_fields_schema[] = { 57 CYAML_FIELD_STRING_PTR("name", CYAML_FLAG_POINTER, 58 struct parsed_dataset_cmode_2, name, 0, CYAML_UNLIMITED), 59 CYAML_FIELD_FLOAT("wall_thickness", CYAML_FLAG_DEFAULT, 60 struct parsed_dataset_cmode_2, wall_thickness), 61 CYAML_FIELD_FLOAT("floor_thickness", CYAML_FLAG_DEFAULT, 62 struct parsed_dataset_cmode_2, floor_thickness), 63 CYAML_FIELD_FLOAT("inter_floor_thickness", CYAML_FLAG_DEFAULT, 64 struct parsed_dataset_cmode_2, inter_floor_thickness), 65 CYAML_FIELD_FLOAT("roof_thickness", CYAML_FLAG_DEFAULT, 66 struct parsed_dataset_cmode_2, roof_thickness), 67 CYAML_FIELD_FLOAT("internal_insulation_thickness", CYAML_FLAG_DEFAULT, 68 struct parsed_dataset_cmode_2, internal_insulation_thickness), 69 CYAML_FIELD_FLOAT("external_insulation_thickness", CYAML_FLAG_DEFAULT, 70 struct parsed_dataset_cmode_2, external_insulation_thickness), 71 CYAML_FIELD_FLOAT("floor_insulation_thickness", CYAML_FLAG_DEFAULT, 72 struct parsed_dataset_cmode_2, floor_insulation_thickness), 73 CYAML_FIELD_FLOAT("roof_insulation_thickness", CYAML_FLAG_DEFAULT, 74 struct parsed_dataset_cmode_2, roof_insulation_thickness), 75 CYAML_FIELD_FLOAT("foundation_depth", CYAML_FLAG_DEFAULT, 76 struct parsed_dataset_cmode_2, foundation_depth), 77 CYAML_FIELD_FLOAT("crawl_height", CYAML_FLAG_DEFAULT, 78 struct parsed_dataset_cmode_2, crawl_height), 79 CYAML_FIELD_BOOL("has_attic", CYAML_FLAG_DEFAULT, 80 struct parsed_dataset_cmode_2, has_attic), 81 CYAML_FIELD_FLOAT("glass_ratio", CYAML_FLAG_DEFAULT, 82 struct parsed_dataset_cmode_2, glass_ratio), 83 CYAML_FIELD_FLOAT("windows_min_width", CYAML_FLAG_DEFAULT, 84 struct parsed_dataset_cmode_2, windows_min_width), 85 CYAML_FIELD_FLOAT("windows_max_width", CYAML_FLAG_DEFAULT, 86 struct parsed_dataset_cmode_2, windows_max_width), 87 CYAML_FIELD_FLOAT("windows_min_spacing", CYAML_FLAG_DEFAULT, 88 struct parsed_dataset_cmode_2, windows_min_spacing), 89 CYAML_FIELD_FLOAT("windows_height_ratio", CYAML_FLAG_DEFAULT, 90 struct parsed_dataset_cmode_2, windows_height_ratio), 91 CYAML_FIELD_END 92 }; 93 94 static const struct cyaml_schema_value p_dataset_cmode_2_schema = { 95 CYAML_VALUE_MAPPING(CYAML_FLAG_POINTER, struct parsed_dataset_cmode_2, 96 dataset_cmode_2_fields_schema), 97 }; 98 99 static const struct cyaml_schema_value dataset_cmode_2_schema = { 100 CYAML_VALUE_MAPPING(CYAML_FLAG_DEFAULT, struct parsed_dataset_cmode_2, 101 dataset_cmode_2_fields_schema), 102 }; 103 104 static const cyaml_schema_field_t cmode_2_fields_schemas[] = { 105 CYAML_FIELD_IGNORE("construction_mode", CYAML_FLAG_DEFAULT), 106 { 107 .key = "datasets", 108 .value = { 109 .type = CYAML_SEQUENCE, 110 .flags = CYAML_FLAG_POINTER, 111 .data_size = sizeof(struct parsed_dataset_cmode_2), 112 .sequence = { 113 .entry = &dataset_cmode_2_schema, 114 .min = 1, 115 .max = CYAML_UNLIMITED, 116 } 117 }, 118 .data_offset = offsetof(struct parsed_catalog_cmode_2, datasets), 119 .count_size = sizeof(((struct parsed_catalog_cmode_2*)0)->datasets_count), 120 .count_offset = offsetof(struct parsed_catalog_cmode_2, datasets_count), 121 }, 122 CYAML_FIELD_END 123 }; 124 125 /* Top-level schema. The top level value for the construction mode is a mapping. 126 * Its fields are defined in cmode_2_fields_schemas. 127 */ 128 static const cyaml_schema_value_t construction_mode_2_schema = { 129 CYAML_VALUE_MAPPING(CYAML_FLAG_POINTER, struct parsed_catalog_cmode_2, 130 cmode_2_fields_schemas), 131 }; 132 133 #endif