Line data Source code
1 : /* File: gui_sketch_object_creator.c; Copyright and License: see below */
2 :
3 : #include "sketch/gui_sketch_object_creator.h"
4 : #include "geometry/geometry_rectangle.h"
5 : #include "ctrl_multi_step_changer.h"
6 : #include "entity/data_table.h"
7 : #include "entity/data_id.h"
8 : #include "u8/u8_trace.h"
9 : #include "u8/u8_log.h"
10 : #include <stdint.h>
11 : #include <stdbool.h>
12 :
13 0 : void gui_sketch_object_creator_init ( gui_sketch_object_creator_t *this_,
14 : ctrl_controller_t *controller,
15 : data_database_reader_t *db_reader,
16 : gui_simple_message_to_user_t *message_to_user )
17 : {
18 0 : U8_TRACE_BEGIN();
19 :
20 0 : (*this_).db_reader = db_reader;
21 0 : (*this_).controller = controller;
22 0 : gui_sketch_defaults_init ( &((*this_).defaults ) );
23 0 : data_rules_init ( &((*this_).data_rules ) );
24 0 : (*this_).message_to_user = message_to_user;
25 :
26 0 : U8_TRACE_END();
27 0 : }
28 :
29 0 : void gui_sketch_object_creator_destroy ( gui_sketch_object_creator_t *this_ )
30 : {
31 0 : U8_TRACE_BEGIN();
32 :
33 0 : (*this_).message_to_user = NULL;
34 0 : data_rules_destroy ( &((*this_).data_rules) );
35 0 : gui_sketch_defaults_destroy ( &((*this_).defaults) );
36 0 : (*this_).db_reader = NULL;
37 0 : (*this_).controller = NULL;
38 :
39 0 : U8_TRACE_END();
40 0 : }
41 :
42 0 : u8_error_t gui_sketch_object_creator_create_classifier ( gui_sketch_object_creator_t *this_,
43 : data_row_id_t diagram_id,
44 : int32_t x_order,
45 : int32_t y_order,
46 : data_row_id_t *out_diagramelement_id,
47 : data_row_id_t *out_classifier_id )
48 : {
49 0 : U8_TRACE_BEGIN();
50 0 : assert ( NULL != out_classifier_id );
51 0 : assert ( NULL != out_diagramelement_id );
52 0 : assert ( DATA_ROW_ID_VOID != diagram_id );
53 :
54 : u8_error_t c_result;
55 :
56 : /* get type of diagram */
57 0 : data_diagram_type_t diag_type = DATA_DIAGRAM_TYPE_LIST;
58 : {
59 : const u8_error_t diag_err
60 0 : = data_database_reader_get_diagram_by_id( (*this_).db_reader,
61 : diagram_id,
62 : &((*this_).private_temp_diagram)
63 : );
64 0 : if ( U8_ERROR_NONE == diag_err )
65 : {
66 0 : diag_type = data_diagram_get_diagram_type( &((*this_).private_temp_diagram) );
67 0 : data_diagram_destroy ( &((*this_).private_temp_diagram) );
68 : }
69 : else
70 : {
71 0 : U8_LOG_ERROR_INT( "gui_sketch_object_creator_create_classifier cannot find diagram:", diagram_id );
72 : }
73 : }
74 :
75 : /* determine type of new classifier */
76 : data_classifier_type_t type_of_new_classifier;
77 0 : type_of_new_classifier = gui_sketch_defaults_get_classifier_type( &((*this_).defaults), diag_type );
78 :
79 : /* propose a name */
80 : const char *const full_new_name
81 0 : = gui_sketch_object_creator_private_propose_classifier_name( this_, type_of_new_classifier );
82 :
83 : /* define classifier */
84 : const u8_error_t d_err
85 0 : = data_classifier_init_new ( &((*this_).private_temp_classifier),
86 : type_of_new_classifier,
87 : "", /* stereotype */
88 : full_new_name,
89 : "", /* description */
90 : x_order,
91 : y_order,
92 : y_order /* y_order used also as list_order */
93 : );
94 0 : if ( d_err != U8_ERROR_NONE )
95 : {
96 0 : U8_LOG_ERROR_HEX("data_classifier_init_new failed in gui_sketch_object_creator_create_classifier:",d_err);
97 : }
98 :
99 : /* create classifier, adapt name if necessary: */
100 : {
101 : ctrl_multi_step_changer_t multi_stepper;
102 0 : ctrl_multi_step_changer_init( &multi_stepper, (*this_).controller, (*this_).db_reader );
103 : u8_error_t out_info;
104 0 : c_result = ctrl_multi_step_changer_create_classifier( &multi_stepper,
105 : &((*this_).private_temp_classifier),
106 : &out_info
107 : );
108 0 : *out_classifier_id = data_classifier_get_row_id( &((*this_).private_temp_classifier) );
109 0 : ctrl_multi_step_changer_destroy( &multi_stepper );
110 : }
111 :
112 0 : if ( U8_ERROR_NONE == c_result )
113 : {
114 : /* get diagram controller */
115 0 : ctrl_diagram_controller_t *const diagram_control = ctrl_controller_get_diagram_control_ptr( (*this_).controller );
116 :
117 : data_diagramelement_t new_diagele;
118 0 : data_diagramelement_init_new ( &new_diagele,
119 : diagram_id,
120 : *out_classifier_id,
121 : DATA_DIAGRAMELEMENT_FLAG_NONE,
122 : DATA_ROW_ID_VOID
123 : );
124 :
125 0 : c_result = ctrl_diagram_controller_create_diagramelement ( diagram_control,
126 : &new_diagele,
127 : CTRL_UNDO_REDO_ACTION_BOUNDARY_APPEND,
128 : out_diagramelement_id
129 : );
130 :
131 : /* cleanup */
132 0 : data_diagramelement_destroy ( &new_diagele );
133 : }
134 0 : else if ( U8_ERROR_READ_ONLY_DB == c_result )
135 : {
136 : /* notify read-only warning to user */
137 0 : gui_simple_message_to_user_show_message( (*this_).message_to_user,
138 : GUI_SIMPLE_MESSAGE_TYPE_WARNING,
139 : GUI_SIMPLE_MESSAGE_CONTENT_DB_IS_READ_ONLY
140 : );
141 : }
142 :
143 : /* cleanup */
144 0 : data_classifier_destroy ( &((*this_).private_temp_classifier) );
145 :
146 0 : U8_TRACE_END_ERR( c_result );
147 0 : return c_result;
148 : }
149 :
150 0 : u8_error_t gui_sketch_object_creator_create_classifier_as_child ( gui_sketch_object_creator_t *this_,
151 : data_row_id_t diagram_id,
152 : data_row_id_t parent_classifier_id,
153 : int32_t x_order,
154 : int32_t y_order,
155 : data_row_id_t *out_diagramelement_id,
156 : data_row_id_t *out_classifier_id,
157 : data_row_id_t *out_relationship_id )
158 : {
159 0 : U8_TRACE_BEGIN();
160 0 : assert ( NULL != out_classifier_id );
161 0 : assert ( NULL != out_diagramelement_id );
162 0 : assert ( NULL != out_relationship_id );
163 0 : assert ( DATA_ROW_ID_VOID != parent_classifier_id );
164 0 : assert ( DATA_ROW_ID_VOID != diagram_id );
165 :
166 : u8_error_t c_result;
167 :
168 0 : c_result = gui_sketch_object_creator_create_classifier( this_,
169 : diagram_id,
170 : x_order,
171 : y_order,
172 : out_diagramelement_id,
173 : out_classifier_id
174 : );
175 :
176 0 : if ( U8_ERROR_NONE == c_result )
177 : {
178 : /* get classifier controller */
179 : ctrl_classifier_controller_t *classifier_control;
180 0 : classifier_control = ctrl_controller_get_classifier_control_ptr ( (*this_).controller );
181 :
182 : /* define relationship */
183 : const u8_error_t d_err
184 0 : = data_relationship_init_new( &((*this_).private_temp_relationship),
185 : parent_classifier_id,
186 : DATA_ROW_ID_VOID,
187 : *out_classifier_id,
188 : DATA_ROW_ID_VOID,
189 : DATA_RELATIONSHIP_TYPE_UML_CONTAINMENT,
190 : "", /* =stereotype */
191 : "", /* =name */
192 : "", /* =description */
193 : y_order /* =list_order */
194 : );
195 0 : if ( d_err != U8_ERROR_NONE )
196 : {
197 0 : U8_LOG_ERROR_HEX("data_relationship_init failed in gui_sketch_object_creator_create_classifier_as_child:",d_err);
198 : }
199 :
200 : /* create relationship */
201 0 : c_result = ctrl_classifier_controller_create_relationship( classifier_control,
202 0 : &((*this_).private_temp_relationship),
203 : CTRL_UNDO_REDO_ACTION_BOUNDARY_APPEND,
204 : out_relationship_id
205 : );
206 :
207 : /* cleanup */
208 0 : data_relationship_destroy( &((*this_).private_temp_relationship) );
209 : }
210 :
211 0 : U8_TRACE_END_ERR( c_result );
212 0 : return c_result;
213 : }
214 :
215 0 : u8_error_t gui_sketch_object_creator_create_diagram ( gui_sketch_object_creator_t *this_,
216 : data_row_id_t parent_diagram_id,
217 : int32_t list_order,
218 : data_row_id_t *out_diagram_id )
219 : {
220 0 : U8_TRACE_BEGIN();
221 0 : assert ( NULL != out_diagram_id );
222 :
223 : u8_error_t c_result;
224 :
225 : ctrl_diagram_controller_t *diag_control;
226 0 : diag_control = ctrl_controller_get_diagram_control_ptr ( (*this_).controller );
227 :
228 : const char *const new_name
229 0 : = gui_sketch_object_creator_private_propose_diagram_name( this_ );
230 :
231 : /* create the diagram */
232 : const u8_error_t d_err
233 0 : = data_diagram_init_new( &((*this_).private_temp_diagram),
234 : parent_diagram_id,
235 : DATA_DIAGRAM_TYPE_UML_COMPONENT_DIAGRAM,
236 : "",
237 : new_name,
238 : "",
239 : list_order,
240 : DATA_DIAGRAM_FLAG_NONE
241 : );
242 0 : if ( d_err != U8_ERROR_NONE )
243 : {
244 0 : U8_LOG_ERROR_HEX("data_diagram_init_new failed in gui_sketch_object_creator_create_diagram:",d_err);
245 : }
246 :
247 0 : c_result = ctrl_diagram_controller_create_diagram( diag_control,
248 0 : &((*this_).private_temp_diagram),
249 : CTRL_UNDO_REDO_ACTION_BOUNDARY_START_NEW,
250 : out_diagram_id
251 : );
252 0 : if ( U8_ERROR_READ_ONLY_DB == c_result )
253 : {
254 : /* notify read-only warning to user */
255 0 : gui_simple_message_to_user_show_message( (*this_).message_to_user,
256 : GUI_SIMPLE_MESSAGE_TYPE_WARNING,
257 : GUI_SIMPLE_MESSAGE_CONTENT_DB_IS_READ_ONLY
258 : );
259 : }
260 :
261 : /* cleanup */
262 0 : if ( d_err == U8_ERROR_NONE )
263 : {
264 0 : data_diagram_destroy ( &((*this_).private_temp_diagram) );
265 : }
266 :
267 0 : U8_TRACE_END_ERR( c_result );
268 0 : return c_result;
269 : }
270 :
271 0 : u8_error_t gui_sketch_object_creator_create_relationship ( gui_sketch_object_creator_t *this_,
272 : data_diagram_type_t diag_type,
273 : data_row_id_t from_classifier_id,
274 : data_row_id_t from_feature_id,
275 : data_row_id_t to_classifier_id,
276 : data_row_id_t to_feature_id,
277 : int32_t list_order,
278 : data_row_id_t *out_relationship_id )
279 : {
280 0 : U8_TRACE_BEGIN();
281 0 : assert ( NULL != out_relationship_id );
282 0 : assert ( DATA_ROW_ID_VOID != from_classifier_id );
283 0 : assert ( DATA_ROW_ID_VOID != to_classifier_id );
284 :
285 : u8_error_t c_result;
286 :
287 : /* get classifier controller */
288 : ctrl_classifier_controller_t *classifier_control;
289 0 : classifier_control = ctrl_controller_get_classifier_control_ptr( (*this_).controller );
290 :
291 : /* propose a type for the relationship */
292 0 : data_relationship_type_t new_rel_type = DATA_RELATIONSHIP_TYPE_UML_DEPENDENCY;
293 : {
294 : /* get type of from_classifier */
295 0 : data_classifier_type_t from_class_type = DATA_CLASSIFIER_TYPE_CLASS;
296 : {
297 : const u8_error_t clsfy_err
298 0 : = data_database_reader_get_classifier_by_id( (*this_).db_reader,
299 : from_classifier_id,
300 : &((*this_).private_temp_classifier)
301 : );
302 0 : if ( U8_ERROR_NONE == clsfy_err )
303 : {
304 0 : from_class_type = data_classifier_get_main_type( &((*this_).private_temp_classifier) );
305 0 : data_classifier_destroy ( &((*this_).private_temp_classifier) );
306 : }
307 : else
308 : {
309 0 : U8_LOG_ERROR_INT( "gui_sketch_object_creator_create_relationship cannot find classifier:", from_classifier_id );
310 : }
311 : }
312 :
313 : /* get type of from_feature */
314 0 : data_feature_type_t from_feature_type = DATA_FEATURE_TYPE_VOID;
315 0 : if ( from_feature_id != DATA_ROW_ID_VOID )
316 : {
317 : const u8_error_t feat_err
318 0 : = data_database_reader_get_feature_by_id( (*this_).db_reader,
319 : from_feature_id,
320 : &((*this_).private_temp_feature)
321 : );
322 0 : if ( U8_ERROR_NONE == feat_err )
323 : {
324 0 : from_feature_type = data_feature_get_main_type( &((*this_).private_temp_feature) );
325 0 : data_feature_destroy ( &((*this_).private_temp_feature) );
326 : }
327 : else
328 : {
329 0 : U8_LOG_ERROR_INT( "gui_sketch_object_creator_create_relationship cannot find feature:", from_feature_id );
330 : }
331 : }
332 0 : new_rel_type = gui_sketch_defaults_get_relationship_type( &((*this_).defaults), from_class_type, from_feature_type );
333 : }
334 :
335 : /* define relationship struct */
336 : const u8_error_t d_err
337 0 : = data_relationship_init_new( &((*this_).private_temp_relationship),
338 : from_classifier_id,
339 : from_feature_id,
340 : to_classifier_id,
341 : to_feature_id,
342 : new_rel_type,
343 : "", /* =stereotype */
344 : "", /* =name */
345 : "", /* =description */
346 : list_order
347 : );
348 0 : if ( d_err != U8_ERROR_NONE )
349 : {
350 0 : U8_LOG_ERROR_HEX("data_relationship_init failed in gui_sketch_object_creator_create_relationship:",d_err);
351 : }
352 :
353 : /* check preconditions */
354 0 : const bool is_scenario = data_rules_diagram_is_scenario ( &((*this_).data_rules), diag_type )
355 0 : && (( from_feature_id != DATA_ROW_ID_VOID )||( to_feature_id != DATA_ROW_ID_VOID ));
356 0 : const bool diagram_ok = is_scenario
357 0 : ? data_rules_diagram_shows_scenario_relationships ( &((*this_).data_rules), diag_type )
358 0 : : data_rules_diagram_shows_uncond_relationships ( &((*this_).data_rules), diag_type );
359 :
360 0 : if ( diagram_ok ) {
361 : /* create relationship */
362 0 : c_result = ctrl_classifier_controller_create_relationship( classifier_control,
363 0 : &((*this_).private_temp_relationship),
364 : CTRL_UNDO_REDO_ACTION_BOUNDARY_START_NEW,
365 : out_relationship_id
366 : );
367 0 : if ( U8_ERROR_READ_ONLY_DB == c_result )
368 : {
369 : /* notify read-only warning to user */
370 0 : gui_simple_message_to_user_show_message( (*this_).message_to_user,
371 : GUI_SIMPLE_MESSAGE_TYPE_WARNING,
372 : GUI_SIMPLE_MESSAGE_CONTENT_DB_IS_READ_ONLY
373 : );
374 : }
375 : }
376 : else
377 : {
378 : /* notify error to user */
379 0 : gui_simple_message_to_user_show_message( (*this_).message_to_user,
380 : GUI_SIMPLE_MESSAGE_TYPE_ERROR,
381 : GUI_SIMPLE_MESSAGE_CONTENT_NO_RELATIONSHIPS
382 : );
383 0 : c_result = U8_ERROR_DIAGRAM_HIDES_RELATIONSHIPS;
384 : }
385 :
386 : /* cleanup */
387 0 : data_relationship_destroy( &((*this_).private_temp_relationship) );
388 :
389 0 : U8_TRACE_END_ERR( c_result );
390 0 : return c_result;
391 : }
392 :
393 0 : u8_error_t gui_sketch_object_creator_create_feature ( gui_sketch_object_creator_t *this_,
394 : data_diagram_type_t diag_type,
395 : data_row_id_t parent_classifier_id,
396 : int32_t std_list_order,
397 : int32_t port_list_order,
398 : data_row_id_t *out_feature_id )
399 : {
400 0 : U8_TRACE_BEGIN();
401 0 : assert ( NULL != out_feature_id );
402 0 : assert ( DATA_ROW_ID_VOID != parent_classifier_id );
403 :
404 : u8_error_t c_result;
405 :
406 : /* get classifier controller */
407 : ctrl_classifier_controller_t *classifier_control;
408 0 : classifier_control = ctrl_controller_get_classifier_control_ptr( (*this_).controller );
409 :
410 : /* get type of parent classifier */
411 0 : data_classifier_type_t parent_class_type = DATA_CLASSIFIER_TYPE_CLASS;
412 : {
413 : const u8_error_t clsfy_err
414 0 : = data_database_reader_get_classifier_by_id( (*this_).db_reader,
415 : parent_classifier_id,
416 : &((*this_).private_temp_classifier)
417 : );
418 0 : if ( U8_ERROR_NONE == clsfy_err )
419 : {
420 0 : parent_class_type = data_classifier_get_main_type( &((*this_).private_temp_classifier) );
421 0 : data_classifier_destroy( &((*this_).private_temp_classifier) );
422 : }
423 : else
424 : {
425 0 : U8_LOG_ERROR_INT( "gui_sketch_object_creator_create_feature cannot find classifier:", parent_classifier_id );
426 : }
427 : }
428 :
429 : /* propose a type for the feature */
430 : data_feature_type_t new_feature_type;
431 0 : new_feature_type = gui_sketch_defaults_get_feature_type( &((*this_).defaults), parent_class_type );
432 :
433 : /* select the right list_order */
434 : int32_t list_order;
435 0 : if ( ( DATA_FEATURE_TYPE_PROVIDED_INTERFACE == new_feature_type )
436 0 : || ( DATA_FEATURE_TYPE_REQUIRED_INTERFACE == new_feature_type )
437 0 : || ( DATA_FEATURE_TYPE_PORT == new_feature_type )
438 0 : || ( DATA_FEATURE_TYPE_IN_PORT_PIN == new_feature_type )
439 0 : || ( DATA_FEATURE_TYPE_OUT_PORT_PIN == new_feature_type )
440 0 : || ( DATA_FEATURE_TYPE_ENTRY == new_feature_type )
441 0 : || ( DATA_FEATURE_TYPE_EXIT == new_feature_type ) )
442 : {
443 0 : list_order = port_list_order;
444 : }
445 : else /* DATA_FEATURE_TYPE_PROPERTY or DATA_FEATURE_TYPE_OPERATION or DATA_FEATURE_TYPE_TAGGED_VALUE */
446 : {
447 0 : list_order = std_list_order;
448 : }
449 :
450 : /* find a good default name */
451 : const char *const full_new_name
452 0 : = gui_sketch_object_creator_private_propose_feature_name( this_, new_feature_type );
453 :
454 : /* define feature struct */
455 : const u8_error_t data_err
456 0 : = data_feature_init_new( &((*this_).private_temp_feature),
457 : new_feature_type,
458 : parent_classifier_id,
459 : full_new_name,
460 : "", /* type/value */
461 : "",
462 : list_order
463 : );
464 0 : if ( data_err != U8_ERROR_NONE )
465 : {
466 0 : U8_LOG_ERROR_HEX("data_feature_init failed in gui_sketch_object_creator_create_feature:",data_err);
467 : }
468 :
469 : /* check preconditions */
470 0 : const bool classifier_ok = data_rules_classifier_has_uncond_features ( &((*this_).data_rules), parent_class_type );
471 0 : const bool is_scenario = data_rules_feature_is_scenario_cond ( &((*this_).data_rules), new_feature_type );
472 0 : assert ( ! is_scenario ); /* lifelines should not be created by this function */
473 0 : const bool diagram_ok = is_scenario
474 0 : ? data_rules_diagram_shows_scenario_features ( &((*this_).data_rules), diag_type )
475 0 : : data_rules_diagram_shows_uncond_features ( &((*this_).data_rules), diag_type );
476 :
477 0 : if ( diagram_ok && classifier_ok )
478 : {
479 : /* create feature */
480 0 : c_result = ctrl_classifier_controller_create_feature( classifier_control,
481 0 : &((*this_).private_temp_feature),
482 : CTRL_UNDO_REDO_ACTION_BOUNDARY_START_NEW,
483 : out_feature_id
484 : );
485 0 : if ( U8_ERROR_READ_ONLY_DB == c_result )
486 : {
487 : /* notify read-only warning to user */
488 0 : gui_simple_message_to_user_show_message( (*this_).message_to_user,
489 : GUI_SIMPLE_MESSAGE_TYPE_WARNING,
490 : GUI_SIMPLE_MESSAGE_CONTENT_DB_IS_READ_ONLY
491 : );
492 : }
493 : }
494 0 : else if ( ! classifier_ok )
495 : {
496 : /* notify error to user */
497 0 : gui_simple_message_to_user_show_message( (*this_).message_to_user,
498 : GUI_SIMPLE_MESSAGE_TYPE_ERROR,
499 : GUI_SIMPLE_MESSAGE_CONTENT_FEATURELESS_CLASSIFIER
500 : );
501 0 : c_result = U8_ERROR_CLASSIFIER_REFUSES_FEATURE;
502 : }
503 : else
504 : {
505 : /* notify error to user */
506 0 : gui_simple_message_to_user_show_message( (*this_).message_to_user,
507 : GUI_SIMPLE_MESSAGE_TYPE_ERROR,
508 : GUI_SIMPLE_MESSAGE_CONTENT_NO_FEATURES
509 : );
510 0 : c_result = U8_ERROR_DIAGRAM_HIDES_FEATURES;
511 : }
512 :
513 : /* cleanup */
514 0 : data_feature_destroy( &((*this_).private_temp_feature) );
515 :
516 0 : U8_TRACE_END_ERR( c_result );
517 0 : return c_result;
518 : }
519 :
520 0 : const char* gui_sketch_object_creator_private_propose_diagram_name( gui_sketch_object_creator_t *this_ )
521 : {
522 : static int cycle_names = 0;
523 : static const char *const (NAMES[8])
524 : = {"New Overview","New Context","New Structure","New Deployment","New Lifecycle","New Errors","New Use Cases","New Sequence"};
525 :
526 0 : cycle_names ++;
527 :
528 0 : return NAMES[cycle_names&0x07];
529 : }
530 :
531 0 : const char* gui_sketch_object_creator_private_propose_classifier_name( gui_sketch_object_creator_t *this_, data_classifier_type_t c_type )
532 : {
533 0 : const char* result = "";
534 :
535 : static int cycle_names = 0;
536 : static const char *const (BLOCK_NAMES[8])
537 : = {"New DRAM","New SoC","New NAND","New NOR","New PMIC","New Watchdog","New CPU","New SRAM"};
538 : static const char *(REQUIREMENT_NAMES[8])
539 : = {"New Reaction Time","New Startup Time","New Latency","New Resource Consumption","New Update","New Fault Tolerance","New Availability","New Hardware Abstraction"};
540 : static const char *const (ACTOR_NAMES[8])
541 : = {"New Customer","New Database","New Service/Maintenance","New Operator","New Backend/Server","New Authorities","New Hacker","New Peer/Client"};
542 : static const char *const (USECASE_NAMES[8])
543 : = {"New Get Status","New Perform Transaction","New SW Update","New Pay Order","New Deliver","New Debug","New Check Eventlog","New Manage Rights"};
544 : static const char *const (BOUNDARIES_NAMES[8])
545 : = {"New Controller SW","New Machine","New Backend","New Virtual Machine","New Security Module","New Terminal","New Smart Device","New PC"};
546 : static const char *const (ACTIVITY_NAMES[8])
547 : = {"New Startup","New SW Update","New Background Scan","New Sleep","New User Input","New Normal Operation","New Error Reporting","New Idle"};
548 : static const char *const (STATE_NAMES[8])
549 : = {"New Off","New Starting","New On","New Debugging","New Wait","New Shutdown","New Send","New Receive"};
550 : static const char *const (DIAGREF_NAMES[8])
551 : = {"New Startup","New Data Upload","New Data Download","New Shutdown","New Suspend and Resume","New Background Activities","New Error Notification","New SW Update"};
552 : static const char *const (COMPONENT_NAMES[8])
553 : = {"New Persistence","New ErrorLogger","New UserInterface","New PeripheralControl","New Monitor","New ServiceDiscovery","New LifecycleManager","New Controller"};
554 : static const char *const (ARTIFACT_NAMES[8])
555 : = {"New Firmware","New Code","New Data","New Settings","New Log","New ErrorReport","New RuleSet","New Inventory"};
556 : static const char *const (IF_NAMES[8])
557 : = {"New Authentication_IF","New Log_IF","New TraceChannel_IF","New Update_IF","New DataSync_IF","New DataLink_IF","New AliveSignal_IF","New PowerControl_IF"};
558 : static const char *const (CLASS_NAMES[8])
559 : = {"New Serializer","New Deserializer","New CompressionAlg","New Transformer","New Wrapper","New EventLoop","New RingBuffer","New Multiplexer"};
560 : static const char *const (PACKAGE_NAMES[8])
561 : = {"New Drivers","New Platform Services","New User Applications","New Utilities","New Debug Tools","New Authentication and Authorization","New Controller","New Maintenance Tools"};
562 : static const char *const (NOTE_NAMES[8])
563 : = {"New Note","New Comment","New Hint","New Todo","New Remark","New Question","New Rationale","New Proposal"};
564 : static const char *const (STEREOTYPE_NAMES[8])
565 : = {"New transient","New persistent","New 3rd-party","New entity","New database","New decision","New testcase","New copy-of"};
566 :
567 0 : cycle_names ++;
568 :
569 0 : switch ( c_type )
570 : {
571 0 : case DATA_CLASSIFIER_TYPE_BLOCK:
572 : case DATA_CLASSIFIER_TYPE_CONSTRAINT_BLOCK:
573 : {
574 0 : result = BLOCK_NAMES[cycle_names&0x07];
575 : }
576 0 : break;
577 :
578 0 : case DATA_CLASSIFIER_TYPE_REQUIREMENT:
579 : {
580 0 : result = REQUIREMENT_NAMES[cycle_names&0x07];
581 : }
582 0 : break;
583 :
584 0 : case DATA_CLASSIFIER_TYPE_ACTOR:
585 : {
586 0 : result = ACTOR_NAMES[cycle_names&0x07];
587 : }
588 0 : break;
589 :
590 0 : case DATA_CLASSIFIER_TYPE_USE_CASE:
591 : {
592 0 : result = USECASE_NAMES[cycle_names&0x07];
593 : }
594 0 : break;
595 :
596 0 : case DATA_CLASSIFIER_TYPE_SUBSYSTEM:
597 : {
598 0 : result = BOUNDARIES_NAMES[cycle_names&0x07];
599 : }
600 0 : break;
601 :
602 0 : case DATA_CLASSIFIER_TYPE_ACTIVITY:
603 : case DATA_CLASSIFIER_TYPE_DYN_INTERRUPTABLE_REGION:
604 : case DATA_CLASSIFIER_TYPE_DYN_INITIAL_NODE:
605 : case DATA_CLASSIFIER_TYPE_DYN_FINAL_NODE:
606 : case DATA_CLASSIFIER_TYPE_DYN_FORK_NODE:
607 : case DATA_CLASSIFIER_TYPE_DYN_JOIN_NODE:
608 : case DATA_CLASSIFIER_TYPE_DYN_DECISION_NODE:
609 : case DATA_CLASSIFIER_TYPE_DYN_ACCEPT_EVENT :
610 : case DATA_CLASSIFIER_TYPE_DYN_ACCEPT_TIME_EVENT:
611 : case DATA_CLASSIFIER_TYPE_DYN_SEND_SIGNAL:
612 : {
613 0 : result = ACTIVITY_NAMES[cycle_names&0x07];
614 : }
615 0 : break;
616 :
617 0 : case DATA_CLASSIFIER_TYPE_STATE:
618 : case DATA_CLASSIFIER_TYPE_DYN_SHALLOW_HISTORY:
619 : case DATA_CLASSIFIER_TYPE_DYN_DEEP_HISTORY:
620 : {
621 0 : result = STATE_NAMES[cycle_names&0x07];
622 : }
623 0 : break;
624 :
625 0 : case DATA_CLASSIFIER_TYPE_DIAGRAM_REFERENCE:
626 : {
627 0 : result = DIAGREF_NAMES[cycle_names&0x07];
628 : }
629 0 : break;
630 :
631 0 : case DATA_CLASSIFIER_TYPE_NODE:
632 : {
633 0 : result = BLOCK_NAMES[cycle_names&0x07];
634 : }
635 0 : break;
636 :
637 0 : case DATA_CLASSIFIER_TYPE_COMPONENT: /* and */
638 : {
639 0 : result = COMPONENT_NAMES[cycle_names&0x07];
640 : }
641 0 : break;
642 :
643 0 : case DATA_CLASSIFIER_TYPE_PART:
644 : {
645 0 : result = COMPONENT_NAMES[cycle_names&0x07];
646 : }
647 0 : break;
648 :
649 0 : case DATA_CLASSIFIER_TYPE_ARTIFACT:
650 : {
651 0 : result = ARTIFACT_NAMES[cycle_names&0x07];
652 : }
653 0 : break;
654 :
655 0 : case DATA_CLASSIFIER_TYPE_INTERFACE: /* and */
656 : {
657 0 : result = IF_NAMES[cycle_names&0x07];
658 : }
659 0 : break;
660 :
661 0 : case DATA_CLASSIFIER_TYPE_CLASS: /* and */
662 : {
663 0 : result = CLASS_NAMES[cycle_names&0x07];
664 : }
665 0 : break;
666 :
667 0 : case DATA_CLASSIFIER_TYPE_OBJECT: /* and */
668 : {
669 0 : result = CLASS_NAMES[cycle_names&0x07];
670 : }
671 0 : break;
672 :
673 0 : case DATA_CLASSIFIER_TYPE_PACKAGE:
674 : {
675 0 : result = PACKAGE_NAMES[cycle_names&0x07];
676 : }
677 0 : break;
678 :
679 0 : case DATA_CLASSIFIER_TYPE_COMMENT:
680 : {
681 0 : result = NOTE_NAMES[cycle_names&0x07];
682 : }
683 0 : break;
684 :
685 0 : case DATA_CLASSIFIER_TYPE_STEREOTYPE:
686 : case DATA_CLASSIFIER_TYPE_IMAGE:
687 : {
688 0 : result = STEREOTYPE_NAMES[cycle_names&0x07];
689 : }
690 0 : break;
691 :
692 0 : default:
693 : {
694 0 : U8_LOG_ERROR("data_classifier_type_t out of range in gui_sketch_object_creator_private_propose_classifier_name");
695 0 : result = "New";
696 : }
697 0 : break;
698 : }
699 :
700 0 : return result;
701 : }
702 :
703 0 : const char* gui_sketch_object_creator_private_propose_feature_name( gui_sketch_object_creator_t *this_, data_feature_type_t f_type )
704 : {
705 0 : const char* result = "";
706 :
707 : static int cycle_names = 0;
708 : static const char *const (PROPERTY_NAMES[8])
709 : = {"new_state","new_run_mode","new_error_code","new_color","new_name","new_type","new_size","new_weight"};
710 : static const char *const (OPERATION_NAMES[8])
711 : = {"new_start","new_stop","new_pause","new_resume","new_get_state","new_handle_event","new_set_color","new_is_valid"};
712 : static const char *const (PORT_NAMES[8])
713 : = {"new_in_a","new_in_b","new_in_c","new_out_a","new_out_b","new_out_c","new_out_error","new_in_reset"};
714 : static const char *const (IO_PORT_NAMES[8])
715 : = {"new_order","new_item","new_error","new_report","new_audio_file","new_video_file","new_plan","new_status"};
716 : static const char *const (IF_NAMES[8])
717 : = {"New Auth_IF","New Log_IF","New Trace_IF","New Update_IF","New Sync_IF","New Link_IF","New Alive_IF","New Power_IF"};
718 : static const char *const (ENTRY_NAMES[8])
719 : = {"new_again","new_first_time","new_error_case","new_std_entry","new_retries_exceeded","new_debug","new_rookie_mode","new_last_try"};
720 : static const char *const (EXIT_NAMES[8])
721 : = {"new_abort","new_std_exit","new_precondition_failed","new_warning","new_error","new_retry","new_ok","new_repair_request"};
722 :
723 0 : cycle_names ++;
724 :
725 0 : switch ( f_type )
726 : {
727 0 : case DATA_FEATURE_TYPE_PROPERTY:
728 : case DATA_FEATURE_TYPE_TAGGED_VALUE:
729 : {
730 0 : result = PROPERTY_NAMES[cycle_names&0x07];
731 : }
732 0 : break;
733 :
734 0 : case DATA_FEATURE_TYPE_OPERATION:
735 : {
736 0 : result = OPERATION_NAMES[cycle_names&0x07];
737 : }
738 0 : break;
739 :
740 0 : case DATA_FEATURE_TYPE_PORT:
741 : {
742 0 : result = PORT_NAMES[cycle_names&0x07];
743 : }
744 0 : break;
745 :
746 0 : case DATA_FEATURE_TYPE_LIFELINE:
747 : {
748 0 : result = "";
749 : }
750 0 : break;
751 :
752 0 : case DATA_FEATURE_TYPE_PROVIDED_INTERFACE:
753 : {
754 0 : result = IF_NAMES[cycle_names&0x07];
755 : }
756 0 : break;
757 :
758 0 : case DATA_FEATURE_TYPE_REQUIRED_INTERFACE:
759 : {
760 0 : result = IF_NAMES[cycle_names&0x07];
761 : }
762 0 : break;
763 :
764 0 : case DATA_FEATURE_TYPE_IN_PORT_PIN:
765 : case DATA_FEATURE_TYPE_OUT_PORT_PIN:
766 : {
767 0 : result = IO_PORT_NAMES[cycle_names&0x07];
768 : }
769 0 : break;
770 :
771 0 : case DATA_FEATURE_TYPE_ENTRY:
772 : {
773 0 : result = ENTRY_NAMES[cycle_names&0x07];
774 : }
775 0 : break;
776 :
777 0 : case DATA_FEATURE_TYPE_EXIT:
778 : {
779 0 : result = EXIT_NAMES[cycle_names&0x07];
780 : }
781 0 : break;
782 :
783 0 : default:
784 : {
785 0 : U8_LOG_ERROR("data_feature_type_t out of range in gui_sketch_object_creator_private_propose_feature_name");
786 0 : result = "new";
787 : }
788 0 : break;
789 : }
790 :
791 0 : return result;
792 : }
793 :
794 :
795 : /*
796 : Copyright 2017-2024 Andreas Warnke
797 :
798 : Licensed under the Apache License, Version 2.0 (the "License");
799 : you may not use this file except in compliance with the License.
800 : You may obtain a copy of the License at
801 :
802 : http://www.apache.org/licenses/LICENSE-2.0
803 :
804 : Unless required by applicable law or agreed to in writing, software
805 : distributed under the License is distributed on an "AS IS" BASIS,
806 : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
807 : See the License for the specific language governing permissions and
808 : limitations under the License.
809 : */
|