LCOV - code coverage report
Current view: top level - ctrl/include - ctrl_undo_redo_entry.inl (source / functions) Hit Total Coverage
Test: crystal-facet-uml_v1.61.0_covts Lines: 106 129 82.2 %
Date: 2024-10-26 21:44:38 Functions: 16 25 64.0 %

          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 : }
      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          37 : static inline data_classifier_t *ctrl_undo_redo_entry_get_classifier_before_action_ptr ( ctrl_undo_redo_entry_t *this_ )
      31             : {
      32          37 :     return &((*this_).data_before_action.classifier);
      33             : }
      34             : 
      35             : static inline const data_classifier_t *ctrl_undo_redo_entry_get_classifier_before_action_const ( const ctrl_undo_redo_entry_t *this_ )
      36             : {
      37             :     return &((*this_).data_before_action.classifier);
      38             : }
      39             : 
      40         175 : static inline data_diagram_t *ctrl_undo_redo_entry_get_diagram_before_action_ptr ( ctrl_undo_redo_entry_t *this_ )
      41             : {
      42         175 :     return &((*this_).data_before_action.diagram);
      43             : }
      44             : 
      45           0 : static inline const data_diagram_t *ctrl_undo_redo_entry_get_diagram_before_action_const ( const ctrl_undo_redo_entry_t *this_ )
      46             : {
      47           0 :     return &((*this_).data_before_action.diagram);
      48             : }
      49             : 
      50          63 : static inline data_diagramelement_t *ctrl_undo_redo_entry_get_diagramelement_before_action_ptr ( ctrl_undo_redo_entry_t *this_ )
      51             : {
      52          63 :     return &((*this_).data_before_action.diagramelement);
      53             : }
      54             : 
      55           0 : static inline const data_diagramelement_t *ctrl_undo_redo_entry_get_diagramelement_before_action_const ( const ctrl_undo_redo_entry_t *this_ )
      56             : {
      57           0 :     return &((*this_).data_before_action.diagramelement);
      58             : }
      59             : 
      60          27 : static inline data_relationship_t *ctrl_undo_redo_entry_get_relationship_before_action_ptr ( ctrl_undo_redo_entry_t *this_ )
      61             : {
      62          27 :     return &((*this_).data_before_action.relationship);
      63             : }
      64             : 
      65           0 : static inline const data_relationship_t *ctrl_undo_redo_entry_get_relationship_before_action_const ( const ctrl_undo_redo_entry_t *this_ )
      66             : {
      67           0 :     return &((*this_).data_before_action.relationship);
      68             : }
      69             : 
      70          53 : static inline data_feature_t *ctrl_undo_redo_entry_get_feature_before_action_ptr ( ctrl_undo_redo_entry_t *this_ )
      71             : {
      72          53 :     return &((*this_).data_before_action.feature);
      73             : }
      74             : 
      75           0 : static inline const data_feature_t *ctrl_undo_redo_entry_get_feature_before_action_const ( const ctrl_undo_redo_entry_t *this_ )
      76             : {
      77           0 :     return &((*this_).data_before_action.feature);
      78             : }
      79             : 
      80          39 : static inline data_classifier_t *ctrl_undo_redo_entry_get_classifier_after_action_ptr ( ctrl_undo_redo_entry_t *this_ )
      81             : {
      82          39 :     return &((*this_).data_after_action.classifier);
      83             : }
      84             : 
      85           0 : static inline const data_classifier_t *ctrl_undo_redo_entry_get_classifier_after_action_const ( const ctrl_undo_redo_entry_t *this_ )
      86             : {
      87           0 :     return &((*this_).data_after_action.classifier);
      88             : }
      89             : 
      90         309 : static inline data_diagram_t *ctrl_undo_redo_entry_get_diagram_after_action_ptr ( ctrl_undo_redo_entry_t *this_ )
      91             : {
      92         309 :     return &((*this_).data_after_action.diagram);
      93             : }
      94             : 
      95           0 : static inline const data_diagram_t *ctrl_undo_redo_entry_get_diagram_after_action_const ( const ctrl_undo_redo_entry_t *this_ )
      96             : {
      97           0 :     return &((*this_).data_after_action.diagram);
      98             : }
      99             : 
     100          64 : static inline data_diagramelement_t *ctrl_undo_redo_entry_get_diagramelement_after_action_ptr ( ctrl_undo_redo_entry_t *this_ )
     101             : {
     102          64 :     return &((*this_).data_after_action.diagramelement);
     103             : }
     104             : 
     105           0 : static inline const data_diagramelement_t *ctrl_undo_redo_entry_get_diagramelement_after_action_const ( const ctrl_undo_redo_entry_t *this_ )
     106             : {
     107           0 :     return &((*this_).data_after_action.diagramelement);
     108             : }
     109             : 
     110          27 : static inline data_relationship_t *ctrl_undo_redo_entry_get_relationship_after_action_ptr ( ctrl_undo_redo_entry_t *this_ )
     111             : {
     112          27 :     return &((*this_).data_after_action.relationship);
     113             : }
     114             : 
     115           0 : static inline const data_relationship_t *ctrl_undo_redo_entry_get_relationship_after_action_const ( const ctrl_undo_redo_entry_t *this_ )
     116             : {
     117           0 :     return &((*this_).data_after_action.relationship);
     118             : }
     119             : 
     120          52 : static inline data_feature_t *ctrl_undo_redo_entry_get_feature_after_action_ptr ( ctrl_undo_redo_entry_t *this_ )
     121             : {
     122          52 :     return &((*this_).data_after_action.feature);
     123             : }
     124             : 
     125           0 : static inline const data_feature_t *ctrl_undo_redo_entry_get_feature_after_action_const ( const ctrl_undo_redo_entry_t *this_ )
     126             : {
     127           0 :     return &((*this_).data_after_action.feature);
     128             : }
     129             : 
     130         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 )
     131             : {
     132         188 :     assert( NULL != io_stat );
     133             : 
     134         188 :     data_stat_table_t table = DATA_STAT_TABLE_LIFELINE;
     135         188 :     data_stat_series_t series = DATA_STAT_SERIES_ERROR;
     136         188 :     switch( (*this_).action_type )
     137             :     {
     138           1 :         case CTRL_UNDO_REDO_ENTRY_TYPE_DELETE_DIAGRAM:
     139             :         {
     140           1 :             table = DATA_STAT_TABLE_DIAGRAM;
     141           1 :             series = undo ? DATA_STAT_SERIES_CREATED : DATA_STAT_SERIES_DELETED;
     142             :         }
     143           1 :         break;
     144             : 
     145          10 :         case CTRL_UNDO_REDO_ENTRY_TYPE_UPDATE_DIAGRAM:
     146             :         {
     147          10 :             table = DATA_STAT_TABLE_DIAGRAM;
     148          10 :             series = DATA_STAT_SERIES_MODIFIED;
     149             :         }
     150          10 :         break;
     151             : 
     152         134 :         case CTRL_UNDO_REDO_ENTRY_TYPE_CREATE_DIAGRAM:
     153             :         {
     154         134 :             table = DATA_STAT_TABLE_DIAGRAM;
     155         134 :             series = undo ? DATA_STAT_SERIES_DELETED : DATA_STAT_SERIES_CREATED;
     156             :         }
     157         134 :         break;
     158             : 
     159           2 :         case CTRL_UNDO_REDO_ENTRY_TYPE_DELETE_DIAGRAMELEMENT:
     160             :         {
     161           2 :             table = DATA_STAT_TABLE_DIAGRAMELEMENT;
     162           2 :             series = undo ? DATA_STAT_SERIES_CREATED : DATA_STAT_SERIES_DELETED;
     163             :         }
     164           2 :         break;
     165             : 
     166           8 :         case CTRL_UNDO_REDO_ENTRY_TYPE_UPDATE_DIAGRAMELEMENT:
     167             :         {
     168           8 :             table = DATA_STAT_TABLE_DIAGRAMELEMENT;
     169           8 :             series = DATA_STAT_SERIES_MODIFIED;
     170             :         }
     171           8 :         break;
     172             : 
     173           2 :         case CTRL_UNDO_REDO_ENTRY_TYPE_CREATE_DIAGRAMELEMENT:
     174             :         {
     175           2 :             table = DATA_STAT_TABLE_DIAGRAMELEMENT;
     176           2 :             series = undo ? DATA_STAT_SERIES_DELETED : DATA_STAT_SERIES_CREATED;
     177             :         }
     178           2 :         break;
     179             : 
     180           3 :         case CTRL_UNDO_REDO_ENTRY_TYPE_DELETE_CLASSIFIER:
     181             :         {
     182           3 :             table = DATA_STAT_TABLE_CLASSIFIER;
     183           3 :             series = undo ? DATA_STAT_SERIES_CREATED : DATA_STAT_SERIES_DELETED;
     184             :         }
     185           3 :         break;
     186             : 
     187           2 :         case CTRL_UNDO_REDO_ENTRY_TYPE_UPDATE_CLASSIFIER:
     188             :         {
     189           2 :             table = DATA_STAT_TABLE_CLASSIFIER;
     190           2 :             series = DATA_STAT_SERIES_MODIFIED;
     191             :         }
     192           2 :         break;
     193             : 
     194           2 :         case CTRL_UNDO_REDO_ENTRY_TYPE_CREATE_CLASSIFIER:
     195             :         {
     196           2 :             table = DATA_STAT_TABLE_CLASSIFIER;
     197           2 :             series = undo ? DATA_STAT_SERIES_DELETED : DATA_STAT_SERIES_CREATED;
     198             :         }
     199           2 :         break;
     200             : 
     201           7 :         case CTRL_UNDO_REDO_ENTRY_TYPE_DELETE_FEATURE:
     202             :         {
     203           7 :             const data_feature_t *const old_feat = &((*this_).data_before_action.feature);
     204           7 :             const data_feature_type_t feat_type = data_feature_get_main_type( old_feat );
     205           7 :             table = (feat_type == DATA_FEATURE_TYPE_LIFELINE) ? DATA_STAT_TABLE_LIFELINE : DATA_STAT_TABLE_FEATURE;
     206           7 :             series = undo ? DATA_STAT_SERIES_CREATED : DATA_STAT_SERIES_DELETED;
     207             :         }
     208           7 :         break;
     209             : 
     210           4 :         case CTRL_UNDO_REDO_ENTRY_TYPE_UPDATE_FEATURE:
     211             :         {
     212           4 :             const data_feature_t *const old_feat = &((*this_).data_before_action.feature);
     213           4 :             const data_feature_type_t feat_type = data_feature_get_main_type( old_feat );
     214           4 :             table = (feat_type == DATA_FEATURE_TYPE_LIFELINE) ? DATA_STAT_TABLE_LIFELINE : DATA_STAT_TABLE_FEATURE;
     215           4 :             series = DATA_STAT_SERIES_MODIFIED;
     216             :         }
     217           4 :         break;
     218             : 
     219           4 :         case CTRL_UNDO_REDO_ENTRY_TYPE_CREATE_FEATURE:
     220             :         {
     221           4 :             const data_feature_t *const new_feat = &((*this_).data_after_action.feature);
     222           4 :             const data_feature_type_t feat_type = data_feature_get_main_type( new_feat );
     223           4 :             table = (feat_type == DATA_FEATURE_TYPE_LIFELINE) ? DATA_STAT_TABLE_LIFELINE : DATA_STAT_TABLE_FEATURE;
     224           4 :             series = undo ? DATA_STAT_SERIES_DELETED : DATA_STAT_SERIES_CREATED;
     225             :         }
     226           4 :         break;
     227             : 
     228           5 :         case CTRL_UNDO_REDO_ENTRY_TYPE_DELETE_RELATIONSHIP:
     229             :         {
     230           5 :             table = DATA_STAT_TABLE_RELATIONSHIP;
     231           5 :             series = undo ? DATA_STAT_SERIES_CREATED : DATA_STAT_SERIES_DELETED;
     232             :         }
     233           5 :         break;
     234             : 
     235           2 :         case CTRL_UNDO_REDO_ENTRY_TYPE_UPDATE_RELATIONSHIP:
     236             :         {
     237           2 :             table = DATA_STAT_TABLE_RELATIONSHIP;
     238           2 :             series = DATA_STAT_SERIES_MODIFIED;
     239             :         }
     240           2 :         break;
     241             : 
     242           2 :         case CTRL_UNDO_REDO_ENTRY_TYPE_CREATE_RELATIONSHIP:
     243             :         {
     244           2 :             table = DATA_STAT_TABLE_RELATIONSHIP;
     245           2 :             series = undo ? DATA_STAT_SERIES_DELETED : DATA_STAT_SERIES_CREATED;
     246             :         }
     247           2 :         break;
     248             : 
     249           0 :         case CTRL_UNDO_REDO_ENTRY_TYPE_BOUNDARY:
     250             :         {
     251             :             /* nothing to count */
     252             :         }
     253           0 :         break;
     254             : 
     255           0 :         default :
     256             :         {
     257             :             /* internal error, switch-case statement incomplete */
     258           0 :             U8_LOG_ERROR("incomplete switch statement in ctrl_undo_redo_entry_to_statistics");
     259             :         }
     260           0 :         break;
     261             :     }
     262             : 
     263         188 :     data_stat_inc_count ( io_stat, table, (err ? DATA_STAT_SERIES_ERROR : series) );
     264         188 : }
     265             : 
     266             : 
     267             : /*
     268             : Copyright 2016-2024 Andreas Warnke
     269             : 
     270             : Licensed under the Apache License, Version 2.0 (the "License");
     271             : you may not use this file except in compliance with the License.
     272             : You may obtain a copy of the License at
     273             : 
     274             :     http://www.apache.org/licenses/LICENSE-2.0
     275             : 
     276             : Unless required by applicable law or agreed to in writing, software
     277             : distributed under the License is distributed on an "AS IS" BASIS,
     278             : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     279             : See the License for the specific language governing permissions and
     280             : limitations under the License.
     281             : */

Generated by: LCOV version 1.16