| 1 | /* File: gui_sketch_object_creator.h; Copyright and License: see below */ |
| 2 | |
| 3 | #ifndef GUI_SKETCH_OBJECT_CREATOR_H |
| 4 | #define GUI_SKETCH_OBJECT_CREATOR_H |
| 5 | |
| 6 | /* public file for the doxygen documentation: */ |
| 7 | /*! \file |
| 8 | * \brief Creates new classifiers, diagrams, relationships and features |
| 9 | */ |
| 10 | |
| 11 | #include "gui_simple_message_to_user.h" |
| 12 | #include "gui_sketch_defaults.h" |
| 13 | #include "storage/data_database_reader.h" |
| 14 | #include "entity/data_diagram.h" |
| 15 | #include "entity/data_table.h" |
| 16 | #include "data_rules.h" |
| 17 | #include "ctrl_controller.h" |
| 18 | #include <stdbool.h> |
| 19 | #include <stdint.h> |
| 20 | |
| 21 | /*! |
| 22 | * \brief attributes of the sketch area widget |
| 23 | */ |
| 24 | struct gui_sketch_object_creator_struct { |
| 25 | data_database_reader_t *db_reader; /*!< pointer to external database reader */ |
| 26 | ctrl_controller_t *controller; /*!< pointer to external controller */ |
| 27 | gui_sketch_defaults_t defaults; /*!< own instance of uml and sysml model default types */ |
| 28 | data_rules_t data_rules; /*!< own instance of uml and sysml consistency rules */ |
| 29 | gui_simple_message_to_user_t *message_to_user; /*!< pointer to external gui_simple_message_to_user_t */ |
| 30 | |
| 31 | data_diagram_t private_temp_diagram; /*!< instance for temporary object data, exists here to avoid medium-sized objects on the stack */ |
| 32 | data_classifier_t private_temp_classifier; /*!< instance for temporary object data, exists here to avoid medium-sized objects on the stack */ |
| 33 | data_relationship_t private_temp_relationship; /*!< instance for temporary object data, exists here to avoid medium-sized objects on the stack */ |
| 34 | data_feature_t private_temp_feature; /*!< instance for temporary object data, exists here to avoid medium-sized objects on the stack */ |
| 35 | }; |
| 36 | |
| 37 | typedef struct gui_sketch_object_creator_struct gui_sketch_object_creator_t; |
| 38 | |
| 39 | /*! |
| 40 | * \brief initializes the gui_sketch_object_creator_t struct |
| 41 | * |
| 42 | * \param this_ pointer to own object attributes |
| 43 | * \param controller pointer to a controller object which can modify the database |
| 44 | * \param db_reader pointer to a database reader object |
| 45 | * \param message_to_user pointer to the message_to_user object to use |
| 46 | */ |
| 47 | void gui_sketch_object_creator_init ( gui_sketch_object_creator_t *this_, |
| 48 | ctrl_controller_t *controller, |
| 49 | data_database_reader_t *db_reader, |
| 50 | gui_simple_message_to_user_t *message_to_user |
| 51 | ); |
| 52 | |
| 53 | /*! |
| 54 | * \brief destroys the gui_sketch_object_creator_t struct |
| 55 | * |
| 56 | * \param this_ pointer to own object attributes |
| 57 | */ |
| 58 | void gui_sketch_object_creator_destroy ( gui_sketch_object_creator_t *this_ ); |
| 59 | |
| 60 | /*! |
| 61 | * \brief creates a new classifier |
| 62 | * |
| 63 | * \param this_ pointer to own object attributes |
| 64 | * \param diagram_id id of the diagram where the new classifier shall appear |
| 65 | * \param x_order x order where the new classifier shall be located |
| 66 | * \param y_order y order where the new classifier shall be located |
| 67 | * \param out_diagramelement_id row_id of the newly created diagramelement |
| 68 | * \param out_classifier_id row_id of the newly created classifier |
| 69 | * \return U8_ERROR_NONE in case of success, U8_ERROR_DUPLICATE_NAME in case of error |
| 70 | */ |
| 71 | u8_error_t gui_sketch_object_creator_create_classifier ( gui_sketch_object_creator_t *this_, |
| 72 | data_row_t diagram_id, |
| 73 | int32_t x_order, |
| 74 | int32_t y_order, |
| 75 | data_row_t *out_diagramelement_id, |
| 76 | data_row_t *out_classifier_id |
| 77 | ); |
| 78 | |
| 79 | /*! |
| 80 | * \brief creates a new classifier as child of another one |
| 81 | * |
| 82 | * \param this_ pointer to own object attributes |
| 83 | * \param diagram_id id of the diagram where the new classifier shall appear |
| 84 | * \param parent_classifier_id id of the parent classifier of the new classifier |
| 85 | * \param x_order x order where the new classifier shall be located |
| 86 | * \param y_order y order where the new classifier shall be located |
| 87 | * \param out_diagramelement_id row_id of the newly created diagramelement |
| 88 | * \param out_classifier_id row_id of the newly created classifier |
| 89 | * \param out_relationship_id row_id of the newly created relationship |
| 90 | * \return U8_ERROR_NONE in case of success, U8_ERROR_DUPLICATE_NAME in case of error |
| 91 | */ |
| 92 | u8_error_t gui_sketch_object_creator_create_classifier_as_child ( gui_sketch_object_creator_t *this_, |
| 93 | data_row_t diagram_id, |
| 94 | data_row_t parent_classifier_id, |
| 95 | int32_t x_order, |
| 96 | int32_t y_order, |
| 97 | data_row_t *out_diagramelement_id, |
| 98 | data_row_t *out_classifier_id, |
| 99 | data_row_t *out_relationship_id |
| 100 | ); |
| 101 | |
| 102 | /*! |
| 103 | * \brief creates a new diagram |
| 104 | * |
| 105 | * \param this_ pointer to own object attributes |
| 106 | * \param parent_diagram_id id of the parent diagram where the new diagram shall appear. DATA_ROW_VOID if a root diagram shall be created. |
| 107 | * \param list_order order of the new diagram |
| 108 | * \param out_diagram_id row_id of the newly created diagram |
| 109 | * \return U8_ERROR_NONE in case of success |
| 110 | */ |
| 111 | u8_error_t gui_sketch_object_creator_create_diagram ( gui_sketch_object_creator_t *this_, |
| 112 | data_row_t parent_diagram_id, |
| 113 | int32_t list_order, |
| 114 | data_row_t *out_diagram_id |
| 115 | ); |
| 116 | |
| 117 | /*! |
| 118 | * \brief creates a new relationship |
| 119 | * |
| 120 | * \param this_ pointer to own object attributes |
| 121 | * \param diag_type diagram type where the relationship was constructed and shall be visible |
| 122 | * \param from_classifier_id id of the classifier where the new relationship shall start from |
| 123 | * \param from_feature_id optional id of the feature where the new relationship shall start from; alternatively DATA_ROW_VOID |
| 124 | * \param to_classifier_id id of the classifier where the new relationship shall end at |
| 125 | * \param to_feature_id optional id of the feature where the new relationship shall end at; alternatively DATA_ROW_VOID |
| 126 | * \param list_order order where the new relationship shall be located |
| 127 | * \param out_relationship_id row_id of the newly created relationship |
| 128 | * \return U8_ERROR_NONE in case of success |
| 129 | */ |
| 130 | u8_error_t gui_sketch_object_creator_create_relationship ( gui_sketch_object_creator_t *this_, |
| 131 | data_diagram_type_t diag_type, |
| 132 | data_row_t from_classifier_id, |
| 133 | data_row_t from_feature_id, |
| 134 | data_row_t to_classifier_id, |
| 135 | data_row_t to_feature_id, |
| 136 | int32_t list_order, |
| 137 | data_row_t *out_relationship_id |
| 138 | ); |
| 139 | |
| 140 | /*! |
| 141 | * \brief creates a new feature |
| 142 | * |
| 143 | * \param this_ pointer to own object attributes |
| 144 | * \param diag_type diagram type where the relationship was constructed and shall be visible |
| 145 | * \param parent_classifier_id id of the parent classifier where the new feature shall appear |
| 146 | * \param std_list_order order where the new feature shall be located, if not a port |
| 147 | * \param port_list_order order where the new feature shall be located, if a port |
| 148 | * \param out_feature_id row_id of the newly created feature |
| 149 | * \return U8_ERROR_NONE in case of success, U8_ERROR_DUPLICATE_NAME in case of error |
| 150 | */ |
| 151 | u8_error_t gui_sketch_object_creator_create_feature ( gui_sketch_object_creator_t *this_, |
| 152 | data_diagram_type_t diag_type, |
| 153 | data_row_t parent_classifier_id, |
| 154 | int32_t std_list_order, |
| 155 | int32_t port_list_order, |
| 156 | data_row_t *out_feature_id |
| 157 | ); |
| 158 | |
| 159 | #endif /* GUI_SKETCH_OBJECT_CREATOR_H */ |
| 160 | |
| 161 | |
| 162 | /* |
| 163 | Copyright 2017-2026 Andreas Warnke |
| 164 | |
| 165 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 166 | you may not use this file except in compliance with the License. |
| 167 | You may obtain a copy of the License at |
| 168 | |
| 169 | http://www.apache.org/licenses/LICENSE-2.0 |
| 170 | |
| 171 | Unless required by applicable law or agreed to in writing, software |
| 172 | distributed under the License is distributed on an "AS IS" BASIS, |
| 173 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 174 | See the License for the specific language governing permissions and |
| 175 | limitations under the License. |
| 176 | */ |