LCOV - code coverage report
Current view: top level - ctrl/include - ctrl_undo_redo_entry.inl (source / functions) Coverage Total Hit
Test: crystal-facet-uml_v1.67.0_covts Lines: 97.4 % 189 184
Test Date: 2025-11-06 17:22:08 Functions: 100.0 % 31 31

            Line data    Source code
       1              : /* File: ctrl_undo_redo_entry.inl; Copyright and License: see below */
       2              : 
       3              : #include "entity/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 :     (*this_).data_before_action.boundary_revision = DATA_REVISION_VOID;
      10          680 :     (*this_).data_after_action.boundary_revision = DATA_REVISION_VOID;
      11          680 : }
      12              : 
      13          731 : static inline void ctrl_undo_redo_entry_destroy ( ctrl_undo_redo_entry_t *this_ )
      14              : {
      15          731 : }
      16              : 
      17              : /* ================================ BOUNDARY ================================ */
      18              : 
      19          434 : static inline void ctrl_undo_redo_entry_init_boundary ( ctrl_undo_redo_entry_t *this_, data_revision_t boundary_revision )
      20              : {
      21          434 :     (*this_).action_type = CTRL_UNDO_REDO_ENTRY_TYPE_BOUNDARY;
      22          434 :     (*this_).data_before_action.boundary_revision = DATA_REVISION_VOID;  /* unused */
      23          434 :     (*this_).data_after_action.boundary_revision = boundary_revision;
      24          434 : }
      25              : 
      26          155 : static inline data_revision_t ctrl_undo_redo_entry_get_boundary_revision ( const ctrl_undo_redo_entry_t *this_ )
      27              : {
      28          155 :     return (*this_).data_after_action.boundary_revision;
      29              : }
      30              : 
      31              : /* ================================ DIAGRAM ================================ */
      32              : 
      33          162 : static inline void ctrl_undo_redo_entry_init_create_diagram ( ctrl_undo_redo_entry_t *this_,
      34              :                                                               const data_diagram_t *data_after )
      35              : {
      36          162 :     (*this_).action_type = CTRL_UNDO_REDO_ENTRY_TYPE_CREATE_DIAGRAM;
      37          162 :     data_diagram_init_empty( &((*this_).data_before_action.diagram) );
      38          162 :     data_diagram_replace( &((*this_).data_after_action.diagram), data_after );
      39          162 : }
      40              : 
      41            9 : static inline void ctrl_undo_redo_entry_init_update_diagram ( ctrl_undo_redo_entry_t *this_,
      42              :                                                               const data_diagram_t *data_before,
      43              :                                                               const data_diagram_t *data_after )
      44              : {
      45            9 :     (*this_).action_type = CTRL_UNDO_REDO_ENTRY_TYPE_UPDATE_DIAGRAM;
      46            9 :     data_diagram_replace( &((*this_).data_before_action.diagram), data_before );
      47            9 :     data_diagram_replace( &((*this_).data_after_action.diagram), data_after );
      48            9 : }
      49              : 
      50            2 : static inline void ctrl_undo_redo_entry_init_delete_diagram ( ctrl_undo_redo_entry_t *this_,
      51              :                                                               const data_diagram_t *data_before )
      52              : {
      53            2 :     (*this_).action_type = CTRL_UNDO_REDO_ENTRY_TYPE_DELETE_DIAGRAM;
      54            2 :     data_diagram_replace( &((*this_).data_before_action.diagram), data_before );
      55            2 :     data_diagram_init_empty( &((*this_).data_after_action.diagram) );
      56            2 : }
      57              : 
      58          136 : static inline const data_diagram_t *ctrl_undo_redo_entry_get_diagram_after_action_const ( const ctrl_undo_redo_entry_t *this_ )
      59              : {
      60          136 :     return &((*this_).data_after_action.diagram);
      61              : }
      62              : 
      63            2 : static inline const data_diagram_t *ctrl_undo_redo_entry_get_diagram_before_action_const ( const ctrl_undo_redo_entry_t *this_ )
      64              : {
      65            2 :     return &((*this_).data_before_action.diagram);
      66              : }
      67              : 
      68              : /* ================================ DIAGRAMELEMENT ================================ */
      69              : 
      70           33 : static inline void ctrl_undo_redo_entry_init_create_diagramelement ( ctrl_undo_redo_entry_t *this_,
      71              :                                                                      const data_diagramelement_t *data_after )
      72              : {
      73           33 :     (*this_).action_type = CTRL_UNDO_REDO_ENTRY_TYPE_CREATE_DIAGRAMELEMENT;
      74           33 :     data_diagramelement_init_empty( &((*this_).data_before_action.diagramelement) );
      75           33 :     data_diagramelement_replace( &((*this_).data_after_action.diagramelement), data_after );
      76           33 : }
      77              : 
      78           22 : static inline void ctrl_undo_redo_entry_init_update_diagramelement ( ctrl_undo_redo_entry_t *this_,
      79              :                                                                      const data_diagramelement_t *data_before,
      80              :                                                                      const data_diagramelement_t *data_after )
      81              : {
      82           22 :     (*this_).action_type = CTRL_UNDO_REDO_ENTRY_TYPE_UPDATE_DIAGRAMELEMENT;
      83           22 :     data_diagramelement_replace( &((*this_).data_before_action.diagramelement), data_before );
      84           22 :     data_diagramelement_replace( &((*this_).data_after_action.diagramelement), data_after );
      85           22 : }
      86              : 
      87            5 : static inline void ctrl_undo_redo_entry_init_delete_diagramelement ( ctrl_undo_redo_entry_t *this_,
      88              :                                                                      const data_diagramelement_t *data_before )
      89              : {
      90            5 :     (*this_).action_type = CTRL_UNDO_REDO_ENTRY_TYPE_DELETE_DIAGRAMELEMENT;
      91            5 :     data_diagramelement_replace( &((*this_).data_before_action.diagramelement), data_before );
      92            5 :     data_diagramelement_init_empty( &((*this_).data_after_action.diagramelement) );
      93            5 : }
      94              : 
      95            4 : static inline const data_diagramelement_t *ctrl_undo_redo_entry_get_diagramelement_after_action_const ( const ctrl_undo_redo_entry_t *this_ )
      96              : {
      97            4 :     return &((*this_).data_after_action.diagramelement);
      98              : }
      99              : 
     100            3 : static inline const data_diagramelement_t *ctrl_undo_redo_entry_get_diagramelement_before_action_const ( const ctrl_undo_redo_entry_t *this_ )
     101              : {
     102            3 :     return &((*this_).data_before_action.diagramelement);
     103              : }
     104              : 
     105              : /* ================================ CLASSIFIER ================================ */
     106              : 
     107           26 : static inline void ctrl_undo_redo_entry_init_create_classifier ( ctrl_undo_redo_entry_t *this_ ,
     108              :                                                                  const data_classifier_t *data_after )
     109              : {
     110           26 :     (*this_).action_type = CTRL_UNDO_REDO_ENTRY_TYPE_CREATE_CLASSIFIER;
     111           26 :     data_classifier_init_empty( &((*this_).data_before_action.classifier) );
     112           26 :     data_classifier_replace( &((*this_).data_after_action.classifier), data_after );
     113           26 : }
     114              : 
     115            7 : static inline void ctrl_undo_redo_entry_init_update_classifier ( ctrl_undo_redo_entry_t *this_ ,
     116              :                                                                  const data_classifier_t *data_before,
     117              :                                                                  const data_classifier_t *data_after )
     118              : {
     119            7 :     (*this_).action_type = CTRL_UNDO_REDO_ENTRY_TYPE_UPDATE_CLASSIFIER;
     120            7 :     data_classifier_replace( &((*this_).data_before_action.classifier), data_before );
     121            7 :     data_classifier_replace( &((*this_).data_after_action.classifier), data_after );
     122            7 : }
     123              : 
     124            3 : static inline void ctrl_undo_redo_entry_init_delete_classifier ( ctrl_undo_redo_entry_t *this_ ,
     125              :                                                                  const data_classifier_t *data_before )
     126              : {
     127            3 :     (*this_).action_type = CTRL_UNDO_REDO_ENTRY_TYPE_DELETE_CLASSIFIER;
     128            3 :     data_classifier_replace( &((*this_).data_before_action.classifier), data_before );
     129            3 :     data_classifier_init_empty( &((*this_).data_after_action.classifier) );
     130            3 : }
     131              : 
     132              : static inline data_classifier_t *ctrl_undo_redo_entry_get_classifier_before_action_ptr ( ctrl_undo_redo_entry_t *this_ )
     133              : {
     134              :     return &((*this_).data_before_action.classifier);
     135              : }
     136              : 
     137              : static inline data_classifier_t *ctrl_undo_redo_entry_get_classifier_after_action_ptr ( ctrl_undo_redo_entry_t *this_ )
     138              : {
     139              :     return &((*this_).data_after_action.classifier);
     140              : }
     141              : 
     142            3 : static inline const data_classifier_t *ctrl_undo_redo_entry_get_classifier_after_action_const ( const ctrl_undo_redo_entry_t *this_ )
     143              : {
     144            3 :     return &((*this_).data_after_action.classifier);
     145              : }
     146              : 
     147            1 : static inline const data_classifier_t *ctrl_undo_redo_entry_get_classifier_before_action_const ( const ctrl_undo_redo_entry_t *this_ )
     148              : {
     149            1 :     return &((*this_).data_before_action.classifier);
     150              : }
     151              : 
     152              : /* ================================ FEATURE ================================ */
     153              : 
     154           32 : static inline void ctrl_undo_redo_entry_init_create_feature ( ctrl_undo_redo_entry_t *this_,
     155              :                                                               const data_feature_t *data_after )
     156              : {
     157           32 :     (*this_).action_type = CTRL_UNDO_REDO_ENTRY_TYPE_CREATE_FEATURE;
     158           32 :     data_feature_init_empty( &((*this_).data_before_action.feature) );
     159           32 :     data_feature_replace( &((*this_).data_after_action.feature), data_after );
     160           32 : }
     161              : 
     162            7 : static inline void ctrl_undo_redo_entry_init_update_feature ( ctrl_undo_redo_entry_t *this_,
     163              :                                                               const data_feature_t *data_before,
     164              :                                                               const data_feature_t *data_after )
     165              : {
     166            7 :     (*this_).action_type = CTRL_UNDO_REDO_ENTRY_TYPE_UPDATE_FEATURE;
     167            7 :     data_feature_replace( &((*this_).data_before_action.feature), data_before );
     168            7 :     data_feature_replace( &((*this_).data_after_action.feature), data_after );
     169            7 : }
     170              : 
     171            9 : static inline void ctrl_undo_redo_entry_init_delete_feature ( ctrl_undo_redo_entry_t *this_,
     172              :                                                               const data_feature_t *data_before )
     173              : {
     174            9 :     (*this_).action_type = CTRL_UNDO_REDO_ENTRY_TYPE_DELETE_FEATURE;
     175            9 :     data_feature_replace( &((*this_).data_before_action.feature), data_before );
     176            9 :     data_feature_init_empty( &((*this_).data_after_action.feature) );
     177            9 : }
     178              : 
     179            4 : static inline const data_feature_t *ctrl_undo_redo_entry_get_feature_after_action_const ( const ctrl_undo_redo_entry_t *this_ )
     180              : {
     181            4 :     return &((*this_).data_after_action.feature);
     182              : }
     183              : 
     184            5 : static inline const data_feature_t *ctrl_undo_redo_entry_get_feature_before_action_const ( const ctrl_undo_redo_entry_t *this_ )
     185              : {
     186            5 :     return &((*this_).data_before_action.feature);
     187              : }
     188              : 
     189              : /* ================================ RELATIONSHIP ================================ */
     190              : 
     191           13 : static inline void ctrl_undo_redo_entry_init_create_relationship ( ctrl_undo_redo_entry_t *this_,
     192              :                                                                    const data_relationship_t *data_after )
     193              : {
     194           13 :     (*this_).action_type = CTRL_UNDO_REDO_ENTRY_TYPE_CREATE_RELATIONSHIP;
     195           13 :     data_relationship_init_empty( &((*this_).data_before_action.relationship) );
     196           13 :     data_relationship_replace( &((*this_).data_after_action.relationship), data_after );
     197           13 : }
     198              : 
     199            6 : static inline void ctrl_undo_redo_entry_init_update_relationship ( ctrl_undo_redo_entry_t *this_,
     200              :                                                                    const data_relationship_t *data_before,
     201              :                                                                    const data_relationship_t *data_after )
     202              : {
     203            6 :     (*this_).action_type = CTRL_UNDO_REDO_ENTRY_TYPE_UPDATE_RELATIONSHIP;
     204            6 :     data_relationship_replace( &((*this_).data_before_action.relationship), data_before );
     205            6 :     data_relationship_replace( &((*this_).data_after_action.relationship), data_after );
     206            6 : }
     207              : 
     208            5 : static inline void ctrl_undo_redo_entry_init_delete_relationship ( ctrl_undo_redo_entry_t *this_,
     209              :                                                                    const data_relationship_t *data_before )
     210              : {
     211            5 :     (*this_).action_type = CTRL_UNDO_REDO_ENTRY_TYPE_DELETE_RELATIONSHIP;
     212            5 :     data_relationship_replace( &((*this_).data_before_action.relationship), data_before );
     213            5 :     data_relationship_init_empty( &((*this_).data_after_action.relationship) );
     214            5 : }
     215              : 
     216            3 : static inline const data_relationship_t *ctrl_undo_redo_entry_get_relationship_after_action_const ( const ctrl_undo_redo_entry_t *this_ )
     217              : {
     218            3 :     return &((*this_).data_after_action.relationship);
     219              : }
     220              : 
     221            3 : static inline const data_relationship_t *ctrl_undo_redo_entry_get_relationship_before_action_const ( const ctrl_undo_redo_entry_t *this_ )
     222              : {
     223            3 :     return &((*this_).data_before_action.relationship);
     224              : }
     225              : 
     226              : /* ================================ ENTRY_TYPE ================================ */
     227              : 
     228        36315 : static inline ctrl_undo_redo_entry_type_t ctrl_undo_redo_entry_get_action_type ( const ctrl_undo_redo_entry_t *this_ )
     229              : {
     230        36315 :     return (*this_).action_type;
     231              : }
     232              : 
     233              : /* ================================ STATISTICS ================================ */
     234              : 
     235          188 : 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 )
     236              : {
     237          188 :     assert( NULL != io_stat );
     238              : 
     239          188 :     data_stat_table_t table = DATA_STAT_TABLE_LIFELINE;
     240          188 :     data_stat_series_t series = DATA_STAT_SERIES_ERROR;
     241          188 :     switch( (*this_).action_type )
     242              :     {
     243            1 :         case CTRL_UNDO_REDO_ENTRY_TYPE_DELETE_DIAGRAM:
     244              :         {
     245            1 :             table = DATA_STAT_TABLE_DIAGRAM;
     246            1 :             series = undo ? DATA_STAT_SERIES_CREATED : DATA_STAT_SERIES_DELETED;
     247              :         }
     248            1 :         break;
     249              : 
     250           10 :         case CTRL_UNDO_REDO_ENTRY_TYPE_UPDATE_DIAGRAM:
     251              :         {
     252           10 :             table = DATA_STAT_TABLE_DIAGRAM;
     253           10 :             series = DATA_STAT_SERIES_MODIFIED;
     254              :         }
     255           10 :         break;
     256              : 
     257          134 :         case CTRL_UNDO_REDO_ENTRY_TYPE_CREATE_DIAGRAM:
     258              :         {
     259          134 :             table = DATA_STAT_TABLE_DIAGRAM;
     260          134 :             series = undo ? DATA_STAT_SERIES_DELETED : DATA_STAT_SERIES_CREATED;
     261              :         }
     262          134 :         break;
     263              : 
     264            2 :         case CTRL_UNDO_REDO_ENTRY_TYPE_DELETE_DIAGRAMELEMENT:
     265              :         {
     266            2 :             table = DATA_STAT_TABLE_DIAGRAMELEMENT;
     267            2 :             series = undo ? DATA_STAT_SERIES_CREATED : DATA_STAT_SERIES_DELETED;
     268              :         }
     269            2 :         break;
     270              : 
     271            8 :         case CTRL_UNDO_REDO_ENTRY_TYPE_UPDATE_DIAGRAMELEMENT:
     272              :         {
     273            8 :             table = DATA_STAT_TABLE_DIAGRAMELEMENT;
     274            8 :             series = DATA_STAT_SERIES_MODIFIED;
     275              :         }
     276            8 :         break;
     277              : 
     278            2 :         case CTRL_UNDO_REDO_ENTRY_TYPE_CREATE_DIAGRAMELEMENT:
     279              :         {
     280            2 :             table = DATA_STAT_TABLE_DIAGRAMELEMENT;
     281            2 :             series = undo ? DATA_STAT_SERIES_DELETED : DATA_STAT_SERIES_CREATED;
     282              :         }
     283            2 :         break;
     284              : 
     285            3 :         case CTRL_UNDO_REDO_ENTRY_TYPE_DELETE_CLASSIFIER:
     286              :         {
     287            3 :             table = DATA_STAT_TABLE_CLASSIFIER;
     288            3 :             series = undo ? DATA_STAT_SERIES_CREATED : DATA_STAT_SERIES_DELETED;
     289              :         }
     290            3 :         break;
     291              : 
     292            2 :         case CTRL_UNDO_REDO_ENTRY_TYPE_UPDATE_CLASSIFIER:
     293              :         {
     294            2 :             table = DATA_STAT_TABLE_CLASSIFIER;
     295            2 :             series = DATA_STAT_SERIES_MODIFIED;
     296              :         }
     297            2 :         break;
     298              : 
     299            2 :         case CTRL_UNDO_REDO_ENTRY_TYPE_CREATE_CLASSIFIER:
     300              :         {
     301            2 :             table = DATA_STAT_TABLE_CLASSIFIER;
     302            2 :             series = undo ? DATA_STAT_SERIES_DELETED : DATA_STAT_SERIES_CREATED;
     303              :         }
     304            2 :         break;
     305              : 
     306            7 :         case CTRL_UNDO_REDO_ENTRY_TYPE_DELETE_FEATURE:
     307              :         {
     308            7 :             const data_feature_t *const old_feat = &((*this_).data_before_action.feature);
     309            7 :             const data_feature_type_t feat_type = data_feature_get_main_type( old_feat );
     310            7 :             table = (feat_type == DATA_FEATURE_TYPE_LIFELINE) ? DATA_STAT_TABLE_LIFELINE : DATA_STAT_TABLE_FEATURE;
     311            7 :             series = undo ? DATA_STAT_SERIES_CREATED : DATA_STAT_SERIES_DELETED;
     312              :         }
     313            7 :         break;
     314              : 
     315            4 :         case CTRL_UNDO_REDO_ENTRY_TYPE_UPDATE_FEATURE:
     316              :         {
     317            4 :             const data_feature_t *const old_feat = &((*this_).data_before_action.feature);
     318            4 :             const data_feature_type_t feat_type = data_feature_get_main_type( old_feat );
     319            4 :             table = (feat_type == DATA_FEATURE_TYPE_LIFELINE) ? DATA_STAT_TABLE_LIFELINE : DATA_STAT_TABLE_FEATURE;
     320            4 :             series = DATA_STAT_SERIES_MODIFIED;
     321              :         }
     322            4 :         break;
     323              : 
     324            4 :         case CTRL_UNDO_REDO_ENTRY_TYPE_CREATE_FEATURE:
     325              :         {
     326            4 :             const data_feature_t *const new_feat = &((*this_).data_after_action.feature);
     327            4 :             const data_feature_type_t feat_type = data_feature_get_main_type( new_feat );
     328            4 :             table = (feat_type == DATA_FEATURE_TYPE_LIFELINE) ? DATA_STAT_TABLE_LIFELINE : DATA_STAT_TABLE_FEATURE;
     329            4 :             series = undo ? DATA_STAT_SERIES_DELETED : DATA_STAT_SERIES_CREATED;
     330              :         }
     331            4 :         break;
     332              : 
     333            5 :         case CTRL_UNDO_REDO_ENTRY_TYPE_DELETE_RELATIONSHIP:
     334              :         {
     335            5 :             table = DATA_STAT_TABLE_RELATIONSHIP;
     336            5 :             series = undo ? DATA_STAT_SERIES_CREATED : DATA_STAT_SERIES_DELETED;
     337              :         }
     338            5 :         break;
     339              : 
     340            2 :         case CTRL_UNDO_REDO_ENTRY_TYPE_UPDATE_RELATIONSHIP:
     341              :         {
     342            2 :             table = DATA_STAT_TABLE_RELATIONSHIP;
     343            2 :             series = DATA_STAT_SERIES_MODIFIED;
     344              :         }
     345            2 :         break;
     346              : 
     347            2 :         case CTRL_UNDO_REDO_ENTRY_TYPE_CREATE_RELATIONSHIP:
     348              :         {
     349            2 :             table = DATA_STAT_TABLE_RELATIONSHIP;
     350            2 :             series = undo ? DATA_STAT_SERIES_DELETED : DATA_STAT_SERIES_CREATED;
     351              :         }
     352            2 :         break;
     353              : 
     354            0 :         case CTRL_UNDO_REDO_ENTRY_TYPE_BOUNDARY:
     355              :         {
     356              :             /* nothing to count */
     357              :         }
     358            0 :         break;
     359              : 
     360            0 :         default :
     361              :         {
     362              :             /* internal error, switch-case statement incomplete */
     363            0 :             U8_LOG_ERROR("incomplete switch statement in ctrl_undo_redo_entry_to_statistics");
     364              :         }
     365            0 :         break;
     366              :     }
     367              : 
     368          188 :     data_stat_inc_count ( io_stat, table, (err ? DATA_STAT_SERIES_ERROR : series) );
     369          188 : }
     370              : 
     371              : 
     372              : /*
     373              : Copyright 2016-2025 Andreas Warnke
     374              : 
     375              : Licensed under the Apache License, Version 2.0 (the "License");
     376              : you may not use this file except in compliance with the License.
     377              : You may obtain a copy of the License at
     378              : 
     379              :     http://www.apache.org/licenses/LICENSE-2.0
     380              : 
     381              : Unless required by applicable law or agreed to in writing, software
     382              : distributed under the License is distributed on an "AS IS" BASIS,
     383              : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     384              : See the License for the specific language governing permissions and
     385              : limitations under the License.
     386              : */
        

Generated by: LCOV version 2.0-1