LCOV - code coverage report
Current view: top level - ctrl/source - ctrl_controller.c (source / functions) Hit Total Coverage
Test: crystal-facet-uml_v1.57.0_covts Lines: 37 37 100.0 %
Date: 2024-04-07 11:14:42 Functions: 3 3 100.0 %

          Line data    Source code
       1             : /* File: ctrl_controller.c; Copyright and License: see below */
       2             : 
       3             : #include "ctrl_controller.h"
       4             : #include "u8/u8_trace.h"
       5             : #include "u8/u8_log.h"
       6             : 
       7          42 : void ctrl_controller_init ( ctrl_controller_t *this_, data_database_t *database )
       8             : {
       9          42 :     U8_TRACE_BEGIN();
      10             : 
      11             :     /* init member attributes */
      12          42 :     (*this_).database = database;
      13          42 :     data_database_reader_init( &((*this_).db_reader), database );
      14          42 :     data_database_writer_init( &((*this_).db_writer), &((*this_).db_reader), database );
      15          42 :     ctrl_undo_redo_list_init ( &((*this_).undo_redo_list), &((*this_).db_reader), &((*this_).db_writer) );
      16          42 :     consistency_drop_invisibles_init ( &((*this_).consistency_drop_invisibles), &((*this_).db_reader), &((*this_).classifiers), &((*this_).diagrams) );
      17          42 :     consistency_lifeline_init ( &((*this_).consistency_lifeline), &((*this_).db_reader), &((*this_).classifiers), &((*this_).diagrams) );
      18          42 :     ctrl_classifier_trigger_init( &((*this_).classifier_trigger), &((*this_).consistency_drop_invisibles), &((*this_).consistency_lifeline) );
      19          42 :     ctrl_diagram_trigger_init( &((*this_).diagram_trigger), &((*this_).consistency_drop_invisibles), &((*this_).consistency_lifeline) );
      20          42 :     ctrl_classifier_controller_init ( &((*this_).classifiers),
      21             :                                       &((*this_).undo_redo_list),
      22             :                                       &((*this_).classifier_trigger),
      23             :                                       database,
      24             :                                       &((*this_).db_reader),
      25             :                                       &((*this_).db_writer)
      26             :                                     );
      27          42 :     ctrl_diagram_controller_init ( &((*this_).diagrams),
      28             :                                    &((*this_).undo_redo_list),
      29             :                                    &((*this_).diagram_trigger),
      30             :                                    database,
      31             :                                    &((*this_).db_reader),
      32             :                                    &((*this_).db_writer)
      33             :                                  );
      34          42 :     ctrl_consistency_checker_init ( &((*this_).consistency_checker), database, &((*this_).db_reader), &((*this_).db_writer) );
      35             : 
      36             :     /* listen on db open and prepare_close events: */
      37          42 :     data_database_listener_init ( &((*this_).me_as_listener),
      38             :                                   this_,
      39             :                                   (void (*)(void*,data_database_listener_signal_t)) &ctrl_controller_db_change_callback
      40             :                                 );
      41          42 :     data_database_add_db_listener( (*this_).database, &((*this_).me_as_listener) );
      42             : 
      43          42 :     U8_TRACE_END();
      44          42 : }
      45             : 
      46          42 : void ctrl_controller_destroy ( ctrl_controller_t *this_ )
      47             : {
      48          42 :     U8_TRACE_BEGIN();
      49             : 
      50             :     /* stop listening on db open and prepare_close events: */
      51          42 :     data_database_remove_db_listener( (*this_).database, &((*this_).me_as_listener) );
      52             : 
      53             :     /* destroy member attributes */
      54          42 :     ctrl_classifier_trigger_destroy( &((*this_).classifier_trigger) );
      55          42 :     ctrl_diagram_trigger_destroy( &((*this_).diagram_trigger) );
      56          42 :     ctrl_consistency_checker_destroy ( &((*this_).consistency_checker) );
      57          42 :     ctrl_diagram_controller_destroy ( &((*this_).diagrams) );
      58          42 :     ctrl_classifier_controller_destroy ( &((*this_).classifiers) );
      59          42 :     consistency_lifeline_destroy ( &((*this_).consistency_lifeline) );
      60          42 :     consistency_drop_invisibles_destroy ( &((*this_).consistency_drop_invisibles) );
      61          42 :     ctrl_undo_redo_list_destroy ( &((*this_).undo_redo_list) );
      62          42 :     data_database_writer_destroy( &((*this_).db_writer) );
      63          42 :     data_database_reader_destroy( &((*this_).db_reader) );
      64             : 
      65          42 :     U8_TRACE_END();
      66          42 : }
      67             : 
      68             : /* ================================ interface for database file ================================ */
      69             : 
      70           6 : void ctrl_controller_db_change_callback ( ctrl_controller_t *this_, data_database_listener_signal_t signal_id )
      71             : {
      72           6 :     U8_TRACE_BEGIN();
      73             : 
      74             :     /* for any db event, clear the undo history */
      75           6 :     ctrl_undo_redo_list_clear( &((*this_).undo_redo_list) );
      76             : 
      77           6 :     U8_TRACE_END();
      78           6 : }
      79             : 
      80             : 
      81             : /*
      82             : Copyright 2016-2024 Andreas Warnke
      83             : 
      84             : Licensed under the Apache License, Version 2.0 (the "License");
      85             : you may not use this file except in compliance with the License.
      86             : You may obtain a copy of the License at
      87             : 
      88             :     http://www.apache.org/licenses/LICENSE-2.0
      89             : 
      90             : Unless required by applicable law or agreed to in writing, software
      91             : distributed under the License is distributed on an "AS IS" BASIS,
      92             : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      93             : See the License for the specific language governing permissions and
      94             : limitations under the License.
      95             : */

Generated by: LCOV version 1.16