| 1 |
/* File: layout_visible_set.inl; Copyright and License: see below */ |
| 2 |
|
| 3 |
#include "u8/u8_log.h" |
| 4 |
#include <assert.h> |
| 5 |
|
| 6 |
static inline void layout_visible_set_reinit( layout_visible_set_t *this_, const data_visible_set_t *input_data ) |
| 7 |
{ |
| 8 |
layout_visible_set_destroy( this_ ); |
| 9 |
layout_visible_set_init( this_, input_data ); |
| 10 |
} |
| 11 |
|
| 12 |
static inline void layout_visible_set_resync( layout_visible_set_t *this_ ) |
| 13 |
{ |
| 14 |
layout_visible_set_reinit( this_, (*this_).input_data ); |
| 15 |
} |
| 16 |
|
| 17 |
static inline bool layout_visible_set_is_valid( const layout_visible_set_t *this_ ) |
| 18 |
{ |
| 19 |
return (*this_).diagram_valid; |
| 20 |
} |
| 21 |
|
| 22 |
/* ================================ diagram ================================ */ |
| 23 |
|
| 24 |
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 |
return &((*this_).diagram_layout); |
| 28 |
} |
| 29 |
|
| 30 |
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 |
return &((*this_).diagram_layout); |
| 34 |
} |
| 35 |
|
| 36 |
/* ================================ classifiers ================================ */ |
| 37 |
|
| 38 |
static inline uint32_t layout_visible_set_get_visible_classifier_count ( const layout_visible_set_t *this_ ) |
| 39 |
{ |
| 40 |
assert ( (*this_).visible_classifier_count <= LAYOUT_VISIBLE_SET_MAX_CLASSIFIERS ); |
| 41 |
return (*this_).visible_classifier_count; |
| 42 |
} |
| 43 |
|
| 44 |
static inline layout_visible_classifier_t *layout_visible_set_get_visible_classifier_ptr ( layout_visible_set_t *this_, uint32_t index ) |
| 45 |
{ |
| 46 |
assert( index < (*this_).visible_classifier_count ); |
| 47 |
assert ( (*this_).visible_classifier_count <= LAYOUT_VISIBLE_SET_MAX_CLASSIFIERS ); |
| 48 |
return &((*this_).visible_classifier_layout[index]); |
| 49 |
} |
| 50 |
|
| 51 |
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 |
assert( index < (*this_).visible_classifier_count ); |
| 54 |
assert ( (*this_).visible_classifier_count <= LAYOUT_VISIBLE_SET_MAX_CLASSIFIERS ); |
| 55 |
return &((*this_).visible_classifier_layout[index]); |
| 56 |
} |
| 57 |
|
| 58 |
/* ================================ features ================================ */ |
| 59 |
|
| 60 |
static inline uint32_t layout_visible_set_get_feature_count ( const layout_visible_set_t *this_ ) |
| 61 |
{ |
| 62 |
assert( (*this_).feature_count <= LAYOUT_VISIBLE_SET_MAX_FEATURES ); |
| 63 |
return (*this_).feature_count; |
| 64 |
} |
| 65 |
|
| 66 |
static inline layout_feature_t *layout_visible_set_get_feature_ptr ( layout_visible_set_t *this_, uint32_t index ) |
| 67 |
{ |
| 68 |
assert( index < (*this_).feature_count ); |
| 69 |
assert( (*this_).feature_count <= LAYOUT_VISIBLE_SET_MAX_FEATURES ); |
| 70 |
return &((*this_).feature_layout[index]); |
| 71 |
} |
| 72 |
|
| 73 |
static inline const layout_feature_t *layout_visible_set_get_feature_const ( const layout_visible_set_t *this_, uint32_t index ) |
| 74 |
{ |
| 75 |
assert( index < (*this_).feature_count ); |
| 76 |
assert( (*this_).feature_count <= LAYOUT_VISIBLE_SET_MAX_FEATURES ); |
| 77 |
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 |
static inline void layout_visible_set_set_relationship_visibility ( layout_visible_set_t *this_, uint32_t index, pencil_visibility_t visible ) |
| 90 |
{ |
| 91 |
assert( index < (*this_).relationship_count ); |
| 92 |
assert( (*this_).relationship_count <= LAYOUT_VISIBLE_SET_MAX_RELATIONSHIPS ); |
| 93 |
layout_relationship_set_visibility ( &((*this_).relationship_layout[index]), visible ); |
| 94 |
} |
| 95 |
|
| 96 |
static inline uint32_t layout_visible_set_get_relationship_count ( const layout_visible_set_t *this_ ) |
| 97 |
{ |
| 98 |
assert( (*this_).relationship_count <= LAYOUT_VISIBLE_SET_MAX_RELATIONSHIPS ); |
| 99 |
return (*this_).relationship_count; |
| 100 |
} |
| 101 |
|
| 102 |
static inline layout_relationship_t *layout_visible_set_get_relationship_ptr ( layout_visible_set_t *this_, uint32_t index ) |
| 103 |
{ |
| 104 |
assert( index < (*this_).relationship_count ); |
| 105 |
assert( (*this_).relationship_count <= LAYOUT_VISIBLE_SET_MAX_RELATIONSHIPS ); |
| 106 |
return &((*this_).relationship_layout[index]); |
| 107 |
} |
| 108 |
|
| 109 |
static inline const layout_relationship_t *layout_visible_set_get_relationship_const ( const layout_visible_set_t *this_, uint32_t index ) |
| 110 |
{ |
| 111 |
assert( index < (*this_).relationship_count ); |
| 112 |
assert( (*this_).relationship_count <= LAYOUT_VISIBLE_SET_MAX_RELATIONSHIPS ); |
| 113 |
return &((*this_).relationship_layout[index]); |
| 114 |
} |
| 115 |
|
| 116 |
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 |
assert ( NULL != ancestor ); |
| 121 |
assert ( NULL != descendant ); |
| 122 |
|
| 123 |
/* get index */ |
| 124 |
uint32_t ancestor_index; |
| 125 |
uint32_t descendant_index; |
| 126 |
ancestor_index = data_visible_set_get_classifier_index_from_pointer ( (*this_).input_data, layout_visible_classifier_get_data_const(ancestor) ); |
| 127 |
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 |
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 |
static inline uint32_t layout_visible_set_count_descendants ( const layout_visible_set_t *this_, |
| 147 |
const layout_visible_classifier_t *classifier ) |
| 148 |
{ |
| 149 |
assert ( NULL != classifier ); |
| 150 |
|
| 151 |
/* get index */ |
| 152 |
uint32_t classifier_index; |
| 153 |
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 |
return data_visible_set_count_descendants_of_index ( (*this_).input_data, classifier_index ); |
| 157 |
} |
| 158 |
|
| 159 |
|
| 160 |
/* |
| 161 |
Copyright 2017-2026 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 |
*/ |