Line data Source code
1 : /* File: consistency_classifier.c; Copyright and License: see below */
2 :
3 : #include "consistency/consistency_classifier.h"
4 : #include "ctrl_classifier_controller.h"
5 : #include "ctrl_diagram_controller.h"
6 : #include "u8/u8_trace.h"
7 : #include "u8/u8_log.h"
8 :
9 47 : void consistency_classifier_init( consistency_classifier_t *this_,
10 : data_database_reader_t *db_reader,
11 : struct ctrl_classifier_controller_struct *clfy_ctrl )
12 : {
13 47 : U8_TRACE_BEGIN();
14 47 : assert( NULL != db_reader );
15 47 : assert( NULL != clfy_ctrl );
16 :
17 47 : (*this_).db_reader = db_reader;
18 47 : (*this_).clfy_ctrl = clfy_ctrl;
19 :
20 47 : U8_TRACE_END();
21 47 : }
22 :
23 47 : void consistency_classifier_destroy( consistency_classifier_t *this_ )
24 : {
25 47 : U8_TRACE_BEGIN();
26 :
27 47 : (*this_).db_reader = NULL;
28 47 : (*this_).clfy_ctrl = NULL;
29 :
30 47 : U8_TRACE_END();
31 47 : }
32 :
33 9 : u8_error_t consistency_classifier_delete_unreferenced_classifier( consistency_classifier_t *this_,
34 : const data_diagramelement_t *deleted_diagramelement,
35 : consistency_stat_t *io_stat )
36 : {
37 9 : U8_TRACE_BEGIN();
38 9 : assert( NULL != deleted_diagramelement );
39 9 : assert( NULL != io_stat );
40 9 : u8_error_t result = U8_ERROR_NONE;
41 :
42 : /* try to also delete the classifier, ignore errors because it is ok if the classifier is still referenced */
43 : u8_error_t delete_err;
44 :
45 9 : delete_err = ctrl_classifier_controller_delete_classifier( (*this_).clfy_ctrl,
46 : data_diagramelement_get_classifier_row( deleted_diagramelement ),
47 : CTRL_UNDO_REDO_ACTION_BOUNDARY_APPEND,
48 : io_stat
49 : );
50 :
51 9 : if ( u8_error_contains( delete_err, U8_ERROR_OBJECT_STILL_REFERENCED ) )
52 : {
53 6 : U8_LOG_EVENT( "The classifier cannot be deleted because it is still referenced." );
54 : }
55 : else
56 : {
57 : /* report whatever error */
58 3 : result |= delete_err;
59 : }
60 :
61 9 : U8_TRACE_END_ERR( result );
62 9 : return result;
63 : }
64 :
65 :
66 : /*
67 : Copyright 2018-2026 Andreas Warnke
68 :
69 : Licensed under the Apache License, Version 2.0 (the "License");
70 : you may not use this file except in compliance with the License.
71 : You may obtain a copy of the License at
72 :
73 : http://www.apache.org/licenses/LICENSE-2.0
74 :
75 : Unless required by applicable law or agreed to in writing, software
76 : distributed under the License is distributed on an "AS IS" BASIS,
77 : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
78 : See the License for the specific language governing permissions and
79 : limitations under the License.
80 : */
|