Line data Source code
1 : /* File: data_search_result.inl; Copyright and License: see below */
2 :
3 : #include <assert.h>
4 : #include "u8/u8_log.h"
5 :
6 0 : static inline void data_search_result_init_diagram ( data_search_result_t *this_,
7 : data_row_id_t match_id,
8 : int match_type,
9 : const char* match_name )
10 : {
11 0 : assert( NULL != match_name );
12 : utf8error_t strerr;
13 :
14 0 : data_id_init( &((*this_).match_object_id), DATA_TABLE_DIAGRAM, match_id );
15 0 : if ( match_type == DATA_DIAGRAM_TYPE_DEPRECATED_INTERACTION_OVERVIEW_DIAGRAM )
16 : {
17 0 : match_type = DATA_DIAGRAM_TYPE_UML_ACTIVITY_DIAGRAM;
18 0 : U8_LOG_ANOMALY_INT( "Diagram type INTERACTION_OVERVIEW is re-invented. Old type converted to ACTIVITY. See id D", match_id );
19 : }
20 0 : (*this_).match_type = match_type;
21 0 : (*this_).match_object_name = utf8stringbuf_init( sizeof((*this_).private_match_name_buffer), (*this_).private_match_name_buffer );
22 0 : strerr = utf8stringbuf_copy_str( (*this_).match_object_name, match_name );
23 0 : if ( strerr != UTF8ERROR_SUCCESS )
24 : {
25 : /* just the read-only name of a search result - truncation should not matter */
26 0 : U8_LOG_ANOMALY_INT( "utf8stringbuf_copy_str() failed:", strerr );
27 : }
28 :
29 0 : data_id_init_void( &((*this_).src_classifier_id) );
30 0 : data_id_init_void( &((*this_).dst_classifier_id) );
31 0 : data_id_init( &((*this_).diagram_id), DATA_TABLE_DIAGRAM, match_id );
32 0 : }
33 :
34 0 : static inline void data_search_result_init_classifier ( data_search_result_t *this_,
35 : data_row_id_t match_id,
36 : int match_type,
37 : const char* match_name,
38 : data_row_id_t diagram_id )
39 : {
40 0 : assert( NULL != match_name );
41 : utf8error_t strerr;
42 :
43 0 : data_id_init( &((*this_).match_object_id), DATA_TABLE_CLASSIFIER, match_id );
44 0 : if ( match_type == DATA_CLASSIFIER_TYPE_DEPRECATED_FEATURE )
45 : {
46 0 : match_type = DATA_CLASSIFIER_TYPE_REQUIREMENT;
47 0 : U8_LOG_ANOMALY_INT( "Classifier type FEATURE is deprecated. Converted to REQUIREMENT. See id C", match_id );
48 : }
49 0 : (*this_).match_type = match_type;
50 0 : (*this_).match_object_name = utf8stringbuf_init( sizeof((*this_).private_match_name_buffer), (*this_).private_match_name_buffer );
51 0 : strerr = utf8stringbuf_copy_str( (*this_).match_object_name, match_name );
52 0 : if ( strerr != UTF8ERROR_SUCCESS )
53 : {
54 : /* just the read-only name of a search result - truncation should not matter */
55 0 : U8_LOG_ANOMALY_INT( "utf8stringbuf_copy_str() failed:", strerr );
56 : }
57 :
58 0 : data_id_init_void( &((*this_).src_classifier_id) );
59 0 : data_id_init_void( &((*this_).dst_classifier_id) );
60 0 : data_id_init( &((*this_).diagram_id), DATA_TABLE_DIAGRAM, diagram_id );
61 0 : }
62 :
63 0 : static inline void data_search_result_init_feature ( data_search_result_t *this_,
64 : data_row_id_t match_id,
65 : int match_type,
66 : const char* match_name,
67 : data_row_id_t classifier_id,
68 : data_row_id_t diagram_id )
69 : {
70 0 : assert( NULL != match_name );
71 : utf8error_t strerr;
72 :
73 0 : data_id_init( &((*this_).match_object_id), DATA_TABLE_FEATURE, match_id );
74 0 : (*this_).match_type = match_type;
75 0 : (*this_).match_object_name = utf8stringbuf_init( sizeof((*this_).private_match_name_buffer), (*this_).private_match_name_buffer );
76 0 : strerr = utf8stringbuf_copy_str( (*this_).match_object_name, match_name );
77 0 : if ( strerr != UTF8ERROR_SUCCESS )
78 : {
79 : /* just the read-only name of a search result - truncation should not matter */
80 0 : U8_LOG_ANOMALY_INT( "utf8stringbuf_copy_str() failed:", strerr );
81 : }
82 :
83 0 : data_id_init( &((*this_).src_classifier_id), DATA_TABLE_CLASSIFIER, classifier_id );
84 0 : data_id_init_void( &((*this_).dst_classifier_id) );
85 0 : data_id_init( &((*this_).diagram_id), DATA_TABLE_DIAGRAM, diagram_id );
86 0 : }
87 :
88 0 : static inline void data_search_result_init_relationship ( data_search_result_t *this_,
89 : data_row_id_t match_id,
90 : int match_type,
91 : const char* match_name,
92 : data_row_id_t from_classifier_id,
93 : data_row_id_t to_classifier_id,
94 : data_row_id_t diagram_id )
95 : {
96 0 : assert( NULL != match_name );
97 : utf8error_t strerr;
98 :
99 0 : data_id_init( &((*this_).match_object_id), DATA_TABLE_RELATIONSHIP, match_id );
100 0 : (*this_).match_type = match_type;
101 0 : (*this_).match_object_name = utf8stringbuf_init( sizeof((*this_).private_match_name_buffer), (*this_).private_match_name_buffer );
102 0 : strerr = utf8stringbuf_copy_str( (*this_).match_object_name, match_name );
103 0 : if ( strerr != UTF8ERROR_SUCCESS )
104 : {
105 : /* just the read-only name of a search result - truncation should not matter */
106 0 : U8_LOG_ANOMALY_INT( "utf8stringbuf_copy_str() failed:", strerr );
107 : }
108 :
109 0 : data_id_init( &((*this_).src_classifier_id), DATA_TABLE_CLASSIFIER, from_classifier_id );
110 0 : data_id_init( &((*this_).dst_classifier_id), DATA_TABLE_CLASSIFIER, to_classifier_id );
111 0 : data_id_init( &((*this_).diagram_id), DATA_TABLE_DIAGRAM, diagram_id );
112 0 : }
113 :
114 0 : static inline void data_search_result_copy ( data_search_result_t *this_, const data_search_result_t *original )
115 : {
116 0 : assert( NULL != original );
117 :
118 0 : *this_ = *original;
119 : /* repair the overwritten pointers */
120 0 : (*this_).match_object_name = utf8stringbuf_init( sizeof((*this_).private_match_name_buffer), (*this_).private_match_name_buffer );
121 0 : }
122 :
123 0 : static inline void data_search_result_destroy ( data_search_result_t *this_ )
124 : {
125 0 : data_id_destroy( &((*this_).match_object_id) );
126 0 : data_id_destroy( &((*this_).src_classifier_id) );
127 0 : data_id_destroy( &((*this_).dst_classifier_id) );
128 0 : data_id_destroy( &((*this_).diagram_id) );
129 0 : }
130 :
131 0 : static inline data_id_t data_search_result_get_match_id ( const data_search_result_t *this_ )
132 : {
133 0 : return (*this_).match_object_id;
134 : }
135 :
136 : static inline data_id_t *data_search_result_get_match_id_ptr ( data_search_result_t *this_ )
137 : {
138 : return &((*this_).match_object_id);
139 : }
140 :
141 0 : static inline const data_id_t *data_search_result_get_match_id_const ( const data_search_result_t *this_ )
142 : {
143 0 : return &((*this_).match_object_id);
144 : }
145 :
146 0 : static inline data_table_t data_search_result_get_match_table ( const data_search_result_t *this_ )
147 : {
148 0 : const data_table_t match_table = data_id_get_table( &((*this_).match_object_id) );
149 0 : return match_table;
150 : }
151 :
152 0 : static inline int data_search_result_get_match_type ( const data_search_result_t *this_ )
153 : {
154 0 : return (*this_).match_type;
155 : }
156 :
157 0 : static inline const char* data_search_result_get_match_name_const ( const data_search_result_t *this_ )
158 : {
159 0 : return utf8stringbuf_get_string( (*this_).match_object_name );
160 : }
161 :
162 : static inline data_id_t data_search_result_get_src_classifier_id ( const data_search_result_t *this_ )
163 : {
164 : return (*this_).src_classifier_id;
165 : }
166 :
167 : static inline data_id_t *data_search_result_get_src_classifier_id_ptr ( data_search_result_t *this_ )
168 : {
169 : return &((*this_).src_classifier_id);
170 : }
171 :
172 0 : static inline const data_id_t *data_search_result_get_src_classifier_id_const ( const data_search_result_t *this_ )
173 : {
174 0 : return &((*this_).src_classifier_id);
175 : }
176 :
177 : static inline data_id_t data_search_result_get_dst_classifier_id ( const data_search_result_t *this_ )
178 : {
179 : return (*this_).dst_classifier_id;
180 : }
181 :
182 : static inline data_id_t *data_search_result_get_dst_classifier_id_ptr ( data_search_result_t *this_ )
183 : {
184 : return &((*this_).dst_classifier_id);
185 : }
186 :
187 : static inline const data_id_t *data_search_result_get_dst_classifier_id_const ( const data_search_result_t *this_ )
188 : {
189 : return &((*this_).dst_classifier_id);
190 : }
191 :
192 0 : static inline data_id_t data_search_result_get_diagram_id ( const data_search_result_t *this_ )
193 : {
194 0 : return (*this_).diagram_id;
195 : }
196 :
197 0 : static inline data_id_t *data_search_result_get_diagram_id_ptr ( data_search_result_t *this_ )
198 : {
199 0 : return &((*this_).diagram_id);
200 : }
201 :
202 0 : static inline const data_id_t *data_search_result_get_diagram_id_const ( const data_search_result_t *this_ )
203 : {
204 0 : return &((*this_).diagram_id);
205 : }
206 :
207 0 : static inline void data_search_result_trace ( const data_search_result_t *this_ )
208 : {
209 0 : U8_TRACE_INFO_STR( "- name:", utf8stringbuf_get_string((*this_).match_object_name) );
210 0 : U8_TRACE_INFO_INT( "- type:", (*this_).match_type );
211 0 : data_id_trace( &((*this_).match_object_id) );
212 0 : data_id_trace( &((*this_).src_classifier_id) );
213 0 : data_id_trace( &((*this_).dst_classifier_id) );
214 0 : data_id_trace( &((*this_).diagram_id) );
215 0 : }
216 :
217 :
218 : /*
219 : Copyright 2020-2024 Andreas Warnke
220 :
221 : Licensed under the Apache License, Version 2.0 (the "License");
222 : you may not use this file except in compliance with the License.
223 : You may obtain a copy of the License at
224 :
225 : http://www.apache.org/licenses/LICENSE-2.0
226 :
227 : Unless required by applicable law or agreed to in writing, software
228 : distributed under the License is distributed on an "AS IS" BASIS,
229 : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
230 : See the License for the specific language governing permissions and
231 : limitations under the License.
232 : */
|