diff --git a/docs/doxyfile b/docs/doxyfile index 9a8f100..bffbc20 100644 --- a/docs/doxyfile +++ b/docs/doxyfile @@ -403,7 +403,7 @@ MARKDOWN_ID_STYLE = DOXYGEN # globally by setting AUTOLINK_SUPPORT to NO. # The default value is: YES. -AUTOLINK_SUPPORT = YES +AUTOLINK_SUPPORT = NO # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want # to include (a tag file for) the STL sources as input, then you should set this @@ -565,7 +565,7 @@ EXTRACT_PACKAGE = NO # included in the documentation. # The default value is: NO. -EXTRACT_STATIC = NO +EXTRACT_STATIC = YES # If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined # locally in source files will be included in the documentation. If set to NO, @@ -573,7 +573,7 @@ EXTRACT_STATIC = NO # for Java sources. # The default value is: YES. -EXTRACT_LOCAL_CLASSES = YES +EXTRACT_LOCAL_CLASSES = NO # This flag is only useful for Objective-C code. If set to YES, local methods, # which are defined in the implementation section but not in the interface are @@ -614,7 +614,7 @@ HIDE_UNDOC_MEMBERS = NO # if EXTRACT_ALL is enabled. # The default value is: NO. -HIDE_UNDOC_CLASSES = NO +HIDE_UNDOC_CLASSES = YES # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend # declarations. If set to NO, these declarations will be included in the diff --git a/docs/readme b/docs/readme index 7e7cdeb..04ae548 100644 --- a/docs/readme +++ b/docs/readme @@ -24,7 +24,8 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - +This dossier gives you information on how to make the best use of doc. +(a few tips for personalising it) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * diff --git a/docs/rtfm/Once upon a time, b/docs/rtfm/Once upon a time, index 7002086..c328283 100644 --- a/docs/rtfm/Once upon a time, +++ b/docs/rtfm/Once upon a time, @@ -1,8 +1,8 @@ Welcome to Gem-graph ! -Gem-graph lets you move or transform drawn objects and can be used in all cases where drawings, designs or patterns are useful. You can draw anything you like. You can make it move or transform as you like. It is your design and you decide how you want it to evolve! You can use it to make a game. You can use it to make an animated representation (a model) of a phenomenon that interests you. You can represent what you want simply or in more realistic detail. Simple parts and more detailed parts can coexist in the same design. You can watch what you have created evolve without interfering or guiding it towards what you want to achieve. You can observe it in detail, go back, start again, measure, compare and keep the results that interest you so that you can play them again. +Gem-graph lets you move or transform objects drawn using an automaton. It can be used when drawings, patterns or templates are the simplest description tools and it is useful to work on modifying them. You can draw anything you like. You can make it move or transform as you like. It is your design and you decide how you want it to evolve! You can use it to make a game. You can use it to make an animated representation (a model) of a phenomenon that interests you. You can represent what you want simply or in more realistic detail. Simple parts and more detailed parts can coexist in the same design. You can watch what you have created evolve without interfering or guiding it towards what you want to achieve. You can mix several drawings and animations. You can observe them in detail, go back, start again, measure, compare and keep the results that interest you so that you can play them again. -However, a certain amount of effort may be required to achieve the desired results. A complicated model will require more work than a simpler one, but it is possible to start with something simple and develop it step by step. In any case, you must draw what you want to see and say how you want it to move. Gem-graph cannot do that for you. Gem-graph can only help you to draw up and develop your idea. However, it can give you powerful tools to do so. All this is possible because the drawings that gem-graph manipulates are made up of very simple elements, all similar, driven by simple rules that can therefore be processed automatically. The tools provided by gem-graph give you access to the power of the automaton it uses to draw and animate your drawings, and this manual is here to help you to learn how to master them. +However, a certain amount of effort may be required to achieve this. A complicated model will require more work than a simpler one, but it is possible to start with something simple and develop it step by step. In any case, you must draw what you want to see and say how you want it to move. Gem-graph cannot do that for you. Gem-graph can only help you to draw up and develop your idea. However, it can give you powerful tools to do so. All this is possible because the drawings that gem-graph manipulates are made up of very simple elements, all similar, driven by simple rules that can therefore be processed automatically. The tools provided by gem-graph give you access to the power of the automaton it uses to draw and animate your drawings, and this manual is here to help you to learn how to master them. One way of doing this is to reproduce a very simple example, such as when a word processing program asks you to write "Hello world". For gem-graph, the equivalent of "Hello world" will be to move a small line on your screen. Once you have done this simple example, you will know enough to quickly build and animate much more complex drawings that suit your desires. If you like learning this way, this example is explained (here). If you prefer to learn by reading what the commands you see on the screen are doing, they have been detailed (here). The table of contents goes from the simplest to the most complicated. How to set up a simple model, observe it and measure what it does, then transform it by changing what you see and how it reacts. @@ -24,11 +24,19 @@ Once you know how to write a state and a rule, you can write thousands of them: ------------ -A final simple example shows how a single rule can be applied to a multitude of states. The rule is the same as for the first model: an arrow can only be moved one square forward, but this time you have to check that the square forward is free. If it isn't, the arrow won't move. And this time, the space contains a multitude of arrows that have been randomly placed all over the place (see details here). -When you open this model, you see a multitude of small lines, all similar, some vertical, some horizontal, placed on a grid. When you set the model in motion, you see these little lines moving from left to right if they are horizontal, and up and down if they are vertical (a second rule vas added to do that). Their number is constant. They don't change shape or direction. There seems to be no accident when they cross. Nothing else happens. +The next example shows how single rules can be applied to a multitude of states. The rule is almost the same as for the first model: an arrow can only be moved one square forward, but this time you have to check that the square forward is free. If it isn't, the arrow won't move. Once the rule has been modified in this way, it can be applied to a multitude of arrows distributed randomly in space. (see details here). +When you set the model in motion, you will see all these small lines moving from left to right. A single rule is responsible for all these movements. +For a small fee, we can apply the rules of the 'random walk' model to all the arrows distributed in this space, and they will then all behave in the same way, sometimes moving forwards, sometimes backwards. ------------ -These five examples give an initial idea of the diversity of possible models and the operations that can be performed on them. +The last example in this series aims to give an initial impression of a more complex system and how it can be controlled. +We add again to the previous state a multitude of arrows distributed randomly in space but, this time, they are vertical. And we add two more rules, very similar to those of the random walk but oriented up and down instead of right and left. +When you set this model in motion, you see these little lines moving from left to right or reverse if they are horizontal, and up and down or reverse if they are vertical. Their number is constant. They don't change shape or direction. There seems to be no accident when they cross. Nothing else happens. + +------------ + +These examples give an initial idea of the diversity of possible models and the operations that can be performed on them. + diff --git a/include/fsm.h b/include/fsm.h index e08b294..7e6654f 100644 --- a/include/fsm.h +++ b/include/fsm.h @@ -1,18 +1,29 @@ /** * @file - * Fsm (finite state machine) header + * Client fsm (finite state machine) header * * This file is part of Gem-graph. * * - * This commit introduces the functions that the log needs. + * This commit introduces: + * + * - the two functions that enable main() to init and close the log: + * fsm_trigger_log_init() and fsm_trigger_log_close() + * + * - the two functions that enable main() to init and close the fsm: + * fsm_init() and fsm_close() + * + * - the two functions that enable the fsm to init and close its structures: + * fsm_structures_init() and fsm_structures_close() + * + * * @see readme.docs and this text below. * * --- * - * The two structures and the two enums listed below will stay in the fsm header. + * The two log structures and the two enums listed below stay in the fsm header. * - * All functions are now in dedicated files. + * All log functions are now in dedicated files. * * The most important function: fsm_add_log() is in the file: * /src/fsm/log/manager.c @@ -104,7 +115,7 @@ * https://en.wikipedia.org/wiki/Syslog * * All logs must contain at least one item from this enum and only one. - * This item can not be set to NULL. + * This item can NOT be set to NULL. * * @see fsm_add_log() */ @@ -238,10 +249,16 @@ long fsm_remove_log (fsm_log_struct *jj, const char *function_source, const char *string_value); -void fsm_add_log (int severity, - int source, - const char *file_source, - const char *function_source, - const char *string_value); +void fsm_add_log (int severity, + int source, + const char *file_source, + const char *function_source, + const char *string_value); + +void fsm_trigger_log_init(); +void fsm_trigger_log_close(); + +void fsm_init (const char *initial_message_from_main); +void fsm_close (const char *final_message_from_main); diff --git a/src/fsm/control.c b/src/fsm/control.c new file mode 100644 index 0000000..d687100 --- /dev/null +++ b/src/fsm/control.c @@ -0,0 +1,214 @@ +/** + * @file + * Client fsm (Finite State Machine) control file. + * + * --- + * + * The fsm control instance + * - **initialises** the log and the rest of the fsm when triggered by main() + * - **checks** all triggered operations and **allocates** them if they are valid + * - **closes** all the elements it opened before handing over to main() + * . + * + * About code organization, see src/readme.dox + * + * --- + * + * @cond LICENSE + * Copyright © 2021 Libre en Communs + * Copyright © 2021-2024 Adrien Bourmault + * Copyright © 2021-2024 Jean Sirmai + * + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU Affero General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) any + * later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more + * details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * @endcond + * + * @file + * @brief + * + * This file is part of Gem-graph. + * + * @details + * The Finite State Machine (fsm) describes all the possible states of the + * Gem-graph client and all the transitions between them. + * It manages several kinds of exclusive states: + * - Run the model or edit it. + * - Select a single view of the model from all those possible. + * The different views show either the space, or the rule tree, + * or a single rule of interest, or measurements or results. + * NB an overview is possible, but it does not provide details. + * - Apply a selected measurement to the currently running model + * - Select some results for study or/and presentation. + * - Choose the user's preferred values for a set of parameters + * used to modify the appearance or behaviour of gem-graph. + * + * Each state of the fsm is a combination of each of these states. + * + * The current state of the fsm must be + * - saved at the end of a work session and + * - reread (available to the user) at the start of a new session. + * + * No state of the fsm should be defined in another module. + * + * No fsm transition should be executed in another module. + * + * The journal is created, edited and published from here. + * + * @cond LICENSE + * Copyright © 2021 Libre en Communs + * Copyright © 2021-2024 Adrien Bourmault + * Copyright © 2021-2024 Jean Sirmai + * + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU Affero General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) any + * later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more + * details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * @endcond + */ + + +#include "../../include/fsm.h" + + +/** + * Initiates the four lists: + * 'measures', 'results', 'displayables results' and 'preferences'. + * The items selected in these lists contribute to define the current state of + * the fsm. + * The exact number and status of the structures of the fsm are still being + * assessed. + * + * @callergraph + * @see fsm_init() + */ +static void fsm_structures_init() +{ +/**< will be introduced later on: + + fsm_add_log (info, FSM, "fsm/dispatch", "measures list init()", + "measurement processes"); + fsm_list_init_measures(); + + fsm_add_log (info, FSM, "fsm/dispatch", "results list init()", + "measurement results (gross)"); + fsm_list_init_results(); + + fsm_add_log (info, FSM, "fsm/dispatch", "displayables list init()", + "displayable results"); + fsm_list_init_displayables(); + + fsm_add_log (info, FSM, "fsm/dispatch", "preferences list init()", + "preferences"); + fsm_list_init_preferences(); +*/ +} + + +/** + * Closes the four lists: + * 'measures', 'results', 'displayables results' and 'preferences'. + * The items selected in these lists contribute to define the current state of + * the fsm. + * The exact number and status of the structures of the fsm are still being + * assessed. + * + * @callergraph + * @see fsm_close() + */ +static void fsm_structures_close() +{ +/**< ? */ +} + + +/** + * @brief fsm_init() is the first function called by main.c + * It initiates the journal and calls fsm_structures_init() that + * + * @since 2024-08 + * + * @callergraph + * @see main() + * + * @callgraph + * @see trigger_fsm_log_init() + * @see fsm_add_log() + * @see fsm_list_init_measures() + * @see fsm_list_init_results() + * @see fsm_list_init_displayables() + * @see fsm_list_init_preferences() + * + * @param *initial_info_from_main + */ +void fsm_init (const char *initial_info_from_main) +{ + fsm_trigger_log_init(); /**< fsm_init_log(() can't be called from here + * because static fsm_log_struct gg_logs + * is in src/fsm/log/manager.c */ + + fsm_add_log (INFO, MAIN, "main", initial_info_from_main, + "👋️ (☕️) Hi everybody ! Here is Gem-Graph."); + + fsm_add_log (INFO, FSM, "fsm/control", "fsm initialisation", "has began ✍️"); + fsm_structures_init(); + fsm_add_log (INFO, FSM, "fsm/control", "fsm initialisation", "has ended 😇️"); +} + +/** + * @brief fsm_close() is the last function called by main.c It closes all that + * was opened in reverse order before handing over to main(). + * + * @details It ensures the fsm state is saved: + * - preferences + * - model + * + * Then it closes the four lists: + * - 'measures', + * - 'results', + * - 'displayables results' and + * - 'preferences'. + * and closes the journal + * + * @since 2024-08 + * + * @callergraph + * @see main() + * + * @callgraph + * @see fsm_structures_close() + * @see fsm_trigger_log_close() + * @see fsm_add_log() + * + * @param *closing_info_from_main + */ +void fsm_close (const char *closing_info_from_main) +{ + fsm_add_log (INFO, FSM, "fsm/control", "fsm closing", "has began"); + fsm_structures_close(); + fsm_add_log (INFO, FSM, "fsm/control", "fsm closing", "has ended"); + + fsm_add_log (INFO, MAIN, "main", closing_info_from_main, + "👋️😄️ That'all folks !"); + + fsm_trigger_log_close(); /**< fsm_clear_log(() can't be called from here + * because static fsm_log_struct gg_logs + * is in src/fsm/log/manager.c */ +} diff --git a/src/fsm/log/manager.c b/src/fsm/log/manager.c index 334fdae..8b668bf 100644 --- a/src/fsm/log/manager.c +++ b/src/fsm/log/manager.c @@ -57,9 +57,8 @@ static fsm_log_struct gg_logs; * * A message is send to the log for each documented event. * - * If there are too many events, one or several filters can be applied - * here (and only here) before publication, to select only some events - * of interest (during debugging, for example). + * One or several filters can be applied here (and only here) before publication, + * to select only some events of interest (during debugging, for example). * * These filters can operate on any the following five parameters: * severity, source, file_source (text), function_source (text), @@ -102,3 +101,38 @@ void fsm_add_log (int severity, ) fsm_add_log_event (&gg_logs, file_source, function_source, string_value); } + +/** + * this function is a relay: fsm_init_log() can't be called directly from + * fsm_init() in control because static fsm_log_struct gg_logs is in + * src/fsm/log/manager.c + * + * + * @since 2024-08 + * + * @callergraph + * @see main() + * + */ +void fsm_trigger_log_init() +{ + fsm_init_log (&gg_logs); +} + +/** + * this function is a relay: fsm_publish_log() and fsm_clear_log() can't be + * called directly from fsm_close() in control because static fsm_log_struct + * gg_logs is in src/fsm/log/manager.c + * + * @since 2024-08 + * + * @callergraph + * @see main() + * + */ +void fsm_trigger_log_close() +{ + fsm_publish_log (gg_logs); + fsm_clear_log (&gg_logs); +} + diff --git a/src/main.c b/src/main.c index 4a577d9..51624b4 100644 --- a/src/main.c +++ b/src/main.c @@ -1,7 +1,6 @@ /** * @file - * - * Gem-graph main file + * Gem-graph-client main file. * * This file is part of Gem-graph. It contains only the main() function. * @@ -26,16 +25,22 @@ * * --- * - * The main() function will **initialise** the log, the finite state machine (fsm), - * the application and the windows and **close** all the elements it opened - * before the end of program execution. + * The main() function + * - **initialise** + * -# the log, + * -# the finite state machine (fsm), + * -# the application, + * -# the windows and + * + * - **close** all the elements it opened in reverse order + * before ending the program execution + * . + * * In this commit, it does not implement g_application_activate() and has no * handlers connected to the 'activate' signal (which triggers an error message). * * The default values of the fsm initial state will be specified in: - * src/fsm/dispatch(). They are user preference and, in accordance, the overview - * page of the current model will be displayed as they specify it in: - * src/widget/main_window/designer/widget_design_main_window(). + * src/fsm/control(). They are user preferences. * * About code organization, see src/readme.dox * @@ -43,19 +48,49 @@ */ #include +#include "../include/fsm.h" // finite state machine (fsm) +/** + * @since 2024-04 + * + * @callgraph + * @see fsm_trigger_log_init() + * @see fsm_init() + * @see fsm_close() + * @see fsm_trigger_log_close() + * @see fsm_add_log() + * + * @param argc + * @param **argv + * @return status, the program errorlevel + */ int main (int argc, char **argv) { - GtkApplication *app; - int status; + GtkApplication *app; + int status; - app = gtk_application_new ("org.gem-graph", G_APPLICATION_DEFAULT_FLAGS); + fsm_init ("first instruction / first log"); - //g_signal_connect (app, "activate", G_CALLBACK (on_main_window_activation), NULL); - //g_signal_connect (app, "activate", G_CALLBACK (on_dialog_window_activation), NULL); + fsm_add_log (INFO, MAIN, "main", "*app = gtk_application_new()", + "| 👉️ trigger app initialization"); + app = gtk_application_new ("org.gem-graph", G_APPLICATION_DEFAULT_FLAGS); - status = g_application_run (G_APPLICATION (app), argc, argv); - g_object_unref (app); + fsm_add_log (INFO, MAIN, "main", + "g signal connect (activate)", + "| 👉️ windows creation requested"); - return status; +// g_signal_connect (app, "startup", G_CALLBACK (on_windows_startup), NULL); +// g_signal_connect (app, "activate", G_CALLBACK (on_windows_activation), NULL); + + fsm_add_log (INFO, MAIN, "main", + "no g signal connect (activate)", + "| 🖐️ windows creation denied"); + + status = g_application_run (G_APPLICATION (app), argc, argv); + g_object_unref (app); + fsm_add_log (INFO, MAIN, "main", "g_object unref (app)", "| 👌️ bye bye app !"); + + fsm_close("last instruction / last log"); + + return status; }