Line data Source code
1 : /* File: gui_sketch_defaults.inl; Copyright and License: see below */ 2 : 3 : #include "u8/u8_trace.h" 4 : #include "u8/u8_log.h" 5 : #include <assert.h> 6 : 7 0 : static inline void gui_sketch_defaults_init ( gui_sketch_defaults_t *this_ ) 8 : { 9 0 : } 10 : 11 0 : static inline void gui_sketch_defaults_destroy ( gui_sketch_defaults_t *this_ ) 12 : { 13 0 : } 14 : 15 0 : static inline data_classifier_type_t gui_sketch_defaults_get_classifier_type ( const gui_sketch_defaults_t *this_, 16 : data_diagram_type_t diagram_type ) 17 : { 18 : data_classifier_type_t result; 19 : 20 0 : switch ( diagram_type ) 21 : { 22 0 : case DATA_DIAGRAM_TYPE_LIST: 23 : { 24 0 : result = DATA_CLASSIFIER_TYPE_OBJECT; 25 : } 26 0 : break; 27 : 28 0 : case DATA_DIAGRAM_TYPE_BOX_DIAGRAM: 29 : { 30 0 : result = DATA_CLASSIFIER_TYPE_PACKAGE; 31 : } 32 0 : break; 33 : 34 0 : case DATA_DIAGRAM_TYPE_SYSML_BLOCK_DEFINITION_DIAGRAM: /* and */ 35 : case DATA_DIAGRAM_TYPE_SYSML_INTERNAL_BLOCK_DIAGRAM: 36 : { 37 0 : result = DATA_CLASSIFIER_TYPE_BLOCK; 38 : } 39 0 : break; 40 : 41 0 : case DATA_DIAGRAM_TYPE_SYSML_PARAMETRIC_DIAGRAM: 42 : { 43 0 : result = DATA_CLASSIFIER_TYPE_BLOCK; 44 : } 45 0 : break; 46 : 47 0 : case DATA_DIAGRAM_TYPE_SYSML_REQUIREMENTS_DIAGRAM: 48 : { 49 0 : result = DATA_CLASSIFIER_TYPE_REQUIREMENT; 50 : } 51 0 : break; 52 : 53 0 : case DATA_DIAGRAM_TYPE_UML_USE_CASE_DIAGRAM: 54 : { 55 0 : result = DATA_CLASSIFIER_TYPE_USE_CASE; 56 : } 57 0 : break; 58 : 59 0 : case DATA_DIAGRAM_TYPE_UML_ACTIVITY_DIAGRAM: 60 : { 61 0 : result = DATA_CLASSIFIER_TYPE_ACTIVITY; 62 : } 63 0 : break; 64 : 65 0 : case DATA_DIAGRAM_TYPE_UML_STATE_MACHINE_DIAGRAM: 66 : { 67 0 : result = DATA_CLASSIFIER_TYPE_STATE; 68 : } 69 0 : break; 70 : 71 0 : case DATA_DIAGRAM_TYPE_UML_SEQUENCE_DIAGRAM: 72 : { 73 0 : result = DATA_CLASSIFIER_TYPE_CLASS; 74 : } 75 0 : break; 76 : 77 0 : case DATA_DIAGRAM_TYPE_UML_COMMUNICATION_DIAGRAM: 78 : { 79 0 : result = DATA_CLASSIFIER_TYPE_CLASS; 80 : } 81 0 : break; 82 : 83 0 : case DATA_DIAGRAM_TYPE_INTERACTION_OVERVIEW_DIAGRAM: 84 : { 85 0 : result = DATA_CLASSIFIER_TYPE_DIAGRAM_REFERENCE; 86 : } 87 0 : break; 88 : 89 0 : case DATA_DIAGRAM_TYPE_UML_TIMING_DIAGRAM: 90 : { 91 0 : result = DATA_CLASSIFIER_TYPE_STATE; 92 : } 93 0 : break; 94 : 95 0 : case DATA_DIAGRAM_TYPE_UML_DEPLOYMENT_DIAGRAM: 96 : { 97 0 : result = DATA_CLASSIFIER_TYPE_NODE; 98 : } 99 0 : break; 100 : 101 0 : case DATA_DIAGRAM_TYPE_UML_COMPONENT_DIAGRAM: 102 : { 103 0 : result = DATA_CLASSIFIER_TYPE_COMPONENT; 104 : } 105 0 : break; 106 : 107 0 : case DATA_DIAGRAM_TYPE_UML_COMPOSITE_STRUCTURE_DIAGRAM: 108 : { 109 0 : result = DATA_CLASSIFIER_TYPE_PART; 110 : } 111 0 : break; 112 : 113 0 : case DATA_DIAGRAM_TYPE_UML_PACKAGE_DIAGRAM: 114 : { 115 0 : result = DATA_CLASSIFIER_TYPE_PACKAGE; 116 : } 117 0 : break; 118 : 119 0 : case DATA_DIAGRAM_TYPE_UML_CLASS_DIAGRAM: 120 : { 121 0 : result = DATA_CLASSIFIER_TYPE_CLASS; 122 : } 123 0 : break; 124 : 125 0 : case DATA_DIAGRAM_TYPE_UML_PROFILE_DIAGRAM: 126 : { 127 0 : result = DATA_CLASSIFIER_TYPE_STEREOTYPE; 128 : } 129 0 : break; 130 : 131 0 : default: 132 : { 133 0 : U8_LOG_ANOMALY("diagram_type out of range in gui_sketch_defaults_get_classifier_type"); 134 0 : result = DATA_CLASSIFIER_TYPE_COMMENT; 135 : /* this case can happen if a model file of a new cfu version is opened with an older version of cfu */ 136 : } 137 0 : break; 138 : } 139 : 140 0 : return result; 141 : } 142 : 143 0 : static inline data_relationship_type_t gui_sketch_defaults_get_relationship_type ( const gui_sketch_defaults_t *this_, 144 : data_classifier_type_t from_classifier_type, 145 : data_feature_type_t from_feature_type ) 146 : { 147 : data_relationship_type_t result; 148 : 149 0 : if ( from_feature_type == DATA_FEATURE_TYPE_LIFELINE ) 150 : { 151 0 : result = DATA_RELATIONSHIP_TYPE_UML_SYNC_CALL; 152 : } 153 : else 154 : { 155 0 : switch ( from_classifier_type ) 156 : { 157 0 : case DATA_CLASSIFIER_TYPE_BLOCK: /* and */ 158 : case DATA_CLASSIFIER_TYPE_CONSTRAINT_BLOCK: 159 : { 160 0 : result = DATA_RELATIONSHIP_TYPE_UML_COMMUNICATION_PATH; 161 : } 162 0 : break; 163 : 164 0 : case DATA_CLASSIFIER_TYPE_REQUIREMENT: 165 : { 166 0 : result = DATA_RELATIONSHIP_TYPE_UML_TRACE; 167 : } 168 0 : break; 169 : 170 0 : case DATA_CLASSIFIER_TYPE_ACTOR: 171 : { 172 0 : result = DATA_RELATIONSHIP_TYPE_UML_ASSOCIATION; 173 : } 174 0 : break; 175 : 176 0 : case DATA_CLASSIFIER_TYPE_USE_CASE: 177 : { 178 0 : result = DATA_RELATIONSHIP_TYPE_UML_INCLUDE; /* a simple include is preferred over the more complex DATA_RELATIONSHIP_TYPE_UML_EXTEND. */ 179 : } 180 0 : break; 181 : 182 0 : case DATA_CLASSIFIER_TYPE_SUBSYSTEM: 183 : { 184 : /* containment would make sense here but is not intuitive from a useability point of view */ 185 0 : result = DATA_RELATIONSHIP_TYPE_UML_ASSOCIATION; 186 : } 187 0 : break; 188 : 189 0 : case DATA_CLASSIFIER_TYPE_ACTIVITY: /* and */ 190 : case DATA_CLASSIFIER_TYPE_STATE: /* and */ 191 : case DATA_CLASSIFIER_TYPE_DIAGRAM_REFERENCE: /* and */ 192 : case DATA_CLASSIFIER_TYPE_DYN_INTERRUPTABLE_REGION: /* and */ 193 : case DATA_CLASSIFIER_TYPE_DYN_INITIAL_NODE: /* and */ 194 : case DATA_CLASSIFIER_TYPE_DYN_FINAL_NODE: /* and */ 195 : case DATA_CLASSIFIER_TYPE_DYN_FORK_NODE: /* and */ 196 : case DATA_CLASSIFIER_TYPE_DYN_JOIN_NODE: /* and */ 197 : case DATA_CLASSIFIER_TYPE_DYN_DECISION_NODE: /* and */ 198 : case DATA_CLASSIFIER_TYPE_DYN_SHALLOW_HISTORY: /* and */ 199 : case DATA_CLASSIFIER_TYPE_DYN_DEEP_HISTORY: /* and */ 200 : case DATA_CLASSIFIER_TYPE_DYN_ACCEPT_EVENT: /* and */ 201 : case DATA_CLASSIFIER_TYPE_DYN_ACCEPT_TIME_EVENT: /* and */ 202 : case DATA_CLASSIFIER_TYPE_DYN_SEND_SIGNAL: 203 : { 204 0 : result = DATA_RELATIONSHIP_TYPE_UML_CONTROL_FLOW; /* control is preferred over DATA_RELATIONSHIP_TYPE_UML_OBJECT_FLOW (?) */ 205 : } 206 0 : break; 207 : 208 0 : case DATA_CLASSIFIER_TYPE_NODE: /* and */ 209 : case DATA_CLASSIFIER_TYPE_COMPONENT: /* and */ 210 : case DATA_CLASSIFIER_TYPE_PART: 211 : { 212 0 : result = DATA_RELATIONSHIP_TYPE_UML_COMMUNICATION_PATH; /* a node/component/part communicates with another node */ 213 : } 214 0 : break; 215 : 216 0 : case DATA_CLASSIFIER_TYPE_ARTIFACT: 217 : { 218 0 : result = DATA_RELATIONSHIP_TYPE_UML_DEPLOY; /* an artifact is deployed onto something, prefferred over DATA_RELATIONSHIP_TYPE_UML_MANIFEST */ 219 : } 220 0 : break; 221 : 222 0 : case DATA_CLASSIFIER_TYPE_INTERFACE: /* and */ 223 : case DATA_CLASSIFIER_TYPE_CLASS: /* and */ 224 : case DATA_CLASSIFIER_TYPE_OBJECT: /* and */ 225 : { 226 0 : result = DATA_RELATIONSHIP_TYPE_UML_ASSOCIATION; 227 : } 228 0 : break; 229 : 230 0 : case DATA_CLASSIFIER_TYPE_PACKAGE: 231 : { 232 0 : result = DATA_RELATIONSHIP_TYPE_UML_ASSOCIATION; /* containment is a not-so-nice default type - therefore association is preferred */ 233 : } 234 0 : break; 235 : 236 0 : case DATA_CLASSIFIER_TYPE_COMMENT: /* and */ 237 : case DATA_CLASSIFIER_TYPE_IMAGE: 238 : { 239 0 : result = DATA_RELATIONSHIP_TYPE_UML_DEPENDENCY; 240 : } 241 0 : break; 242 : 243 0 : case DATA_CLASSIFIER_TYPE_STEREOTYPE: 244 : { 245 0 : result = DATA_RELATIONSHIP_TYPE_UML_GENERALIZATION; 246 : } 247 0 : break; 248 : 249 0 : default: 250 : { 251 0 : U8_LOG_ANOMALY("data_classifier_type_t out of range in gui_sketch_defaults_get_relationship_type"); 252 0 : result = DATA_RELATIONSHIP_TYPE_UML_DEPENDENCY; 253 : /* this case can happen if a model file of a new cfu version is opened with an older version of cfu */ 254 : } 255 0 : break; 256 : } 257 : } 258 : 259 0 : return result; 260 : } 261 : 262 0 : static inline data_feature_type_t gui_sketch_defaults_get_feature_type ( const gui_sketch_defaults_t *this_, 263 : data_classifier_type_t parent_classifier_type ) 264 : { 265 : data_feature_type_t result; 266 : 267 0 : switch ( parent_classifier_type ) 268 : { 269 0 : case DATA_CLASSIFIER_TYPE_BLOCK: /* and */ 270 : case DATA_CLASSIFIER_TYPE_CONSTRAINT_BLOCK: 271 : { 272 0 : result = DATA_FEATURE_TYPE_PORT; 273 : } 274 0 : break; 275 : 276 0 : case DATA_CLASSIFIER_TYPE_REQUIREMENT: 277 : { 278 0 : result = DATA_FEATURE_TYPE_TAGGED_VALUE; 279 : } 280 0 : break; 281 : 282 0 : case DATA_CLASSIFIER_TYPE_ACTOR: 283 : { 284 0 : result = DATA_FEATURE_TYPE_PROPERTY; 285 : } 286 0 : break; 287 : 288 0 : case DATA_CLASSIFIER_TYPE_USE_CASE: 289 : { 290 0 : result = DATA_FEATURE_TYPE_PROPERTY; 291 : } 292 0 : break; 293 : 294 0 : case DATA_CLASSIFIER_TYPE_SUBSYSTEM: 295 : { 296 0 : result = DATA_FEATURE_TYPE_PORT; 297 : } 298 0 : break; 299 : 300 0 : case DATA_CLASSIFIER_TYPE_ACTIVITY: /* and */ 301 : case DATA_CLASSIFIER_TYPE_DYN_ACCEPT_EVENT: /* and */ 302 : case DATA_CLASSIFIER_TYPE_DYN_ACCEPT_TIME_EVENT: /* and */ 303 : case DATA_CLASSIFIER_TYPE_DYN_SEND_SIGNAL: 304 : { 305 0 : result = DATA_FEATURE_TYPE_OUT_PORT_PIN; /* Out Pin */ 306 : } 307 0 : break; 308 : 309 0 : case DATA_CLASSIFIER_TYPE_STATE: 310 : { 311 0 : result = DATA_FEATURE_TYPE_EXIT; 312 : } 313 0 : break; 314 : 315 0 : case DATA_CLASSIFIER_TYPE_DIAGRAM_REFERENCE: /* and */ 316 : case DATA_CLASSIFIER_TYPE_DYN_INTERRUPTABLE_REGION: /* and */ 317 : case DATA_CLASSIFIER_TYPE_DYN_INITIAL_NODE: /* and */ 318 : case DATA_CLASSIFIER_TYPE_DYN_FINAL_NODE: /* and */ 319 : case DATA_CLASSIFIER_TYPE_DYN_FORK_NODE: /* and */ 320 : case DATA_CLASSIFIER_TYPE_DYN_JOIN_NODE: /* and */ 321 : case DATA_CLASSIFIER_TYPE_DYN_DECISION_NODE: /* and */ 322 : case DATA_CLASSIFIER_TYPE_DYN_SHALLOW_HISTORY: /* and */ 323 : case DATA_CLASSIFIER_TYPE_DYN_DEEP_HISTORY: 324 : { 325 0 : result = DATA_FEATURE_TYPE_OPERATION; 326 : } 327 0 : break; 328 : 329 0 : case DATA_CLASSIFIER_TYPE_NODE: /* and */ 330 : case DATA_CLASSIFIER_TYPE_COMPONENT: /* and */ 331 : case DATA_CLASSIFIER_TYPE_PART: 332 : { 333 0 : result = DATA_FEATURE_TYPE_PORT; 334 : } 335 0 : break; 336 : 337 0 : case DATA_CLASSIFIER_TYPE_ARTIFACT: 338 : { 339 0 : result = DATA_FEATURE_TYPE_PROPERTY; 340 : } 341 0 : break; 342 : 343 0 : case DATA_CLASSIFIER_TYPE_INTERFACE: /* and */ 344 : case DATA_CLASSIFIER_TYPE_CLASS: /* and */ 345 : case DATA_CLASSIFIER_TYPE_OBJECT: /* and */ 346 : { 347 0 : result = DATA_FEATURE_TYPE_OPERATION; 348 : } 349 0 : break; 350 : 351 0 : case DATA_CLASSIFIER_TYPE_PACKAGE: 352 : { 353 0 : result = DATA_FEATURE_TYPE_TAGGED_VALUE; 354 : } 355 0 : break; 356 : 357 0 : case DATA_CLASSIFIER_TYPE_COMMENT: 358 : case DATA_CLASSIFIER_TYPE_IMAGE: 359 : { 360 0 : result = DATA_FEATURE_TYPE_TAGGED_VALUE; 361 : } 362 0 : break; 363 : 364 0 : case DATA_CLASSIFIER_TYPE_STEREOTYPE: 365 : { 366 : /* spec-ref: https://www.omg.org/spec/UML/2.5.1/PDF chapter 12.3.3.4 */ 367 : /* a property of a stereotype-class is a tagged-value definition */ 368 0 : result = DATA_FEATURE_TYPE_PROPERTY; 369 : } 370 0 : break; 371 : 372 0 : default: 373 : { 374 0 : U8_LOG_ANOMALY("data_classifier_type_t out of range in gui_sketch_defaults_get_feature_type"); 375 0 : result = DATA_FEATURE_TYPE_TAGGED_VALUE; 376 : /* this case can happen if a model file of a new cfu version is opened with an older version of cfu */ 377 : } 378 0 : break; 379 : } 380 : 381 0 : return result; 382 : } 383 : 384 : 385 : /* 386 : Copyright 2017-2024 Andreas Warnke 387 : 388 : Licensed under the Apache License, Version 2.0 (the "License"); 389 : you may not use this file except in compliance with the License. 390 : You may obtain a copy of the License at 391 : 392 : http://www.apache.org/licenses/LICENSE-2.0 393 : 394 : Unless required by applicable law or agreed to in writing, software 395 : distributed under the License is distributed on an "AS IS" BASIS, 396 : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 397 : See the License for the specific language governing permissions and 398 : limitations under the License. 399 : */