LCOV - code coverage report
Current view: top level - pencil/include - pencil_layout_data.inl (source / functions) Hit Total Coverage
Test: crystal-facet-uml_v1.56.1_covts Lines: 12 61 19.7 %
Date: 2024-03-23 04:33:35 Functions: 3 13 23.1 %

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

Generated by: LCOV version 1.16