Line data Source code
1 : /* File: data_relationship.inl; Copyright and License: see below */
2 :
3 : #include "entity/data_id.h"
4 : #include <assert.h>
5 :
6 55 : static inline void data_relationship_init_empty ( data_relationship_t *this_ )
7 : {
8 55 : (*this_).id = DATA_ROW_ID_VOID;
9 55 : (*this_).from_classifier_id = DATA_ROW_ID_VOID;
10 55 : (*this_).from_feature_id = DATA_ROW_ID_VOID;
11 55 : (*this_).to_classifier_id = DATA_ROW_ID_VOID;
12 55 : (*this_).to_feature_id = DATA_ROW_ID_VOID;
13 55 : (*this_).main_type = DATA_RELATIONSHIP_TYPE_UML_DEPENDENCY;
14 :
15 55 : (*this_).stereotype = utf8stringbuf_init( sizeof((*this_).private_stereotype_buffer), (*this_).private_stereotype_buffer );
16 55 : utf8stringbuf_clear( (*this_).stereotype );
17 55 : (*this_).name = utf8stringbuf_init( sizeof((*this_).private_name_buffer), (*this_).private_name_buffer );
18 55 : utf8stringbuf_clear( (*this_).name );
19 55 : (*this_).description = utf8stringbuf_init( sizeof((*this_).private_description_buffer), (*this_).private_description_buffer );
20 55 : utf8stringbuf_clear( (*this_).description );
21 :
22 55 : (*this_).list_order = 0;
23 55 : data_uuid_init_new( &((*this_).uuid) );
24 55 : }
25 :
26 1 : static inline void data_relationship_reinit_empty ( data_relationship_t *this_ )
27 : {
28 : /* data_relationship_destroy( this_ ); -- not necessary */
29 1 : data_relationship_init_empty( this_ );
30 1 : }
31 :
32 2 : static inline u8_error_t data_relationship_init_new ( data_relationship_t *this_,
33 : data_row_id_t from_classifier_id,
34 : data_row_id_t from_feature_id,
35 : data_row_id_t to_classifier_id,
36 : data_row_id_t to_feature_id,
37 : data_relationship_type_t relationship_main_type,
38 : const char* stereotype,
39 : const char* name,
40 : const char* description,
41 : int32_t list_order)
42 : {
43 2 : assert( NULL != stereotype );
44 2 : assert( NULL != name );
45 2 : assert( NULL != description );
46 : utf8error_t strerr;
47 2 : u8_error_t result = U8_ERROR_NONE;
48 :
49 2 : (*this_).id = DATA_ROW_ID_VOID;
50 2 : (*this_).from_classifier_id = from_classifier_id;
51 2 : (*this_).from_feature_id = from_feature_id;
52 2 : (*this_).to_classifier_id = to_classifier_id;
53 2 : (*this_).to_feature_id = to_feature_id;
54 2 : (*this_).main_type = relationship_main_type;
55 :
56 2 : (*this_).stereotype = utf8stringbuf_init( sizeof((*this_).private_stereotype_buffer), (*this_).private_stereotype_buffer );
57 2 : strerr = utf8stringbuf_copy_str( (*this_).stereotype, stereotype );
58 2 : if ( strerr != UTF8ERROR_SUCCESS )
59 : {
60 1 : U8_LOG_ERROR_INT( "utf8stringbuf_copy_str() failed:", strerr );
61 1 : result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
62 : }
63 :
64 2 : (*this_).name = utf8stringbuf_init( sizeof((*this_).private_name_buffer), (*this_).private_name_buffer );
65 2 : strerr = utf8stringbuf_copy_str( (*this_).name, name );
66 2 : if ( strerr != UTF8ERROR_SUCCESS )
67 : {
68 1 : U8_LOG_ERROR_HEX( "utf8stringbuf_copy_str() failed:", strerr );
69 1 : result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
70 : }
71 :
72 2 : (*this_).description = utf8stringbuf_init( sizeof((*this_).private_description_buffer), (*this_).private_description_buffer );
73 2 : strerr = utf8stringbuf_copy_str( (*this_).description, description );
74 2 : if ( strerr != UTF8ERROR_SUCCESS )
75 : {
76 1 : U8_LOG_ERROR_HEX( "utf8stringbuf_copy_str() failed:", strerr );
77 1 : result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
78 : }
79 :
80 2 : (*this_).list_order = list_order;
81 2 : data_uuid_init_new( &((*this_).uuid) );
82 :
83 2 : return result;
84 : }
85 :
86 8810 : static inline u8_error_t data_relationship_init ( data_relationship_t *this_,
87 : data_row_id_t relationship_id,
88 : data_row_id_t from_classifier_id,
89 : data_row_id_t from_feature_id,
90 : data_row_id_t to_classifier_id,
91 : data_row_id_t to_feature_id,
92 : data_relationship_type_t relationship_main_type,
93 : const char* stereotype,
94 : const char* name,
95 : const char* description,
96 : int32_t list_order,
97 : const char* uuid )
98 : {
99 8810 : assert( NULL != stereotype );
100 8810 : assert( NULL != name );
101 8810 : assert( NULL != description );
102 8810 : assert( NULL != uuid );
103 : utf8error_t strerr;
104 8810 : u8_error_t result = U8_ERROR_NONE;
105 :
106 8810 : (*this_).id = relationship_id;
107 8810 : (*this_).from_classifier_id = from_classifier_id;
108 8810 : (*this_).from_feature_id = from_feature_id;
109 8810 : (*this_).to_classifier_id = to_classifier_id;
110 8810 : (*this_).to_feature_id = to_feature_id;
111 8810 : (*this_).main_type = relationship_main_type;
112 :
113 8810 : (*this_).stereotype = utf8stringbuf_init( sizeof((*this_).private_stereotype_buffer), (*this_).private_stereotype_buffer );
114 8810 : strerr = utf8stringbuf_copy_str( (*this_).stereotype, stereotype );
115 8810 : if ( strerr != UTF8ERROR_SUCCESS )
116 : {
117 1 : U8_LOG_ERROR_HEX( "utf8stringbuf_copy_str() failed:", strerr );
118 1 : result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
119 : }
120 :
121 8810 : (*this_).name = utf8stringbuf_init( sizeof((*this_).private_name_buffer), (*this_).private_name_buffer );
122 8810 : strerr = utf8stringbuf_copy_str( (*this_).name, name );
123 8810 : if ( strerr != UTF8ERROR_SUCCESS )
124 : {
125 1 : U8_LOG_ERROR_HEX( "utf8stringbuf_copy_str() failed:", strerr );
126 1 : result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
127 : }
128 :
129 8810 : (*this_).description = utf8stringbuf_init( sizeof((*this_).private_description_buffer), (*this_).private_description_buffer );
130 8810 : strerr = utf8stringbuf_copy_str( (*this_).description, description );
131 8810 : if ( strerr != UTF8ERROR_SUCCESS )
132 : {
133 1 : U8_LOG_ERROR_HEX( "utf8stringbuf_copy_str() failed:", strerr );
134 1 : result |= U8_ERROR_STRING_BUFFER_EXCEEDED;
135 : }
136 :
137 8810 : (*this_).list_order = list_order;
138 8810 : result |= data_uuid_init( &((*this_).uuid), uuid );
139 :
140 8810 : return result;
141 : }
142 :
143 1053 : static inline void data_relationship_copy ( data_relationship_t *this_, const data_relationship_t *original )
144 : {
145 1053 : assert( NULL != original );
146 :
147 1053 : (*this_) = (*original);
148 : /* repair the overwritten pointers */
149 1053 : (*this_).stereotype = utf8stringbuf_init( sizeof((*this_).private_stereotype_buffer), (*this_).private_stereotype_buffer );
150 1053 : (*this_).name = utf8stringbuf_init( sizeof((*this_).private_name_buffer), (*this_).private_name_buffer );
151 1053 : (*this_).description = utf8stringbuf_init( sizeof((*this_).private_description_buffer), (*this_).private_description_buffer );
152 1053 : data_uuid_copy( &((*this_).uuid), &((*original).uuid) );
153 1053 : }
154 :
155 31 : static inline void data_relationship_replace ( data_relationship_t *this_, const data_relationship_t *that )
156 : {
157 31 : assert( NULL != that );
158 :
159 31 : (*this_) = (*that);
160 : /* repair the overwritten pointers */
161 31 : (*this_).stereotype = utf8stringbuf_init( sizeof((*this_).private_stereotype_buffer), (*this_).private_stereotype_buffer );
162 31 : (*this_).name = utf8stringbuf_init( sizeof((*this_).private_name_buffer), (*this_).private_name_buffer );
163 31 : (*this_).description = utf8stringbuf_init( sizeof((*this_).private_description_buffer), (*this_).private_description_buffer );
164 31 : data_uuid_replace( &((*this_).uuid), &((*that).uuid) );
165 31 : }
166 :
167 3406 : static inline void data_relationship_destroy ( data_relationship_t *this_ )
168 : {
169 3406 : (*this_).id = DATA_ROW_ID_VOID;
170 3406 : data_uuid_destroy( &((*this_).uuid) );
171 3406 : }
172 :
173 529024 : static inline data_row_id_t data_relationship_get_row_id ( const data_relationship_t *this_ )
174 : {
175 529024 : return (*this_).id;
176 : }
177 :
178 43 : static inline void data_relationship_set_row_id ( data_relationship_t *this_, data_row_id_t id )
179 : {
180 43 : (*this_).id = id;
181 43 : }
182 :
183 6 : static inline data_id_t data_relationship_get_data_id ( const data_relationship_t *this_ )
184 : {
185 : data_id_t result;
186 6 : data_id_init ( &result, DATA_TABLE_RELATIONSHIP, (*this_).id );
187 6 : return result;
188 : }
189 :
190 10093 : static inline data_row_id_t data_relationship_get_from_classifier_row_id ( const data_relationship_t *this_ )
191 : {
192 10093 : return (*this_).from_classifier_id;
193 : }
194 :
195 22 : static inline void data_relationship_set_from_classifier_row_id ( data_relationship_t *this_, data_row_id_t from_classifier_id )
196 : {
197 22 : (*this_).from_classifier_id = from_classifier_id;
198 22 : }
199 :
200 1 : static inline data_id_t data_relationship_get_from_classifier_data_id ( const data_relationship_t *this_ )
201 : {
202 : data_id_t result;
203 1 : data_id_init ( &result, DATA_TABLE_CLASSIFIER, (*this_).from_classifier_id );
204 1 : return result;
205 : }
206 :
207 7759 : static inline data_row_id_t data_relationship_get_from_feature_row_id ( const data_relationship_t *this_ )
208 : {
209 7759 : return (*this_).from_feature_id;
210 : }
211 :
212 1323 : static inline void data_relationship_set_from_feature_row_id ( data_relationship_t *this_, data_row_id_t from_feature_id )
213 : {
214 1323 : (*this_).from_feature_id = from_feature_id;
215 1323 : }
216 :
217 1 : static inline data_id_t data_relationship_get_from_feature_data_id ( const data_relationship_t *this_ )
218 : {
219 : data_id_t result;
220 1 : data_id_init ( &result, DATA_TABLE_FEATURE, (*this_).from_feature_id );
221 1 : return result;
222 : }
223 :
224 8766 : static inline data_row_id_t data_relationship_get_to_classifier_row_id ( const data_relationship_t *this_ )
225 : {
226 8766 : return (*this_).to_classifier_id;
227 : }
228 :
229 22 : static inline void data_relationship_set_to_classifier_row_id ( data_relationship_t *this_, data_row_id_t to_classifier_id )
230 : {
231 22 : (*this_).to_classifier_id = to_classifier_id;
232 22 : }
233 :
234 1 : static inline data_id_t data_relationship_get_to_classifier_data_id ( const data_relationship_t *this_ )
235 : {
236 : data_id_t result;
237 1 : data_id_init ( &result, DATA_TABLE_CLASSIFIER, (*this_).to_classifier_id );
238 1 : return result;
239 : }
240 :
241 7762 : static inline data_row_id_t data_relationship_get_to_feature_row_id ( const data_relationship_t *this_ )
242 : {
243 7762 : return (*this_).to_feature_id;
244 : }
245 :
246 1314 : static inline void data_relationship_set_to_feature_row_id ( data_relationship_t *this_, data_row_id_t to_feature_id )
247 : {
248 1314 : (*this_).to_feature_id = to_feature_id;
249 1314 : }
250 :
251 1 : static inline data_id_t data_relationship_get_to_feature_data_id ( const data_relationship_t *this_ )
252 : {
253 : data_id_t result;
254 1 : data_id_init ( &result, DATA_TABLE_FEATURE, (*this_).to_feature_id );
255 1 : return result;
256 : }
257 :
258 8546 : static inline data_relationship_type_t data_relationship_get_main_type ( const data_relationship_t *this_ )
259 : {
260 8546 : return (*this_).main_type;
261 : }
262 :
263 15 : static inline void data_relationship_set_main_type ( data_relationship_t *this_, data_relationship_type_t main_type )
264 : {
265 15 : (*this_).main_type = main_type;
266 15 : }
267 :
268 1343 : static inline const char *data_relationship_get_stereotype_const ( const data_relationship_t *this_ )
269 : {
270 1343 : return utf8stringbuf_get_string( (*this_).stereotype );
271 : }
272 :
273 3 : static inline bool data_relationship_has_stereotype ( const data_relationship_t *this_ )
274 : {
275 3 : return ( ! utf8stringbuf_equals_str( (*this_).stereotype, "" ) );
276 : }
277 :
278 3 : static inline u8_error_t data_relationship_set_stereotype ( data_relationship_t *this_, const char *stereotype )
279 : {
280 3 : assert( NULL != stereotype );
281 :
282 3 : u8_error_t result = U8_ERROR_NONE;
283 : utf8error_t strerr;
284 3 : strerr = utf8stringbuf_copy_str( (*this_).stereotype, stereotype );
285 3 : if ( strerr != UTF8ERROR_SUCCESS )
286 : {
287 1 : U8_LOG_ERROR_HEX( "utf8stringbuf_copy_str() failed:", strerr );
288 1 : result = U8_ERROR_STRING_BUFFER_EXCEEDED;
289 : }
290 3 : return result;
291 : }
292 :
293 1342 : static inline const char *data_relationship_get_name_const ( const data_relationship_t *this_ )
294 : {
295 1342 : return utf8stringbuf_get_string( (*this_).name );
296 : }
297 :
298 16 : static inline u8_error_t data_relationship_set_name ( data_relationship_t *this_, const char *name )
299 : {
300 16 : assert( NULL != name );
301 16 : u8_error_t result = U8_ERROR_NONE;
302 : utf8error_t strerr;
303 16 : strerr = utf8stringbuf_copy_str( (*this_).name, name );
304 16 : if ( strerr != UTF8ERROR_SUCCESS )
305 : {
306 1 : U8_LOG_ERROR_HEX( "utf8stringbuf_copy_str() failed:", strerr );
307 1 : result = U8_ERROR_STRING_BUFFER_EXCEEDED;
308 : }
309 16 : return result;
310 : }
311 :
312 1345 : static inline const char *data_relationship_get_description_const ( const data_relationship_t *this_ )
313 : {
314 1345 : return utf8stringbuf_get_string( (*this_).description );
315 : }
316 :
317 17 : static inline u8_error_t data_relationship_set_description ( data_relationship_t *this_, const char *description )
318 : {
319 17 : assert( NULL != description );
320 17 : u8_error_t result = U8_ERROR_NONE;
321 : utf8error_t strerr;
322 17 : strerr = utf8stringbuf_copy_str( (*this_).description, description );
323 17 : if ( strerr != UTF8ERROR_SUCCESS )
324 : {
325 1 : U8_LOG_ERROR_HEX( "utf8stringbuf_copy_str() failed:", strerr );
326 1 : result = U8_ERROR_STRING_BUFFER_EXCEEDED;
327 : }
328 17 : return result;
329 : }
330 :
331 2 : static inline u8_error_t data_relationship_append_description ( data_relationship_t *this_, const char *description )
332 : {
333 2 : assert( NULL != description );
334 2 : u8_error_t result = U8_ERROR_NONE;
335 : utf8error_t strerr;
336 2 : strerr = utf8stringbuf_append_str( (*this_).description, description );
337 2 : if ( strerr != UTF8ERROR_SUCCESS )
338 : {
339 1 : U8_LOG_ERROR_HEX( "utf8stringbuf_append_str() failed:", strerr );
340 1 : result = U8_ERROR_STRING_BUFFER_EXCEEDED;
341 : }
342 2 : return result;
343 : }
344 :
345 1340 : static inline int32_t data_relationship_get_list_order ( const data_relationship_t *this_ )
346 : {
347 1340 : return (*this_).list_order;
348 : }
349 :
350 15 : static inline void data_relationship_set_list_order ( data_relationship_t *this_, int32_t list_order )
351 : {
352 15 : (*this_).list_order = list_order;
353 15 : }
354 :
355 1353 : static inline const char *data_relationship_get_uuid_const ( const data_relationship_t *this_ )
356 : {
357 1353 : return data_uuid_get_string( &((*this_).uuid) );
358 : }
359 :
360 11 : static inline u8_error_t data_relationship_set_uuid ( data_relationship_t *this_, const char *uuid )
361 : {
362 11 : assert( NULL != uuid );
363 :
364 11 : const u8_error_t result = data_uuid_reinit( &((*this_).uuid), uuid );
365 :
366 11 : return result;
367 : }
368 :
369 11579 : static inline bool data_relationship_is_valid ( const data_relationship_t *this_ )
370 : {
371 11579 : return ( DATA_ROW_ID_VOID != (*this_).id );
372 : }
373 :
374 1326 : static inline void data_relationship_trace ( const data_relationship_t *this_ )
375 : {
376 1326 : U8_TRACE_INFO( "data_relationship_t" );
377 1326 : U8_TRACE_INFO_INT( "- id:", (*this_).id );
378 1326 : U8_TRACE_INFO_INT( "- from_classifier_id:", (*this_).from_classifier_id );
379 1326 : U8_TRACE_INFO_INT( "- from_feature_id:", (*this_).from_feature_id );
380 1326 : U8_TRACE_INFO_INT( "- to_classifier_id:", (*this_).to_classifier_id );
381 1326 : U8_TRACE_INFO_INT( "- to_feature_id:", (*this_).to_feature_id );
382 1326 : U8_TRACE_INFO_INT( "- main_type:", (*this_).main_type );
383 1326 : U8_TRACE_INFO_STR( "- stereotype:", utf8stringbuf_get_string((*this_).stereotype) );
384 1326 : U8_TRACE_INFO_STR( "- name:", utf8stringbuf_get_string((*this_).name) );
385 1326 : U8_TRACE_INFO_STR( "- description:", utf8stringbuf_get_string((*this_).description) );
386 1326 : U8_TRACE_INFO_INT( "- list_order:", (*this_).list_order );
387 1326 : U8_TRACE_INFO_STR( "- uuid:", data_uuid_get_string( &((*this_).uuid) ) );
388 1326 : }
389 :
390 :
391 : /*
392 : Copyright 2016-2024 Andreas Warnke
393 :
394 : Licensed under the Apache License, Version 2.0 (the "License");
395 : you may not use this file except in compliance with the License.
396 : You may obtain a copy of the License at
397 :
398 : http://www.apache.org/licenses/LICENSE-2.0
399 :
400 : Unless required by applicable law or agreed to in writing, software
401 : distributed under the License is distributed on an "AS IS" BASIS,
402 : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
403 : See the License for the specific language governing permissions and
404 : limitations under the License.
405 : */
|