LCOV - code coverage report
Current view: top level - pencil/include/layout - layout_visible_set.inl (source / functions) Hit Total Coverage
Test: crystal-facet-uml_v1.61.0_covts Lines: 15 61 24.6 %
Date: 2024-10-26 21:44:38 Functions: 5 17 29.4 %

          Line data    Source code
       1             : /* File: layout_visible_set.inl; Copyright and License: see below */
       2             : 
       3             : #include "u8/u8_log.h"
       4             : #include <assert.h>
       5             : 
       6           1 : static inline void layout_visible_set_reinit( layout_visible_set_t *this_, const data_visible_set_t *input_data )
       7             : {
       8           1 :     layout_visible_set_destroy( this_ );
       9           1 :     layout_visible_set_init( this_, input_data );
      10           1 : }
      11             : 
      12           0 : static inline void layout_visible_set_resync( layout_visible_set_t *this_ )
      13             : {
      14           0 :     layout_visible_set_reinit( this_, (*this_).input_data );
      15           0 : }
      16             : 
      17           0 : static inline bool layout_visible_set_is_valid( const layout_visible_set_t *this_ )
      18             : {
      19           0 :     return (*this_).diagram_valid;
      20             : }
      21             : 
      22             : /* ================================ diagram ================================ */
      23             : 
      24           5 : static inline layout_diagram_t *layout_visible_set_get_diagram_ptr ( layout_visible_set_t *this_ )
      25             : {
      26             :     /*assert ( (*this_).diagram_valid );*/ /* we return the pointer even if diagram_layout is not yet initialized */
      27           5 :     return &((*this_).diagram_layout);
      28             : }
      29             : 
      30           0 : static inline const layout_diagram_t *layout_visible_set_get_diagram_const ( const layout_visible_set_t *this_ )
      31             : {
      32             :     /*assert ( (*this_).diagram_valid );*/ /* we return the pointer even if diagram_layout is not yet initialized */
      33           0 :     return &((*this_).diagram_layout);
      34             : }
      35             : 
      36             : /* ================================ classifiers ================================ */
      37             : 
      38           5 : static inline uint32_t layout_visible_set_get_visible_classifier_count ( const layout_visible_set_t *this_ )
      39             : {
      40           5 :     assert ( (*this_).visible_classifier_count <= LAYOUT_VISIBLE_SET_MAX_CLASSIFIERS );
      41           5 :     return (*this_).visible_classifier_count;
      42             : }
      43             : 
      44           0 : static inline layout_visible_classifier_t *layout_visible_set_get_visible_classifier_ptr ( layout_visible_set_t *this_, uint32_t index )
      45             : {
      46           0 :     assert( index < (*this_).visible_classifier_count );
      47           0 :     assert ( (*this_).visible_classifier_count <= LAYOUT_VISIBLE_SET_MAX_CLASSIFIERS );
      48           0 :     return &((*this_).visible_classifier_layout[index]);
      49             : }
      50             : 
      51           0 : static inline const layout_visible_classifier_t *layout_visible_set_get_visible_classifier_const ( const layout_visible_set_t *this_, uint32_t index )
      52             : {
      53           0 :     assert( index < (*this_).visible_classifier_count );
      54           0 :     assert ( (*this_).visible_classifier_count <= LAYOUT_VISIBLE_SET_MAX_CLASSIFIERS );
      55           0 :     return &((*this_).visible_classifier_layout[index]);
      56             : }
      57             : 
      58             : /* ================================ features ================================ */
      59             : 
      60           5 : static inline uint32_t layout_visible_set_get_feature_count ( const layout_visible_set_t *this_ )
      61             : {
      62           5 :     assert( (*this_).feature_count <= LAYOUT_VISIBLE_SET_MAX_FEATURES );
      63           5 :     return (*this_).feature_count;
      64             : }
      65             : 
      66           0 : static inline layout_feature_t *layout_visible_set_get_feature_ptr ( layout_visible_set_t *this_, uint32_t index )
      67             : {
      68           0 :     assert( index < (*this_).feature_count );
      69           0 :     assert( (*this_).feature_count <= LAYOUT_VISIBLE_SET_MAX_FEATURES );
      70           0 :     return &((*this_).feature_layout[index]);
      71             : }
      72             : 
      73           0 : static inline const layout_feature_t *layout_visible_set_get_feature_const ( const layout_visible_set_t *this_, uint32_t index )
      74             : {
      75           0 :     assert( index < (*this_).feature_count );
      76           0 :     assert( (*this_).feature_count <= LAYOUT_VISIBLE_SET_MAX_FEATURES );
      77           0 :     return &((*this_).feature_layout[index]);
      78             : }
      79             : 
      80             : /* ================================ relationships ================================ */
      81             : 
      82             : static inline pencil_visibility_t layout_visible_set_get_relationship_visibility ( const layout_visible_set_t *this_, uint32_t index )
      83             : {
      84             :     assert( index < (*this_).relationship_count );
      85             :     assert( (*this_).relationship_count <= LAYOUT_VISIBLE_SET_MAX_RELATIONSHIPS );
      86             :     return layout_relationship_get_visibility ( &((*this_).relationship_layout[index]) );
      87             : }
      88             : 
      89           0 : static inline void layout_visible_set_set_relationship_visibility ( layout_visible_set_t *this_, uint32_t index, pencil_visibility_t visible )
      90             : {
      91           0 :     assert( index < (*this_).relationship_count );
      92           0 :     assert( (*this_).relationship_count <= LAYOUT_VISIBLE_SET_MAX_RELATIONSHIPS );
      93           0 :     layout_relationship_set_visibility ( &((*this_).relationship_layout[index]), visible );
      94           0 : }
      95             : 
      96           5 : static inline uint32_t layout_visible_set_get_relationship_count ( const layout_visible_set_t *this_ )
      97             : {
      98           5 :     assert( (*this_).relationship_count <= LAYOUT_VISIBLE_SET_MAX_RELATIONSHIPS );
      99           5 :     return (*this_).relationship_count;
     100             : }
     101             : 
     102           0 : static inline layout_relationship_t *layout_visible_set_get_relationship_ptr ( layout_visible_set_t *this_, uint32_t index )
     103             : {
     104           0 :     assert( index < (*this_).relationship_count );
     105           0 :     assert( (*this_).relationship_count <= LAYOUT_VISIBLE_SET_MAX_RELATIONSHIPS );
     106           0 :     return &((*this_).relationship_layout[index]);
     107             : }
     108             : 
     109           0 : static inline const layout_relationship_t *layout_visible_set_get_relationship_const ( const layout_visible_set_t *this_, uint32_t index )
     110             : {
     111           0 :     assert( index < (*this_).relationship_count );
     112           0 :     assert( (*this_).relationship_count <= LAYOUT_VISIBLE_SET_MAX_RELATIONSHIPS );
     113           0 :     return &((*this_).relationship_layout[index]);
     114             : }
     115             : 
     116           0 : static inline bool layout_visible_set_is_ancestor ( const layout_visible_set_t *this_,
     117             :                                                     const layout_visible_classifier_t *ancestor,
     118             :                                                     const layout_visible_classifier_t *descendant )
     119             : {
     120           0 :     assert ( NULL != ancestor );
     121           0 :     assert ( NULL != descendant );
     122             : 
     123             :     /* get index */
     124             :     uint32_t ancestor_index;
     125             :     uint32_t descendant_index;
     126           0 :     ancestor_index = data_visible_set_get_classifier_index_from_pointer ( (*this_).input_data, layout_visible_classifier_get_data_const(ancestor) );
     127           0 :     descendant_index = data_visible_set_get_classifier_index_from_pointer ( (*this_).input_data, layout_visible_classifier_get_data_const(descendant) );
     128             : 
     129             :     /* ask input_data */
     130           0 :     return data_visible_set_is_ancestor_by_index ( (*this_).input_data, ancestor_index, descendant_index );
     131             : }
     132             : 
     133             : static inline uint32_t layout_visible_set_count_ancestors ( const layout_visible_set_t *this_,
     134             :                                                             const layout_visible_classifier_t *classifier )
     135             : {
     136             :     assert ( NULL != classifier );
     137             : 
     138             :     /* get index */
     139             :     uint32_t classifier_index;
     140             :     classifier_index = data_visible_set_get_classifier_index_from_pointer ( (*this_).input_data, layout_visible_classifier_get_data_const(classifier) );
     141             : 
     142             :     /* ask input_data */
     143             :     return data_visible_set_count_ancestors_of_index ( (*this_).input_data, classifier_index );
     144             : }
     145             : 
     146           0 : static inline uint32_t layout_visible_set_count_descendants ( const layout_visible_set_t *this_,
     147             :                                                               const layout_visible_classifier_t *classifier )
     148             : {
     149           0 :     assert ( NULL != classifier );
     150             : 
     151             :     /* get index */
     152             :     uint32_t classifier_index;
     153           0 :     classifier_index = data_visible_set_get_classifier_index_from_pointer ( (*this_).input_data, layout_visible_classifier_get_data_const(classifier) );
     154             : 
     155             :     /* ask input_data */
     156           0 :     return data_visible_set_count_descendants_of_index ( (*this_).input_data, classifier_index );
     157             : }
     158             : 
     159             : 
     160             : /*
     161             : Copyright 2017-2024 Andreas Warnke
     162             : 
     163             : Licensed under the Apache License, Version 2.0 (the "License");
     164             : you may not use this file except in compliance with the License.
     165             : You may obtain a copy of the License at
     166             : 
     167             :     http://www.apache.org/licenses/LICENSE-2.0
     168             : 
     169             : Unless required by applicable law or agreed to in writing, software
     170             : distributed under the License is distributed on an "AS IS" BASIS,
     171             : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     172             : See the License for the specific language governing permissions and
     173             : limitations under the License.
     174             : */

Generated by: LCOV version 1.16