Line data Source code
1 : /* File: ctrl_undo_redo_entry.inl; Copyright and License: see below */ 2 : 3 : #include "data_feature_type.h" 4 : #include <assert.h> 5 : 6 680 : static inline void ctrl_undo_redo_entry_init_empty ( ctrl_undo_redo_entry_t *this_ ) 7 : { 8 680 : (*this_).action_type = CTRL_UNDO_REDO_ENTRY_TYPE_BOUNDARY; 9 680 : } 10 : 11 90 : static inline void ctrl_undo_redo_entry_init ( ctrl_undo_redo_entry_t *this_, ctrl_undo_redo_entry_type_t action_type ) 12 : { 13 90 : (*this_).action_type = action_type; 14 90 : } 15 : 16 682 : static inline void ctrl_undo_redo_entry_reinit ( ctrl_undo_redo_entry_t *this_, ctrl_undo_redo_entry_type_t action_type ) 17 : { 18 682 : (*this_).action_type = action_type; 19 682 : } 20 : 21 728 : static inline void ctrl_undo_redo_entry_destroy ( ctrl_undo_redo_entry_t *this_ ) 22 : { 23 728 : } 24 : 25 36315 : static inline ctrl_undo_redo_entry_type_t ctrl_undo_redo_entry_get_action_type ( const ctrl_undo_redo_entry_t *this_ ) 26 : { 27 36315 : return (*this_).action_type; 28 : } 29 : 30 11 : static inline data_classifier_t *ctrl_undo_redo_entry_get_classifier_before_action_ptr ( ctrl_undo_redo_entry_t *this_ ) 31 : { 32 11 : return &((*this_).data_before_action.classifier); 33 : } 34 : 35 13 : static inline data_diagram_t *ctrl_undo_redo_entry_get_diagram_before_action_ptr ( ctrl_undo_redo_entry_t *this_ ) 36 : { 37 13 : return &((*this_).data_before_action.diagram); 38 : } 39 : 40 30 : static inline data_diagramelement_t *ctrl_undo_redo_entry_get_diagramelement_before_action_ptr ( ctrl_undo_redo_entry_t *this_ ) 41 : { 42 30 : return &((*this_).data_before_action.diagramelement); 43 : } 44 : 45 14 : static inline data_relationship_t *ctrl_undo_redo_entry_get_relationship_before_action_ptr ( ctrl_undo_redo_entry_t *this_ ) 46 : { 47 14 : return &((*this_).data_before_action.relationship); 48 : } 49 : 50 21 : static inline data_feature_t *ctrl_undo_redo_entry_get_feature_before_action_ptr ( ctrl_undo_redo_entry_t *this_ ) 51 : { 52 21 : return &((*this_).data_before_action.feature); 53 : } 54 : 55 36 : static inline data_classifier_t *ctrl_undo_redo_entry_get_classifier_after_action_ptr ( ctrl_undo_redo_entry_t *this_ ) 56 : { 57 36 : return &((*this_).data_after_action.classifier); 58 : } 59 : 60 307 : static inline data_diagram_t *ctrl_undo_redo_entry_get_diagram_after_action_ptr ( ctrl_undo_redo_entry_t *this_ ) 61 : { 62 307 : return &((*this_).data_after_action.diagram); 63 : } 64 : 65 59 : static inline data_diagramelement_t *ctrl_undo_redo_entry_get_diagramelement_after_action_ptr ( ctrl_undo_redo_entry_t *this_ ) 66 : { 67 59 : return &((*this_).data_after_action.diagramelement); 68 : } 69 : 70 22 : static inline data_relationship_t *ctrl_undo_redo_entry_get_relationship_after_action_ptr ( ctrl_undo_redo_entry_t *this_ ) 71 : { 72 22 : return &((*this_).data_after_action.relationship); 73 : } 74 : 75 43 : static inline data_feature_t *ctrl_undo_redo_entry_get_feature_after_action_ptr ( ctrl_undo_redo_entry_t *this_ ) 76 : { 77 43 : return &((*this_).data_after_action.feature); 78 : } 79 : 80 185 : static inline void ctrl_undo_redo_entry_to_statistics ( const ctrl_undo_redo_entry_t *this_, bool undo, bool err, data_stat_t *io_stat ) 81 : { 82 185 : assert( NULL != io_stat ); 83 : 84 185 : data_stat_table_t table = DATA_STAT_TABLE_LIFELINE; 85 185 : data_stat_series_t series = DATA_STAT_SERIES_ERROR; 86 185 : switch( (*this_).action_type ) 87 : { 88 1 : case CTRL_UNDO_REDO_ENTRY_TYPE_DELETE_DIAGRAM: 89 : { 90 1 : table = DATA_STAT_TABLE_DIAGRAM; 91 1 : series = undo ? DATA_STAT_SERIES_CREATED : DATA_STAT_SERIES_DELETED; 92 : } 93 1 : break; 94 : 95 9 : case CTRL_UNDO_REDO_ENTRY_TYPE_UPDATE_DIAGRAM: 96 : { 97 9 : table = DATA_STAT_TABLE_DIAGRAM; 98 9 : series = DATA_STAT_SERIES_MODIFIED; 99 : } 100 9 : break; 101 : 102 134 : case CTRL_UNDO_REDO_ENTRY_TYPE_CREATE_DIAGRAM: 103 : { 104 134 : table = DATA_STAT_TABLE_DIAGRAM; 105 134 : series = undo ? DATA_STAT_SERIES_DELETED : DATA_STAT_SERIES_CREATED; 106 : } 107 134 : break; 108 : 109 1 : case CTRL_UNDO_REDO_ENTRY_TYPE_DELETE_DIAGRAMELEMENT: 110 : { 111 1 : table = DATA_STAT_TABLE_DIAGRAMELEMENT; 112 1 : series = undo ? DATA_STAT_SERIES_CREATED : DATA_STAT_SERIES_DELETED; 113 : } 114 1 : break; 115 : 116 8 : case CTRL_UNDO_REDO_ENTRY_TYPE_UPDATE_DIAGRAMELEMENT: 117 : { 118 8 : table = DATA_STAT_TABLE_DIAGRAMELEMENT; 119 8 : series = DATA_STAT_SERIES_MODIFIED; 120 : } 121 8 : break; 122 : 123 2 : case CTRL_UNDO_REDO_ENTRY_TYPE_CREATE_DIAGRAMELEMENT: 124 : { 125 2 : table = DATA_STAT_TABLE_DIAGRAMELEMENT; 126 2 : series = undo ? DATA_STAT_SERIES_DELETED : DATA_STAT_SERIES_CREATED; 127 : } 128 2 : break; 129 : 130 2 : case CTRL_UNDO_REDO_ENTRY_TYPE_DELETE_CLASSIFIER: 131 : { 132 2 : table = DATA_STAT_TABLE_CLASSIFIER; 133 2 : series = undo ? DATA_STAT_SERIES_CREATED : DATA_STAT_SERIES_DELETED; 134 : } 135 2 : break; 136 : 137 2 : case CTRL_UNDO_REDO_ENTRY_TYPE_UPDATE_CLASSIFIER: 138 : { 139 2 : table = DATA_STAT_TABLE_CLASSIFIER; 140 2 : series = DATA_STAT_SERIES_MODIFIED; 141 : } 142 2 : break; 143 : 144 2 : case CTRL_UNDO_REDO_ENTRY_TYPE_CREATE_CLASSIFIER: 145 : { 146 2 : table = DATA_STAT_TABLE_CLASSIFIER; 147 2 : series = undo ? DATA_STAT_SERIES_DELETED : DATA_STAT_SERIES_CREATED; 148 : } 149 2 : break; 150 : 151 7 : case CTRL_UNDO_REDO_ENTRY_TYPE_DELETE_FEATURE: 152 : { 153 7 : const data_feature_t *const old_feat = &((*this_).data_before_action.feature); 154 7 : const data_feature_type_t feat_type = data_feature_get_main_type( old_feat ); 155 7 : table = (feat_type == DATA_FEATURE_TYPE_LIFELINE) ? DATA_STAT_TABLE_LIFELINE : DATA_STAT_TABLE_FEATURE; 156 7 : series = undo ? DATA_STAT_SERIES_CREATED : DATA_STAT_SERIES_DELETED; 157 : } 158 7 : break; 159 : 160 4 : case CTRL_UNDO_REDO_ENTRY_TYPE_UPDATE_FEATURE: 161 : { 162 4 : const data_feature_t *const old_feat = &((*this_).data_before_action.feature); 163 4 : const data_feature_type_t feat_type = data_feature_get_main_type( old_feat ); 164 4 : table = (feat_type == DATA_FEATURE_TYPE_LIFELINE) ? DATA_STAT_TABLE_LIFELINE : DATA_STAT_TABLE_FEATURE; 165 4 : series = DATA_STAT_SERIES_MODIFIED; 166 : } 167 4 : break; 168 : 169 4 : case CTRL_UNDO_REDO_ENTRY_TYPE_CREATE_FEATURE: 170 : { 171 4 : const data_feature_t *const new_feat = &((*this_).data_after_action.feature); 172 4 : const data_feature_type_t feat_type = data_feature_get_main_type( new_feat ); 173 4 : table = (feat_type == DATA_FEATURE_TYPE_LIFELINE) ? DATA_STAT_TABLE_LIFELINE : DATA_STAT_TABLE_FEATURE; 174 4 : series = undo ? DATA_STAT_SERIES_DELETED : DATA_STAT_SERIES_CREATED; 175 : } 176 4 : break; 177 : 178 5 : case CTRL_UNDO_REDO_ENTRY_TYPE_DELETE_RELATIONSHIP: 179 : { 180 5 : table = DATA_STAT_TABLE_RELATIONSHIP; 181 5 : series = undo ? DATA_STAT_SERIES_CREATED : DATA_STAT_SERIES_DELETED; 182 : } 183 5 : break; 184 : 185 2 : case CTRL_UNDO_REDO_ENTRY_TYPE_UPDATE_RELATIONSHIP: 186 : { 187 2 : table = DATA_STAT_TABLE_RELATIONSHIP; 188 2 : series = DATA_STAT_SERIES_MODIFIED; 189 : } 190 2 : break; 191 : 192 2 : case CTRL_UNDO_REDO_ENTRY_TYPE_CREATE_RELATIONSHIP: 193 : { 194 2 : table = DATA_STAT_TABLE_RELATIONSHIP; 195 2 : series = undo ? DATA_STAT_SERIES_DELETED : DATA_STAT_SERIES_CREATED; 196 : } 197 2 : break; 198 : 199 0 : case CTRL_UNDO_REDO_ENTRY_TYPE_BOUNDARY: 200 : { 201 : /* nothing to count */ 202 : } 203 0 : break; 204 : 205 0 : default : 206 : { 207 : /* internal error, switch-case statement incomplete */ 208 0 : U8_LOG_ERROR("incomplete switch statement in ctrl_undo_redo_entry_to_statistics"); 209 : } 210 0 : break; 211 : } 212 : 213 185 : data_stat_inc_count ( io_stat, table, (err ? DATA_STAT_SERIES_ERROR : series) ); 214 185 : } 215 : 216 : 217 : /* 218 : Copyright 2016-2024 Andreas Warnke 219 : 220 : Licensed under the Apache License, Version 2.0 (the "License"); 221 : you may not use this file except in compliance with the License. 222 : You may obtain a copy of the License at 223 : 224 : http://www.apache.org/licenses/LICENSE-2.0 225 : 226 : Unless required by applicable law or agreed to in writing, software 227 : distributed under the License is distributed on an "AS IS" BASIS, 228 : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 229 : See the License for the specific language governing permissions and 230 : limitations under the License. 231 : */