nommage: création d'un index

This commit is contained in:
Jean Sirmai 2024-09-30 15:32:57 +02:00
parent 7e02ca86c5
commit 3c209becd3
Signed by: jean
GPG Key ID: FB3115C340E057E3
11 changed files with 199 additions and 103 deletions

View File

@ -28,31 +28,24 @@
#include <string.h>
#include <gtk-4.0/gtk/gtk.h>
/******************************************************************************/
/* S T A T E M A C H I N E */
/******************************************************************************/
// called by widgets through signal functions
enum fsm_select_EXEC_EDIT { EXEC, EDIT };
enum fsm_select_STATE_RULES_DATA { SYNTH, STATE, RULES, DATA };
enum fsm_select_STORE_RESTORE_RESET { STORE, RESTORE, RESET };
enum fsm_measure_type {DATE_RULE_EXEC, RULE_EXEC_NB, OBJECT_NB, ELAPSED_TIME };
#define n_rules 128 // arbitrary
#define n_objects 32 // arbitrary too,
#define n_situations 128 // and so on...
typedef struct tool_list {int value; struct tool_list *suiv;} tool_list ;
typedef struct data_list {int value; struct data_list *suiv;} data_list ;
typedef struct disp_list {int value; struct disp_list *suiv;} disp_list ;
/******************************************************************************/
/* J O U R N A L */
/******************************************************************************/
/* * * * * - J O U R N A L M E T A R U L E S - * * * *
*
* ref: sudo cat /var/log/messages
*
* structure d'un log:
* - date
* - rang (n° d'ordre)
* - fichier
* - fonction
* - valeur, paramètre, descriptif, contexte,...
* (tout ce qui peut contribuer à améliorer la compréhension du journal)
*
* - - - - - - - - - - - - - - - - - - - - - - - - - -
*
* Un seul fsm_journal_event() par fonction
* ? sauf si cette fonction génère plusieurs autres fonctions d'intérêt ?
*
@ -62,15 +55,15 @@ typedef struct disp_list {int value; struct disp_list *suiv;} disp_list ;
* * * * * - J O U R N A L M E T A R U L E S - * * * */
enum severity {CRITICAL, ERROR, WARNING, INFO, MESSAGE, DEBUG, SPEW};
enum fsm_enum_journal_severity {CRITICAL, ERROR, WARNING, INFO, MESSAGE, DEBUG, SPEW};
enum source {
enum fsm_enum_journal_source {
SOURCE, TARGET, JOURNAL, FSM, PREFER,
MAIN, APP, WIDGETS, SIGNAL,
MAIN_WINDOW, DIALOG_WINDOW, MODAL_WINDOW, TEXT_WINDOW, AUTO_NOTIFICATION,
TOPBAR, TOPBAR_LEFT, TOPBAR_RIGHT, TOPBAR_CENTER,
SYNTH_PAGE, STATE_PAGE, RULES_PAGE, MEASURES_PAGE, RESULTS_PAGE,
SYNTH_GLAREA, SYNTH_ALL_RESULTS,
SenumYNTH_GLAREA, SYNTH_ALL_RESULTS,
SYNTH_TIME_DEP_RESULTS, SYNTH_TIME_INDEP_RESULTS,
STATE_TOP, STATE_BOTTOM, STATE_GLAREA, STATE_CAMERA,
RULE_GEOMETRY, RULE_GLAREA, RULE_CAMERA,
@ -86,41 +79,49 @@ enum source {
#define JOURNAL_LOG_MAX_LENGTH 255
typedef struct unit {long yy_dd_mm;
long usec;
const char *file_source;
const char *function_source;
const char *string_value;
struct unit *prev;
struct unit *next;} unit; // journal unit structure
typedef struct fsm_struct_journal_unit
{
long yy_dd_mm;
long usec;
const char *file_source;
const char *function_source;
const char *string_value;
struct fsm_struct_journal_unit *prev;
struct fsm_struct_journal_unit *next;
}
fsm_struct_journal_unit; // journal unit structure
typedef struct {unit *first; unit *last;} journal; // journal unit access structure
typedef struct {
fsm_struct_journal_unit *first;
fsm_struct_journal_unit *last;
}
fsm_struct_journal; // journal unit access
void fsm_journal_init (journal *jj); // init from main
void fsm_journal_push_front (journal *jj, // add an évènement at the journal front
void fsm_journal_init (fsm_struct_journal *jj); // init from main
void fsm_journal_push_front (fsm_struct_journal *jj, // add an évènement at the journal front
const char *file_source, // def: fsm/dispatch
const char *function_source, // call: any call that does not have
const char *string_value); // the log address
void fsm_journal_clear (journal *jj,
void fsm_journal_clear (fsm_struct_journal *jj,
const char *file_source,
const char *function_source,
const char *string_value); // empty the journal
long fsm_journal_pop_back (journal *jj, // removes an évènement
const char *file_source, // at the journal end
long fsm_journal_pop_back (fsm_struct_journal *jj, // remove an evenement
const char *file_source, // at the journal end
const char *function_source,
const char *string_value);
int fsm_journal_length (journal jj); // journal length
void fsm_journal_seek (journal jj, // seek for an évènement
long usec, // in the journal
int fsm_journal_length (fsm_struct_journal jj); // journal length
void fsm_journal_seek (fsm_struct_journal jj, // seek for an evenement
long usec, // in the journal
const char *file_source,
const char *function_source,
const char *string_value);
void fsm_journal_publish (journal jj); // display the journal
void fsm_journal_publish (fsm_struct_journal jj); // display the journal
// -----------------------------------------------------------------------------
// ref: sudo cat /var/log/messages
// journal fsm_get_journal(); // def: fsm/dispatch call: fsm/prefer/fsm_store_restore_reset()
//
void fsm_journal_publication_request(); // def: fsm/dispatch call: main;
void fsm_journal_event (int severity,
int source,
@ -131,13 +132,32 @@ void fsm_journal_event (int severity,
// -----------------------------------------------------------------------------
/******************************************************************************/
/* S T A T E M A C H I N E */
/******************************************************************************/
// called by widgets through signal functions
enum fsm_enum_exec_edit { EXEC, EDIT };
enum fsm_enum_state_rules_data { SYNTH, STATE, RULES, DATA };
enum fsm_enum_store_restore_reset { STORE, RESTORE, RESET };
enum fsm_enum_measure_type {DATE_RULE_EXEC, RULE_EXEC_NB, OBJECT_NB, ELAPSED_TIME };
#define n_rules 128 // arbitrary
#define n_objects 32 // arbitrary too,
#define n_situations 128 // and so on...
typedef struct fsm_struct_list_tool {int value; struct fsm_struct_list_tool *suiv;} fsm_struct_list_tool ;
typedef struct fsm_struct_list_data {int value; struct fsm_struct_list_data *suiv;} fsm_struct_list_data ;
typedef struct fsm_struct_list_disp {int value; struct fsm_struct_list_disp *suiv;} fsm_struct_list_disp ;
void fsm_init (char *message); // def: fsm/dispatch; call: main;
void fsm_engine_init(); // def: fsm/engine/engine; call main
void fsm_preferences_list_init(); // def: fsm/prefer; call: fsm/dispatch;
void fsm_measures_list_init(); // def: fsm/measure/manage.c; call: fsm/dispatch;
void fsm_results_list_init(); // def: fsm/results; call: fsm/dispatch;
void fsm_displayables_list_init(); // def: fsm/prefer; call: fsm/dispatch;
void fsm_init_list_preferences(); // def: fsm/prefer; call: fsm/dispatch;
void fsm_init_list_measures(); // def: fsm/measure/manage.c; call: fsm/dispatch;
void fsm_init_list_results(); // def: fsm/results; call: fsm/dispatch;
void fsm_init_list_displayables(); // def: fsm/prefer; call: fsm/dispatch;
int fsm_get_exec_edit(); // def: fsm/dispatch; call: signal;
// widget/state/dispatch;
@ -147,7 +167,7 @@ int fsm_get_state_rules_data(); // def: fsm/dispatch; call: signal;
void fsm_set_exec_edit (int value);// def: fsm/dispatch; call: signal;
void fsm_set_state_rules_data (int value); // def: fsm/dispatch; call: signal;
void fsm_store_restore_reset (int choice, int value);// def: prefer; call: signal;
void fsm_set_store_restore_reset (int choice, int value);// def: prefer; call: signal;
bool fsm_get_preferences_state(); // def: fsm/dispatch; call: - - -
void fsm_set_preferences_modified (bool value); // def: fsm/dispatch;
@ -163,11 +183,11 @@ void fsm_reset_all_situations_transparencies_at_value (int value); // provisoire
// --------------------------------------------------------------- WIP ------
// def: measure/tool_list call: measure/tool_list (about the following functions...)
void fsm_tools_list_insert (tool_list **tl, int value);
int fsm_tools_list_pop (tool_list **tl);
int fsm_tools_list_length (tool_list *tl);
void fsm_tools_list_clear (tool_list **tl);
void fsm_tools_list_view (tool_list *tl);
void fsm_tools_list_insert (fsm_struct_list_tool **tl, int value);
int fsm_tools_list_pop (fsm_struct_list_tool **tl);
int fsm_tools_list_length (fsm_struct_list_tool *tl);
void fsm_tools_list_clear (fsm_struct_list_tool **tl);
void fsm_tools_list_view (fsm_struct_list_tool *tl);
void fsm_tools_list_test(); // def: measure/manage; call: measure/manage;
// def: fsm/measure/manage/; call: rule exec
@ -175,13 +195,13 @@ void fsm_rule_trig_measure (int rule_id, int object_id, int measure_id);
// --------------------------------------------------------------- WIP ------
void fsm_add_data (data_list d, int *p_data, int *p_target);
int fsm_get_data (data_list d, int from, int to);
void fsm_remove_data (data_list d, int *p_data);
void fsm_add_data (fsm_struct_list_data d, int *p_data, int *p_target);
int fsm_get_data (fsm_struct_list_data d, int from, int to);
void fsm_remove_data (fsm_struct_list_data d, int *p_data);
// --------------------------------------------------------------- WIP ------
void fsm_disp_add_chart (disp_list d, int *p_chart);
int fsm_disp_get_chart (disp_list d, int from, int to);
void fsm_disp_remove_chart (disp_list d, int *p_chart);
void fsm_disp_add_chart (fsm_struct_list_disp d, int *p_chart);
int fsm_disp_get_chart (fsm_struct_list_disp d, int from, int to);
void fsm_disp_remove_chart (fsm_struct_list_disp d, int *p_chart);

76
include/names_index.all Normal file
View File

@ -0,0 +1,76 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Gem-graph client *
* Finite state machine header *
* *
* Copyright © 2021 Libre en Communs <contact@a-lec.org> *
* Copyright © 2024 Jean Sirmai <jean@a-lec.org> *
* *
* This file is part of Gem-graph. *
* *
* This program is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Affero General Public License *
* as publishedby 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 <http://www.gnu.org/licenses/>. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
fsm_enum_exec_edit
fsm_enum_state_rules_data
fsm_enum_store_restore_reset
fsm_enum_measure_type
fsm_enum_journal_severity
fsm_enum_journal_source
fsm_struct_list_tool
fsm_struct_list_data
fsm_struct_list_disp
fsm_struct_journal_unit
fsm_struct_journal
fsm_journal_init
fsm_journal_push_front
fsm_journal_clear
fsm_journal_pop_back
fsm_journal_length
fsm_journal_seek
fsm_journal_publish
fsm_journal_publication_request
fsm_journal_event
fsm_init
fsm_init_list_preferences
fsm_init_list_measures
fsm_init_list_results
fsm_init_list_displayables
fsm_get_exec_edit
fsm_get_state_rules_data
fsm_get_preferences_state
fsm_set_exec_edit
fsm_set_state_rules_data
fsm_set_store_restore_reset
fsm_set_preferences_modified
fsm_add_measure
fsm_add_result
fsm_add_displayable
fsm_reset_all_situations_transparencies_at_value
fsm_tools_list_insert
fsm_tools_list_pop
fsm_tools_list_length
fsm_tools_list_clear
fsm_tools_list_view
fsm_tools_list_test
fsm_rule_trig_measure
fsm_add_data
fsm_get_data
fsm_remove_data
fsm_disp_add_chart
fsm_disp_get_chart
fsm_disp_remove_chart

View File

@ -56,7 +56,7 @@
/******************************************************************************/
/* J O U R N A L */
/******************************************************************************/
static journal gg_logs;
static fsm_struct_journal gg_logs;
void fsm_journal_publication_request() {fsm_journal_publish (gg_logs);}
@ -92,22 +92,22 @@ void fsm_init (char *initial_message_from_main)
fsm_journal_event (MESSAGE, FSM, "fsm/dispatch", "measures list init()",
"measurement processes");
fsm_measures_list_init();
fsm_init_list_measures();
fsm_journal_event (MESSAGE, FSM, "fsm/dispatch", "results list init()",
"measurement results (gross)");
fsm_results_list_init();
fsm_init_list_results();
fsm_journal_event (MESSAGE, FSM, "fsm/dispatch", "displayables list init()",
"displayable results");
fsm_displayables_list_init();
fsm_init_list_displayables();
fsm_journal_event (MESSAGE, FSM, "fsm/dispatch", "preferences list init()",
"preferences");
fsm_preferences_list_init();
fsm_init_list_preferences();
fsm_journal_event (MESSAGE, FSM, "fsm/dispatch", "fsm initialisation",

View File

@ -39,9 +39,9 @@
/* ex : filter, concat, inverse, scale, correlate, etc. */
/******************************************************************************/
void fsm_add_data (data_list d, int *p_data, int *p_target) {}
int fsm_get_data (data_list d, int from, int to) {return 0;}
void fsm_remove_data (data_list d, int *p_data) {}
void fsm_add_data (fsm_struct_list_data d, int *p_data, int *p_target) {}
int fsm_get_data (fsm_struct_list_data d, int from, int to) {return 0;}
void fsm_remove_data (fsm_struct_list_data d, int *p_data) {}
// http://www.gnuplot.info/
// https://fr.wikipedia.org/wiki/Gnuplot

View File

@ -39,7 +39,7 @@
// "graph", "chart", "plot" and "diagram" are ambiguous terms, used interchangeably.
void fsm_disp_add_chart (disp_list d, int *p_chart) {}
int fsm_disp_get_chart (disp_list d, int from, int to) {return 0;}
void fsm_disp_remove_chart (disp_list d, int *p_chart) {}
void fsm_disp_add_chart (fsm_struct_list_disp d, int *p_chart) {}
int fsm_disp_get_chart (fsm_struct_list_disp d, int from, int to) {return 0;}
void fsm_disp_remove_chart (fsm_struct_list_disp d, int *p_chart) {}

View File

@ -96,7 +96,7 @@ void fsm_add_measure (char *measure_name)
measure_name);
}
void fsm_measures_list_init()
void fsm_init_list_measures()
{
if (0) fsm_tools_list_test();

View File

@ -69,11 +69,11 @@
//------------------------------------------------------------------------------
void fsm_tools_list_insert (tool_list **ml, int value)
void fsm_tools_list_insert (fsm_struct_list_tool **ml, int value)
{
tool_list *tmp = NULL;
tool_list *cml = *ml;
tool_list *elem = malloc (sizeof (tool_list));
fsm_struct_list_tool *tmp = NULL;
fsm_struct_list_tool *cml = *ml;
fsm_struct_list_tool *elem = malloc (sizeof (fsm_struct_list_tool));
if (!elem) exit (EXIT_FAILURE);
elem->value = value;
while (cml && cml->value < value)
@ -86,10 +86,10 @@ void fsm_tools_list_insert (tool_list **ml, int value)
else *ml = elem;
}
int fsm_tools_list_pop (tool_list **ml)
int fsm_tools_list_pop (fsm_struct_list_tool **ml)
{
int value;
tool_list *tmp;
fsm_struct_list_tool *tmp;
if (! *ml) return -1;
tmp = (*ml)->suiv;
value = (*ml)->value;
@ -98,7 +98,7 @@ int fsm_tools_list_pop (tool_list **ml)
return value;
}
int fsm_tools_list_length (tool_list *ml)
int fsm_tools_list_length (fsm_struct_list_tool *ml)
{
int n = 0;
while (ml)
@ -109,9 +109,9 @@ int fsm_tools_list_length (tool_list *ml)
return n;
}
void fsm_tools_list_clear (tool_list **ml)
void fsm_tools_list_clear (fsm_struct_list_tool **ml)
{
tool_list *tmp;
fsm_struct_list_tool *tmp;
while (*ml)
{
tmp = (*ml)->suiv;
@ -120,7 +120,7 @@ void fsm_tools_list_clear (tool_list **ml)
}
}
void fsm_tools_list_view (tool_list *ml)
void fsm_tools_list_view (fsm_struct_list_tool *ml)
{
printf ("-------- view measures list (n = %d)\n",
fsm_tools_list_length (ml));
@ -138,7 +138,7 @@ void fsm_tools_list_view (tool_list *ml)
void fsm_tools_list_test()
{
tool_list *ex_tool = NULL;
fsm_struct_list_tool *ex_tool = NULL;
fsm_journal_event (DEBUG, MEASURES_TOOLS, "fsm/measure/",
"fsm_tools_list_test()", "création d'une liste de 6 elements:");

View File

@ -35,7 +35,7 @@
// 2) dans signal.c on_updating_objects_transparencies()
// où ils servent à identifier le bouton source (activé)
// Cette identification va déterminer le choix du switch
// de la fonction : fsm_store_restore_reset()
// de la fonction : fsm_set_store_restore_reset()
// ! WARNING ! Cette méthode d'identification est dangereuse:
// Si un utilisateur modifie l'apparence d'un bouton (parce que préférence...)
@ -69,7 +69,7 @@ struct preferences *pref_jean = NULL; // TODO (voir graphics_init(...))
// en attendant:
static int p[n_objects] = {};
void fsm_store_restore_reset (int choice, int value)
void fsm_set_store_restore_reset (int choice, int value)
{
switch (choice) {
case (STORE) :
@ -129,14 +129,14 @@ void fsm_add_displayable (char *displayable_name)
/******************************************************************************/
/* P R E F E R E N C E S */
/******************************************************************************/
void fsm_preferences_list_init ()
void fsm_init_list_preferences()
{
fsm_journal_event (MESSAGE, PREFER, "fsm/preferences/manager",
"fsm preferences list is ready to use",
"(double chained)");
}
void fsm_displayables_list_init ()
void fsm_init_list_displayables()
{
fsm_journal_event (MESSAGE, PREFER, "fsm/preferences/manager",
"fsm displayables list is ready to use",

View File

@ -68,7 +68,7 @@ void fsm_add_result (char *result_name)
printf("fsm_add_result %p <<< %s (see fsm.c)\n", list_results, result_name);
}
void fsm_results_list_init ()
void fsm_init_list_results ()
{
fsm_journal_event (DEBUG,
RESULTS,

View File

@ -55,19 +55,19 @@
printf(" Current time: %s", ctime(&current_time));
*/
void fsm_journal_init (journal *jj)
void fsm_journal_init (fsm_struct_journal *jj)
{
jj->first = NULL;
jj->last = NULL;
}
void fsm_journal_clear (journal *jj,
void fsm_journal_clear (fsm_struct_journal *jj,
const char *file_source,
const char *function_source,
const char *string_value)
{
unit *tmp;
unit *a_unit = jj->first;
fsm_struct_journal_unit *tmp;
fsm_struct_journal_unit *a_unit = jj->first;
while(a_unit)
{
tmp = a_unit;
@ -78,14 +78,14 @@ void fsm_journal_clear (journal *jj,
jj->last = NULL;
}
void fsm_journal_push_front (journal *jj,
void fsm_journal_push_front (fsm_struct_journal *jj,
const char *file_source,
const char *function_source,
const char *string_value)
{
struct timeval tv;
gettimeofday (&tv, NULL);
unit *new_unit = malloc (sizeof(unit));
fsm_struct_journal_unit *new_unit = malloc (sizeof(fsm_struct_journal_unit));
if (! new_unit) exit (EXIT_FAILURE);
new_unit->yy_dd_mm = tv.tv_sec;
@ -101,13 +101,13 @@ void fsm_journal_push_front (journal *jj,
jj->first = new_unit;
}
long fsm_journal_pop_back (journal *jj,
long fsm_journal_pop_back (fsm_struct_journal *jj,
const char *file_source,
const char *function_source,
const char *string_value)
{
long usec;
unit *tmp = jj->last;
fsm_struct_journal_unit *tmp = jj->last;
if (! tmp) return -1;
usec = tmp->usec;
jj->last = tmp->prev;
@ -117,9 +117,9 @@ long fsm_journal_pop_back (journal *jj,
return usec; // retourne l'évènement retiré du journal.
}
int fsm_journal_length (journal jj)
int fsm_journal_length (fsm_struct_journal jj)
{
unit *a_unit = jj.first;
fsm_struct_journal_unit *a_unit = jj.first;
int nb = 0;
while (a_unit)
{
@ -130,12 +130,12 @@ int fsm_journal_length (journal jj)
return nb;
}
void fsm_journal_seek (journal jj, long usec,
void fsm_journal_seek (fsm_struct_journal jj, long usec,
const char *file_source,
const char *function_source,
const char *string_value)
{
unit *a_unit = jj.first;
fsm_struct_journal_unit *a_unit = jj.first;
int nb = 0;
while (a_unit)
{
@ -157,9 +157,9 @@ void fsm_journal_seek (journal jj, long usec,
// https://mefics.org/fr/allocation-dynamique-de-m%C3%A9moire-en-c-fonctions-malloc-calloc/
//------------------------------------------------------------------------------
void fsm_journal_publish (journal jj)
void fsm_journal_publish (fsm_struct_journal jj)
{
unit *a_unit = jj.last;
fsm_struct_journal_unit *a_unit = jj.last;
char buf [JOURNAL_LOG_MAX_LENGTH];
int nb = 0;
while (a_unit)

View File

@ -394,9 +394,9 @@ void on_updating_objects_transparencies (GtkWidget *btt_source, GtkScrollbar *sc
printf(string_value);
fsm_journal_event (DEBUG, BUTTON, "signal", "updating objects transparencies()", string_value); // TODO TODO (je suis fatigué)
if ( ! strcmp (btt_name, "document-revert-rtl-symbolic")) fsm_store_restore_reset (STORE, value);
if ( ! strcmp (btt_name, "edit-undo-symbolic")) fsm_store_restore_reset (RESTORE, value);
if ( ! strcmp (btt_name, "view-refresh-symbolic")) fsm_store_restore_reset (RESET, value);
if ( ! strcmp (btt_name, "document-revert-rtl-symbolic")) fsm_set_store_restore_reset (STORE, value);
if ( ! strcmp (btt_name, "edit-undo-symbolic")) fsm_set_store_restore_reset (RESTORE, value);
if ( ! strcmp (btt_name, "view-refresh-symbolic")) fsm_set_store_restore_reset (RESET, value);
fsm_set_preferences_modified (TRUE); // << à détailler TODO
}