Line data Source code
1 : /* File: data_node_set.inl; Copyright and License: see below */ 2 : 3 : #include "u8/u8_log.h" 4 : #include <assert.h> 5 : 6 0 : static inline bool data_node_set_is_valid ( const data_node_set_t *this_ ) 7 : { 8 0 : return data_classifier_is_valid( &((*this_).classifier) ); 9 : } 10 : 11 : static inline void data_node_set_invalidate ( data_node_set_t *this_ ) 12 : { 13 : data_classifier_reinit_empty( &((*this_).classifier) ); 14 : } 15 : 16 0 : static inline void data_node_set_private_destroy_features( data_node_set_t *this_ ) 17 : { 18 0 : assert( (*this_).feature_count <= DATA_NODE_SET_MAX_FEATURES ); 19 : 20 0 : for ( int index = 0; index < (*this_).feature_count; index ++ ) 21 : { 22 0 : data_feature_destroy ( &((*this_).features[index]) ); 23 : } 24 : 25 0 : (*this_).feature_count = 0; 26 0 : } 27 : 28 0 : static inline void data_node_set_private_destroy_relationships( data_node_set_t *this_ ) 29 : { 30 0 : assert( (*this_).relationship_count <= DATA_NODE_SET_MAX_RELATIONSHIPS ); 31 : 32 0 : for ( int index = 0; index < (*this_).relationship_count; index ++ ) 33 : { 34 0 : data_relationship_destroy ( &((*this_).relationships[index]) ); 35 : } 36 : 37 0 : (*this_).relationship_count = 0; 38 0 : } 39 : 40 0 : static inline const data_classifier_t *data_node_set_get_classifier_const ( const data_node_set_t *this_ ) 41 : { 42 0 : return &((*this_).classifier); 43 : } 44 : 45 : static inline data_classifier_t *data_node_set_get_classifier_ptr ( data_node_set_t *this_ ) 46 : { 47 : return &((*this_).classifier); 48 : } 49 : 50 0 : static inline uint32_t data_node_set_get_feature_count ( const data_node_set_t *this_ ) 51 : { 52 0 : return (*this_).feature_count; 53 : } 54 : 55 0 : static inline const data_feature_t *data_node_set_get_feature_const ( const data_node_set_t *this_, uint32_t index ) 56 : { 57 0 : assert( (*this_).feature_count <= DATA_NODE_SET_MAX_FEATURES ); 58 : 59 : const data_feature_t *result; 60 0 : if ( index < (*this_).feature_count ) 61 : { 62 0 : result = &((*this_).features[index]); 63 : } 64 : else 65 : { 66 0 : result = NULL; 67 0 : U8_LOG_ERROR_INT( "index out of bounds (>=(*this_).feature_count)", index ); 68 : } 69 : 70 0 : return result; 71 : } 72 : 73 : static inline data_feature_t *data_node_set_get_feature_ptr ( data_node_set_t *this_, uint32_t index ) 74 : { 75 : assert( (*this_).feature_count <= DATA_NODE_SET_MAX_FEATURES ); 76 : 77 : data_feature_t *result; 78 : if ( index < (*this_).feature_count ) 79 : { 80 : result = &((*this_).features[index]); 81 : } 82 : else 83 : { 84 : result = NULL; 85 : U8_LOG_ERROR_INT( "index out of bounds (>=(*this_).feature_count)", index ); 86 : } 87 : 88 : return result; 89 : } 90 : 91 0 : static inline const data_feature_t *data_node_set_get_feature_by_id_const ( const data_node_set_t *this_, data_row_id_t row_id ) 92 : { 93 0 : assert( (*this_).feature_count <= DATA_NODE_SET_MAX_FEATURES ); 94 0 : const data_feature_t *result = NULL; 95 : 96 0 : for ( int index = 0; index < (*this_).feature_count; index ++ ) 97 : { 98 : const data_feature_t *probe; 99 0 : probe = &((*this_).features[index]); 100 0 : if ( row_id == data_feature_get_row_id( probe ) ) 101 : { 102 0 : result = probe; 103 0 : break; 104 : } 105 : } 106 : 107 0 : return result; 108 : } 109 : 110 : static inline data_feature_t *data_node_set_get_feature_by_id_ptr ( data_node_set_t *this_, data_row_id_t row_id ) 111 : { 112 : assert( (*this_).feature_count <= DATA_NODE_SET_MAX_FEATURES ); 113 : data_feature_t *result = NULL; 114 : 115 : for ( int index = 0; index < (*this_).feature_count; index ++ ) 116 : { 117 : data_feature_t *probe; 118 : probe = &((*this_).features[index]); 119 : if ( row_id == data_feature_get_row_id( probe ) ) 120 : { 121 : result = probe; 122 : break; 123 : } 124 : } 125 : 126 : return result; 127 : } 128 : 129 : static inline data_feature_t *data_node_set_get_feature_list_ptr ( data_node_set_t *this_ ) 130 : { 131 : assert( (*this_).feature_count <= DATA_NODE_SET_MAX_FEATURES ); 132 : return (*this_).features; 133 : } 134 : 135 0 : static inline uint32_t data_node_set_get_relationship_count ( const data_node_set_t *this_ ) 136 : { 137 0 : return (*this_).relationship_count; 138 : } 139 : 140 0 : static inline const data_relationship_t *data_node_set_get_relationship_const ( const data_node_set_t *this_, uint32_t index ) 141 : { 142 0 : assert( (*this_).relationship_count <= DATA_NODE_SET_MAX_RELATIONSHIPS ); 143 : 144 : const data_relationship_t *result; 145 0 : if ( index < (*this_).relationship_count ) 146 : { 147 0 : result = &((*this_).relationships[index]); 148 : } 149 : else 150 : { 151 0 : result = NULL; 152 0 : U8_LOG_ERROR_INT( "index out of bounds (>=(*this_).relationship_count)", index ); 153 : } 154 : 155 0 : return result; 156 : } 157 : 158 : static inline data_relationship_t *data_node_set_get_relationship_ptr ( data_node_set_t *this_, uint32_t index ) 159 : { 160 : assert( (*this_).relationship_count <= DATA_NODE_SET_MAX_RELATIONSHIPS ); 161 : 162 : data_relationship_t *result; 163 : if ( index < (*this_).relationship_count ) 164 : { 165 : result = &((*this_).relationships[index]); 166 : } 167 : else 168 : { 169 : result = NULL; 170 : U8_LOG_ERROR_INT( "index out of bounds (>=(*this_).relationship_count)", index ); 171 : } 172 : 173 : return result; 174 : } 175 : 176 : static inline const data_relationship_t *data_node_set_get_relationship_by_id_const ( const data_node_set_t *this_, data_row_id_t row_id ) 177 : { 178 : assert( (*this_).relationship_count <= DATA_NODE_SET_MAX_RELATIONSHIPS ); 179 : const data_relationship_t *result = NULL; 180 : 181 : for ( int index = 0; index < (*this_).relationship_count; index ++ ) 182 : { 183 : const data_relationship_t *probe; 184 : probe = &((*this_).relationships[index]); 185 : if ( row_id == data_relationship_get_row_id( probe ) ) 186 : { 187 : result = probe; 188 : break; 189 : } 190 : } 191 : 192 : return result; 193 : } 194 : 195 : static inline data_relationship_t *data_node_set_get_relationship_by_id_ptr ( data_node_set_t *this_, data_row_id_t row_id ) 196 : { 197 : assert( (*this_).relationship_count <= DATA_NODE_SET_MAX_RELATIONSHIPS ); 198 : data_relationship_t *result = NULL; 199 : 200 : for ( int index = 0; index < (*this_).relationship_count; index ++ ) 201 : { 202 : data_relationship_t *probe; 203 : probe = &((*this_).relationships[index]); 204 : if ( row_id == data_relationship_get_row_id( probe ) ) 205 : { 206 : result = probe; 207 : break; 208 : } 209 : } 210 : 211 : return result; 212 : } 213 : 214 : 215 : /* 216 : Copyright 2020-2024 Andreas Warnke 217 : 218 : Licensed under the Apache License, Version 2.0 (the "License"); 219 : you may not use this file except in compliance with the License. 220 : You may obtain a copy of the License at 221 : 222 : http://www.apache.org/licenses/LICENSE-2.0 223 : 224 : Unless required by applicable law or agreed to in writing, software 225 : distributed under the License is distributed on an "AS IS" BASIS, 226 : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 227 : See the License for the specific language governing permissions and 228 : limitations under the License. 229 : */