LCOV - code coverage report
Current view: top level - data/include - data_rules.inl (source / functions) Hit Total Coverage
Test: crystal-facet-uml_v1.57.0_covts Lines: 68 87 78.2 %
Date: 2024-04-07 11:14:42 Functions: 11 13 84.6 %

          Line data    Source code
       1             : /* File: data_rules.inl; Copyright and License: see below */
       2             : 
       3             : #include "u8/u8_trace.h"
       4             : #include "u8/u8_log.h"
       5             : #include <assert.h>
       6             : 
       7          88 : static inline void data_rules_init ( data_rules_t *this_ )
       8             : {
       9          88 :     (*this_).dummy = 0;  /* prevent warnings on uninitialized usage */
      10          88 : }
      11             : 
      12          88 : static inline void data_rules_destroy ( data_rules_t *this_ )
      13             : {
      14          88 : }
      15             : 
      16             : /* ================================ DIAGRAM ================================ */
      17             : 
      18          42 : static inline bool data_rules_diagram_is_scenario ( const data_rules_t *this_, data_diagram_type_t diagram_type )
      19             : {
      20             :     bool result;
      21          42 :     result = (( diagram_type == DATA_DIAGRAM_TYPE_UML_SEQUENCE_DIAGRAM )
      22          20 :              || ( diagram_type == DATA_DIAGRAM_TYPE_UML_COMMUNICATION_DIAGRAM )
      23          20 :              || ( diagram_type == DATA_DIAGRAM_TYPE_UML_TIMING_DIAGRAM )
      24          62 :              || ( diagram_type == DATA_DIAGRAM_TYPE_INTERACTION_OVERVIEW_DIAGRAM ));
      25          42 :     return result;
      26             : }
      27             : 
      28             : /* ================================ CLASSIFIER ================================ */
      29             : 
      30             : /* ================================ FEATURE ================================ */
      31             : 
      32       33534 : static inline bool data_rules_classifier_has_uncond_features ( const data_rules_t *this_, data_classifier_type_t classifier_type )
      33             : {
      34             :     bool result;
      35             : 
      36       33534 :     switch ( classifier_type )
      37             :     {
      38       33531 :         case DATA_CLASSIFIER_TYPE_BLOCK:
      39             :         case DATA_CLASSIFIER_TYPE_CONSTRAINT_BLOCK:
      40             :         case DATA_CLASSIFIER_TYPE_REQUIREMENT: /* for requirements, there is a predefined set of: id, text, ... */
      41             :         case DATA_CLASSIFIER_TYPE_INTERFACE:
      42             :         case DATA_CLASSIFIER_TYPE_CLASS:
      43             :         case DATA_CLASSIFIER_TYPE_OBJECT:
      44             :         case DATA_CLASSIFIER_TYPE_USE_CASE:
      45             :         case DATA_CLASSIFIER_TYPE_NODE:
      46             :         case DATA_CLASSIFIER_TYPE_SUBSYSTEM:
      47             :         case DATA_CLASSIFIER_TYPE_COMPONENT:
      48             :         case DATA_CLASSIFIER_TYPE_PART:
      49             :         case DATA_CLASSIFIER_TYPE_PACKAGE:
      50             :         case DATA_CLASSIFIER_TYPE_ARTIFACT:
      51             :         case DATA_CLASSIFIER_TYPE_DYN_INTERRUPTABLE_REGION:
      52             :         case DATA_CLASSIFIER_TYPE_ACTIVITY:
      53             :         case DATA_CLASSIFIER_TYPE_STATE:
      54             :         case DATA_CLASSIFIER_TYPE_STEREOTYPE:
      55             :         {
      56       33531 :             result = true;
      57             :         }
      58       33531 :         break;
      59             : 
      60           3 :         case DATA_CLASSIFIER_TYPE_ACTOR:
      61             :         case DATA_CLASSIFIER_TYPE_DIAGRAM_REFERENCE:
      62             :         case DATA_CLASSIFIER_TYPE_COMMENT:
      63             :         case DATA_CLASSIFIER_TYPE_DYN_INITIAL_NODE:
      64             :         case DATA_CLASSIFIER_TYPE_DYN_FINAL_NODE:
      65             :         case DATA_CLASSIFIER_TYPE_DYN_FORK_NODE:
      66             :         case DATA_CLASSIFIER_TYPE_DYN_JOIN_NODE:
      67             :         case DATA_CLASSIFIER_TYPE_DYN_DECISION_NODE:
      68             :         case DATA_CLASSIFIER_TYPE_DYN_SHALLOW_HISTORY:
      69             :         case DATA_CLASSIFIER_TYPE_DYN_DEEP_HISTORY:
      70             :         case DATA_CLASSIFIER_TYPE_DYN_ACCEPT_EVENT :
      71             :         case DATA_CLASSIFIER_TYPE_DYN_ACCEPT_TIME_EVENT:
      72             :         case DATA_CLASSIFIER_TYPE_DYN_SEND_SIGNAL:
      73             :         case DATA_CLASSIFIER_TYPE_IMAGE:
      74             :         {
      75           3 :             result = false;
      76             :         }
      77           3 :         break;
      78             : 
      79           0 :         default:
      80             :         {
      81           0 :             U8_LOG_ANOMALY("data_classifier_type_t out of range in data_rules_has_features");
      82           0 :             result = true;
      83             :             /* this case can happen if a model file of a new cfu version is opened with an older version of cfu */
      84             :         }
      85           0 :         break;
      86             :     }
      87             : 
      88       33534 :     return result;
      89             : }
      90             : 
      91       33560 : static inline bool data_rules_feature_is_scenario_cond ( const data_rules_t *this_, data_feature_type_t feature_type )
      92             : {
      93             :     bool result;
      94       33560 :     result = ( feature_type == DATA_FEATURE_TYPE_LIFELINE );
      95       33560 :     return result;
      96             : }
      97             : 
      98         296 : static inline bool data_rules_diagram_shows_uncond_features ( const data_rules_t *this_, data_diagram_type_t diagram_type )
      99             : {
     100             :     bool hide;
     101         296 :     hide = (( diagram_type == DATA_DIAGRAM_TYPE_LIST )
     102         296 :            || ( diagram_type == DATA_DIAGRAM_TYPE_BOX_DIAGRAM )
     103         294 :            || ( diagram_type == DATA_DIAGRAM_TYPE_UML_COMMUNICATION_DIAGRAM )
     104         292 :            || ( diagram_type == DATA_DIAGRAM_TYPE_UML_SEQUENCE_DIAGRAM )
     105         292 :            || ( diagram_type == DATA_DIAGRAM_TYPE_UML_TIMING_DIAGRAM )
     106         592 :            || ( diagram_type == DATA_DIAGRAM_TYPE_INTERACTION_OVERVIEW_DIAGRAM ));
     107         296 :     return ( ! hide );
     108             : }
     109             : 
     110           9 : static inline bool data_rules_diagram_shows_scenario_features ( const data_rules_t *this_, data_diagram_type_t diagram_type )
     111             : {
     112             :     bool show;
     113           9 :     show = (( diagram_type == DATA_DIAGRAM_TYPE_UML_COMMUNICATION_DIAGRAM )
     114           6 :            || ( diagram_type == DATA_DIAGRAM_TYPE_UML_SEQUENCE_DIAGRAM )
     115           6 :            || ( diagram_type == DATA_DIAGRAM_TYPE_UML_TIMING_DIAGRAM )
     116          15 :            || ( diagram_type == DATA_DIAGRAM_TYPE_INTERACTION_OVERVIEW_DIAGRAM ));
     117           9 :     return show;
     118             : }
     119             : 
     120       33238 : static inline bool data_rules_vis_classifier_has_feature ( const data_rules_t *this_,
     121             :                                                            const data_visible_classifier_t *vis_classifier,
     122             :                                                            const data_feature_t *feature )
     123             : {
     124       33238 :     assert( vis_classifier != NULL );
     125       33238 :     assert( feature != NULL );
     126       33238 :     const bool valid = data_visible_classifier_is_valid ( vis_classifier ) && data_feature_is_valid ( feature );
     127       33238 :     const data_classifier_t *clasfy = data_visible_classifier_get_classifier_const ( vis_classifier );
     128       33238 :     const data_diagramelement_t *diagele = data_visible_classifier_get_diagramelement_const ( vis_classifier );
     129       33238 :     assert( clasfy != NULL );
     130       33238 :     assert( diagele != NULL );
     131       33238 :     const bool belongs = ( data_feature_get_classifier_row_id( feature ) == data_classifier_get_row_id( clasfy ) );
     132       33238 :     const bool scenario = data_rules_feature_is_scenario_cond( this_, data_feature_get_main_type( feature ) );
     133       33238 :     const bool focused = ( data_diagramelement_get_focused_feature_row_id( diagele ) == data_feature_get_row_id( feature ) );
     134       33238 :     const bool visible = data_rules_classifier_has_uncond_features( this_, data_classifier_get_main_type( clasfy ) );
     135       33238 :     return valid && belongs && (((!scenario)&&visible) || (scenario&&focused));
     136             : }
     137             : 
     138           0 : static inline bool data_rules_classifier_has_scenario_semantics ( const data_rules_t *this_,
     139             :                                                                   data_diagram_type_t diagram_type,
     140             :                                                                   data_classifier_type_t classifier_type )
     141             : {
     142           0 :     const bool lifeline_has_no_semantics
     143             :         = ( classifier_type == DATA_CLASSIFIER_TYPE_REQUIREMENT )
     144           0 :         || ( classifier_type == DATA_CLASSIFIER_TYPE_DEPRECATED_FEATURE )
     145           0 :         || ( classifier_type == DATA_CLASSIFIER_TYPE_COMMENT )
     146           0 :         || ( classifier_type == DATA_CLASSIFIER_TYPE_IMAGE )
     147           0 :         || ( classifier_type == DATA_CLASSIFIER_TYPE_STEREOTYPE )
     148           0 :         || (( diagram_type == DATA_DIAGRAM_TYPE_UML_SEQUENCE_DIAGRAM )
     149           0 :         && (( classifier_type == DATA_CLASSIFIER_TYPE_INTERACTION )
     150           0 :         || ( classifier_type == DATA_CLASSIFIER_TYPE_DIAGRAM_REFERENCE )));
     151           0 :     return ( ! lifeline_has_no_semantics);
     152             : }
     153             : 
     154           0 : static inline bool data_rules_feature_value_is_stereotype ( const data_rules_t *this_, data_feature_type_t feature_type )
     155             : {
     156             :     bool has_value;
     157           0 :     has_value = (( feature_type == DATA_FEATURE_TYPE_PROPERTY )
     158           0 :            || ( feature_type == DATA_FEATURE_TYPE_OPERATION )
     159           0 :            || ( feature_type == DATA_FEATURE_TYPE_TAGGED_VALUE ));
     160           0 :     return ( ! has_value );
     161             : }
     162             : 
     163             : /* ================================ RELATIONSHIP ================================ */
     164             : 
     165        1074 : static inline bool data_rules_relationship_is_scenario_cond ( const data_rules_t *this_,
     166             :                                                               data_feature_type_t from_feature_type,
     167             :                                                               data_feature_type_t to_feature_type
     168             :                                                             )
     169             : {
     170             :     bool result;
     171        1074 :     result = ( from_feature_type == DATA_FEATURE_TYPE_LIFELINE )
     172        1074 :              || ( to_feature_type == DATA_FEATURE_TYPE_LIFELINE );
     173        1074 :     return result;
     174             : }
     175             : 
     176        1059 : static inline bool data_rules_diagram_shows_uncond_relationships ( const data_rules_t *this_, data_diagram_type_t diagram_type )
     177             : {
     178             :     bool hide;
     179        1059 :     hide = (( diagram_type == DATA_DIAGRAM_TYPE_LIST )
     180        1059 :            || ( diagram_type == DATA_DIAGRAM_TYPE_BOX_DIAGRAM )
     181        1055 :            || ( diagram_type == DATA_DIAGRAM_TYPE_UML_COMMUNICATION_DIAGRAM )
     182        1051 :            || ( diagram_type == DATA_DIAGRAM_TYPE_UML_SEQUENCE_DIAGRAM )
     183        1051 :            || ( diagram_type == DATA_DIAGRAM_TYPE_UML_TIMING_DIAGRAM )
     184        2118 :            || ( diagram_type == DATA_DIAGRAM_TYPE_INTERACTION_OVERVIEW_DIAGRAM ));
     185        1059 :     return ( ! hide );
     186             : }
     187             : 
     188          12 : static inline bool data_rules_diagram_shows_scenario_relationships ( const data_rules_t *this_, data_diagram_type_t diagram_type )
     189             : {
     190             :     bool show;
     191          12 :     show = (( diagram_type == DATA_DIAGRAM_TYPE_UML_COMMUNICATION_DIAGRAM )
     192           9 :            || ( diagram_type == DATA_DIAGRAM_TYPE_UML_SEQUENCE_DIAGRAM )
     193           9 :            || ( diagram_type == DATA_DIAGRAM_TYPE_UML_TIMING_DIAGRAM )
     194          21 :            || ( diagram_type == DATA_DIAGRAM_TYPE_INTERACTION_OVERVIEW_DIAGRAM ));
     195          12 :     return show;
     196             : }
     197             : 
     198             : /*
     199             : static inline bool data_rules_is_relationship_compliant ( const data_rules_t *this_,
     200             :                                                           data_relationship_type_t relation_type,
     201             :                                                           data_classifier_type_t from_c_type,
     202             :                                                           data_feature_type_t from_f_type,
     203             :                                                           data_classifier_type_t to_c_type,
     204             :                                                           data_feature_type_t to_f_type )
     205             : {
     206             :     bool comply;
     207             :     comply = true;
     208             :     TODO
     209             :     return comply;
     210             : }
     211             : */
     212             : 
     213             : 
     214             : /*
     215             : Copyright 2017-2024 Andreas Warnke
     216             : 
     217             : Licensed under the Apache License, Version 2.0 (the "License");
     218             : you may not use this file except in compliance with the License.
     219             : You may obtain a copy of the License at
     220             : 
     221             :     http://www.apache.org/licenses/LICENSE-2.0
     222             : 
     223             : Unless required by applicable law or agreed to in writing, software
     224             : distributed under the License is distributed on an "AS IS" BASIS,
     225             : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     226             : See the License for the specific language governing permissions and
     227             : limitations under the License.
     228             : */

Generated by: LCOV version 1.16