Line data Source code
1 : /* File: data_type.inl; Copyright and License: see below */ 2 : 3 2 : static inline void data_type_init_void ( data_type_t *this_ ) 4 : { 5 2 : (*this_).context = DATA_TABLE_VOID; 6 2 : (*this_).specific_type = -1; 7 2 : } 8 : 9 5 : static inline void data_type_init_diagram ( data_type_t *this_, data_diagram_type_t type ) 10 : { 11 5 : (*this_).context = DATA_TABLE_DIAGRAM; 12 5 : (*this_).specific_type = (int) type; 13 5 : } 14 : 15 3 : static inline void data_type_init_classifier ( data_type_t *this_, data_classifier_type_t type ) 16 : { 17 3 : (*this_).context = DATA_TABLE_CLASSIFIER; 18 3 : (*this_).specific_type = (int) type; 19 3 : } 20 : 21 3 : static inline void data_type_init_feature ( data_type_t *this_, data_feature_type_t type ) 22 : { 23 3 : (*this_).context = DATA_TABLE_FEATURE; 24 3 : (*this_).specific_type = (int) type; 25 3 : } 26 : 27 2 : static inline void data_type_init_relationship ( data_type_t *this_, data_relationship_type_t type ) 28 : { 29 2 : (*this_).context = DATA_TABLE_RELATIONSHIP; 30 2 : (*this_).specific_type = (int) type; 31 2 : } 32 : 33 10 : static inline void data_type_destroy ( data_type_t *this_ ) 34 : { 35 10 : } 36 : 37 9 : static inline data_table_t data_type_get_context ( const data_type_t *this_ ) 38 : { 39 9 : return ( (*this_).context ); 40 : } 41 : 42 11 : static inline int data_type_get_type_as_int ( const data_type_t *this_ ) 43 : { 44 11 : return ( (*this_).specific_type ); 45 : } 46 : 47 2 : static inline const data_diagram_type_t data_type_get_diagram_type ( const data_type_t *this_ ) 48 : { 49 2 : return ( ((*this_).context == DATA_TABLE_DIAGRAM) 50 : ? (data_diagram_type_t) (*this_).specific_type 51 2 : : DATA_DIAGRAM_TYPE_VOID ); 52 : } 53 : 54 2 : static inline data_classifier_type_t data_type_get_classifier_type ( const data_type_t *this_ ) 55 : { 56 2 : return ( ((*this_).context == DATA_TABLE_CLASSIFIER) 57 : ? (data_diagram_type_t) (*this_).specific_type 58 2 : : DATA_CLASSIFIER_TYPE_VOID ); 59 : } 60 : 61 2 : static inline data_feature_type_t data_type_get_feature_type ( const data_type_t *this_ ) 62 : { 63 2 : return ( ((*this_).context == DATA_TABLE_FEATURE) 64 : ? (data_diagram_type_t) (*this_).specific_type 65 2 : : DATA_FEATURE_TYPE_VOID ); 66 : } 67 : 68 3 : static inline data_relationship_type_t data_type_get_relationship_type ( const data_type_t *this_ ) 69 : { 70 3 : return ( ((*this_).context == DATA_TABLE_RELATIONSHIP) 71 : ? (data_diagram_type_t) (*this_).specific_type 72 3 : : DATA_RELATIONSHIP_TYPE_VOID ); 73 : } 74 : 75 5 : static inline bool data_type_equals ( const data_type_t *this_, const data_type_t *that ) 76 : { 77 5 : return ( ( (*this_).context != DATA_TABLE_VOID ) 78 4 : && ( (*this_).context == (*that).context ) 79 3 : && ( (*this_).specific_type != -1 ) 80 9 : && ( (*this_).specific_type == (*that).specific_type ) ); 81 : } 82 : 83 : 84 : /* 85 : Copyright 2023-2024 Andreas Warnke 86 : 87 : Licensed under the Apache License, Version 2.0 (the "License"); 88 : you may not use this file except in compliance with the License. 89 : You may obtain a copy of the License at 90 : 91 : http://www.apache.org/licenses/LICENSE-2.0 92 : 93 : Unless required by applicable law or agreed to in writing, software 94 : distributed under the License is distributed on an "AS IS" BASIS, 95 : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 96 : See the License for the specific language governing permissions and 97 : limitations under the License. 98 : */