\doxysection{src/fsm/dispatch.c File Reference} \hypertarget{fsm_2dispatch_8c}{}\label{fsm_2dispatch_8c}\index{src/fsm/dispatch.c@{src/fsm/dispatch.c}} This Finite State Machine (fsm) describes all the possible states of the Gem-\/graph client and all the transitions between them. {\ttfamily \#include $<$stdbool.\+h$>$}\newline {\ttfamily \#include "{}../../include/fsm.\+h"{}}\newline {\ttfamily \#include "{}../../include/util.\+h"{}}\newline {\ttfamily \#include "{}../../include/widget.\+h"{}}\newline \doxysubsubsection*{Functions} \begin{DoxyCompactItemize} \item void \mbox{\hyperlink{fsm_2dispatch_8c_a435d1a5171a7d69662d701234722fee2}{fsm\+\_\+journal\+\_\+publication\+\_\+request}} () \begin{DoxyCompactList}\small\item\em The \doxylink{fsm_2dispatch_8c_a435d1a5171a7d69662d701234722fee2}{fsm\+\_\+journal\+\_\+publication\+\_\+request()} is called only once, by \doxylink{main_8c_a3c04138a5bfe5d72780bb7e82a18e627}{main()}, just after closing the app and before ending the program. \end{DoxyCompactList}\item void \mbox{\hyperlink{fsm_2dispatch_8c_a8c67f42f95d48ee2469c9a27d65db3e6}{fsm\+\_\+journal\+\_\+event}} (int severity, int source, const char \texorpdfstring{$\ast$}{*}file\+\_\+source, const char \texorpdfstring{$\ast$}{*}function\+\_\+source, const char \texorpdfstring{$\ast$}{*}string\+\_\+value) \begin{DoxyCompactList}\small\item\em It is mandatory for any event to call this function to be published in the journal. \end{DoxyCompactList}\item void \mbox{\hyperlink{fsm_2dispatch_8c_a8d91f5868f20ad3b72cfa63787d87444}{fsm\+\_\+init}} (char \texorpdfstring{$\ast$}{*}initial\+\_\+message\+\_\+from\+\_\+main) \begin{DoxyCompactList}\small\item\em fsm init is the first function called by \doxylink{main_8c}{main.\+c} It initiates the journal and the four lists\+: \textquotesingle{}measures\textquotesingle{}, \textquotesingle{}results\textquotesingle{}, \textquotesingle{}displayables results\textquotesingle{} and \textquotesingle{}preferences\textquotesingle{}. \end{DoxyCompactList}\item void \mbox{\hyperlink{fsm_2dispatch_8c_a770bcaeb0bd6f81cddcc3cd506468fff}{fsm\+\_\+set\+\_\+preferences\+\_\+modified}} (bool value) \begin{DoxyCompactList}\small\item\em setter for the static boolean\+: \textquotesingle{}preferences\+\_\+have\+\_\+been\+\_\+modified\textquotesingle{} \end{DoxyCompactList}\item bool \mbox{\hyperlink{fsm_2dispatch_8c_a0b0231a311d0e85723ef9fcf38be88e3}{fsm\+\_\+get\+\_\+preferences\+\_\+state}} () \begin{DoxyCompactList}\small\item\em getter for the static boolean\+: \textquotesingle{}preferences\+\_\+have\+\_\+been\+\_\+modified\textquotesingle{} \end{DoxyCompactList}\item int \mbox{\hyperlink{fsm_2dispatch_8c_a9123915ffd10fe1ae18254898b1c0ebf}{fsm\+\_\+get\+\_\+exec\+\_\+edit}} () \begin{DoxyCompactList}\small\item\em some client pages (in particular "{}state"{} and "{}rules"{}) will be displayed and behave differently depending on whether the fsm is in edit or run state. \end{DoxyCompactList}\item int \mbox{\hyperlink{fsm_2dispatch_8c_a90ab14081a88752d3721947a4922ee25}{fsm\+\_\+get\+\_\+state\+\_\+rules\+\_\+data}} () \begin{DoxyCompactList}\small\item\em The value of the static int choice\+\_\+\+STATE\+\_\+\+RULES\+\_\+\+DATA can be one of the enum include/fsm enum fsm\+\_\+enum\+\_\+state\+\_\+rules\+\_\+data. \end{DoxyCompactList}\item void \mbox{\hyperlink{fsm_2dispatch_8c_ae921ecd39af67bb8dc0deb2cdc86125d}{fsm\+\_\+set\+\_\+exec\+\_\+edit}} (int choice) \begin{DoxyCompactList}\small\item\em setter for the static value\+: \textquotesingle{}choice\+\_\+\+STATE\+\_\+\+RULES\+\_\+\+DATA\textquotesingle{} (in this file) \end{DoxyCompactList}\item void \mbox{\hyperlink{fsm_2dispatch_8c_af5a464b19589ba1972c9b3aa3397945a}{fsm\+\_\+set\+\_\+state\+\_\+rules\+\_\+data}} (int choice) \begin{DoxyCompactList}\small\item\em setter for the static value\+: \textquotesingle{}choice\+\_\+\+STATE\+\_\+\+RULES\+\_\+\+DATA\textquotesingle{} (in this file) \end{DoxyCompactList}\end{DoxyCompactItemize} \doxysubsection{Detailed Description} This Finite State Machine (fsm) describes all the possible states of the Gem-\/graph client and all the transitions between them. The gem-\/graph-\/client fsm manages several kinds of exclusive states\+: \begin{DoxyItemize} \item Run the model or edit it. \item 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. \item Apply a selected measurement to the currently running model \item Select some results for study or/and presentation. \item Choose the user\textquotesingle{}s preferred values for a set of parameters used to modify the appearance or behaviour of gem-\/graph. \end{DoxyItemize} Each state of the fsm is a combination of each of these states. The current state of the fsm must be \begin{DoxyItemize} \item saved at the end of a work session and \item reread (available to the user) at the start of a new session. \end{DoxyItemize} No state of the fsm should be defined in another module. No fsm transition should be executed in another module. \begin{DoxyVerb} The journal is created, edited and published from here. \end{DoxyVerb} \doxysubsection{Function Documentation} \Hypertarget{fsm_2dispatch_8c_a9123915ffd10fe1ae18254898b1c0ebf}\label{fsm_2dispatch_8c_a9123915ffd10fe1ae18254898b1c0ebf} \index{dispatch.c@{dispatch.c}!fsm\_get\_exec\_edit@{fsm\_get\_exec\_edit}} \index{fsm\_get\_exec\_edit@{fsm\_get\_exec\_edit}!dispatch.c@{dispatch.c}} \doxysubsubsection{\texorpdfstring{fsm\_get\_exec\_edit()}{fsm\_get\_exec\_edit()}} {\footnotesize\ttfamily int fsm\+\_\+get\+\_\+exec\+\_\+edit (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})} some client pages (in particular "{}state"{} and "{}rules"{}) will be displayed and behave differently depending on whether the fsm is in edit or run state. Any function which modifies the appearance or behavior of these pages must use this getter to access the choice\+\_\+\+EXEC\+\_\+\+EDIT value. see include/fsm enum fsm\+\_\+enum\+\_\+exec\+\_\+edit \{ EXEC, EDIT \} The current int may be replaced by a boolean . TODO \begin{DoxySince}{Since} 2024-\/06 \end{DoxySince} \begin{DoxySeeAlso}{See also} src/widget/one\+\_\+rule/dispatch src/widget/state/dispatch \texorpdfstring{$\ast$}{*} 2 src/signal choice\+\_\+\+EXEC\+\_\+\+EDIT and include/fsm/enum fsm\+\_\+enum\+\_\+exec\+\_\+edit \{\} \end{DoxySeeAlso} \begin{DoxyReturn}{Returns} choice\+\_\+\+EXEC\+\_\+\+EDIT \end{DoxyReturn} \Hypertarget{fsm_2dispatch_8c_a0b0231a311d0e85723ef9fcf38be88e3}\label{fsm_2dispatch_8c_a0b0231a311d0e85723ef9fcf38be88e3} \index{dispatch.c@{dispatch.c}!fsm\_get\_preferences\_state@{fsm\_get\_preferences\_state}} \index{fsm\_get\_preferences\_state@{fsm\_get\_preferences\_state}!dispatch.c@{dispatch.c}} \doxysubsubsection{\texorpdfstring{fsm\_get\_preferences\_state()}{fsm\_get\_preferences\_state()}} {\footnotesize\ttfamily bool fsm\+\_\+get\+\_\+preferences\+\_\+state (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})} getter for the static boolean\+: \textquotesingle{}preferences\+\_\+have\+\_\+been\+\_\+modified\textquotesingle{} \begin{DoxySince}{Since} 2024-\/08 \end{DoxySince} \begin{DoxySeeAlso}{See also} TODO A function must obtain this boolean when it stores the current state of the fsm (including \doxylink{structpreferences}{preferences}) before closing the current session. \end{DoxySeeAlso} \begin{DoxyReturn}{Returns} preferences\+\_\+have\+\_\+been\+\_\+modified \end{DoxyReturn} \Hypertarget{fsm_2dispatch_8c_a90ab14081a88752d3721947a4922ee25}\label{fsm_2dispatch_8c_a90ab14081a88752d3721947a4922ee25} \index{dispatch.c@{dispatch.c}!fsm\_get\_state\_rules\_data@{fsm\_get\_state\_rules\_data}} \index{fsm\_get\_state\_rules\_data@{fsm\_get\_state\_rules\_data}!dispatch.c@{dispatch.c}} \doxysubsubsection{\texorpdfstring{fsm\_get\_state\_rules\_data()}{fsm\_get\_state\_rules\_data()}} {\footnotesize\ttfamily int fsm\+\_\+get\+\_\+state\+\_\+rules\+\_\+data (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})} The value of the static int choice\+\_\+\+STATE\+\_\+\+RULES\+\_\+\+DATA can be one of the enum include/fsm enum fsm\+\_\+enum\+\_\+state\+\_\+rules\+\_\+data. To each value is associated a different page and different possible behaviors. Any function that modifies the client window must get this value. see include/fsm enum fsm\+\_\+enum\+\_\+state\+\_\+rules\+\_\+data \{ SYNTH, STATE, RULES, DATA \} \begin{DoxySince}{Since} 2024-\/06 \end{DoxySince} \begin{DoxySeeAlso}{See also} src/widget/topbar/left src/signal \end{DoxySeeAlso} \begin{DoxyReturn}{Returns} choice\+\_\+\+STATE\+\_\+\+RULES\+\_\+\+DATA \end{DoxyReturn} \Hypertarget{fsm_2dispatch_8c_a8d91f5868f20ad3b72cfa63787d87444}\label{fsm_2dispatch_8c_a8d91f5868f20ad3b72cfa63787d87444} \index{dispatch.c@{dispatch.c}!fsm\_init@{fsm\_init}} \index{fsm\_init@{fsm\_init}!dispatch.c@{dispatch.c}} \doxysubsubsection{\texorpdfstring{fsm\_init()}{fsm\_init()}} {\footnotesize\ttfamily void fsm\+\_\+init (\begin{DoxyParamCaption}\item[{char \texorpdfstring{$\ast$}{*}}]{initial\+\_\+message\+\_\+from\+\_\+main }\end{DoxyParamCaption})} fsm init is the first function called by \doxylink{main_8c}{main.\+c} It initiates the journal and the four lists\+: \textquotesingle{}measures\textquotesingle{}, \textquotesingle{}results\textquotesingle{}, \textquotesingle{}displayables results\textquotesingle{} and \textquotesingle{}preferences\textquotesingle{}. The items selected in these lists define the current state of the fsm. \begin{DoxySince}{Since} 2024-\/08 \end{DoxySince} \begin{DoxySeeAlso}{See also} src/main/main() src/journal/fsm\+\_\+journal\+\_\+init() src/fsm/dispatch/fsm\+\_\+journal\+\_\+event() src/fsm/measures/manager/fsm\+\_\+list\+\_\+init\+\_\+measures() src/fsm/results/manager/fsm\+\_\+list\+\_\+init\+\_\+results() src/fsm/preferences/manager/fsm\+\_\+list\+\_\+init\+\_\+displayables() src/fsm/preferences/manager/fsm\+\_\+list\+\_\+init\+\_\+preferences() \end{DoxySeeAlso} \begin{DoxyParams}{Parameters} {\em \texorpdfstring{$\ast$}{*}initial\+\_\+message\+\_\+from\+\_\+main} & \\ \hline \end{DoxyParams} \Hypertarget{fsm_2dispatch_8c_a8c67f42f95d48ee2469c9a27d65db3e6}\label{fsm_2dispatch_8c_a8c67f42f95d48ee2469c9a27d65db3e6} \index{dispatch.c@{dispatch.c}!fsm\_journal\_event@{fsm\_journal\_event}} \index{fsm\_journal\_event@{fsm\_journal\_event}!dispatch.c@{dispatch.c}} \doxysubsubsection{\texorpdfstring{fsm\_journal\_event()}{fsm\_journal\_event()}} {\footnotesize\ttfamily void fsm\+\_\+journal\+\_\+event (\begin{DoxyParamCaption}\item[{int}]{severity, }\item[{int}]{source, }\item[{const char \texorpdfstring{$\ast$}{*}}]{file\+\_\+source, }\item[{const char \texorpdfstring{$\ast$}{*}}]{function\+\_\+source, }\item[{const char \texorpdfstring{$\ast$}{*}}]{string\+\_\+value }\end{DoxyParamCaption})} It is mandatory for any event to call this function to be published in the journal. Before publication, a filter can be applied here (and only here) to select only some events of interest (during debugging, for example). If there are too many events, a filter can be applied here to select a few interesting events for publication in the log. This filter can operate on any the following five parameters\+: severity, source, \texorpdfstring{$\ast$}{*}file\+\_\+source, \texorpdfstring{$\ast$}{*}function\+\_\+source, \texorpdfstring{$\ast$}{*}string\+\_\+value. \begin{DoxySeeAlso}{See also} below (params) \end{DoxySeeAlso} Simple filters (on a single parameter) can be combined using the logical operators \textquotesingle{}and\textquotesingle{} and \textquotesingle{}or\textquotesingle{} and parentheses. Use\+: \$ grep -\/r "{}fsm\+\_\+journal\+\_\+event"{} to confirm the callergraph calls. \begin{DoxySince}{Since} 2024-\/08 \end{DoxySince} \begin{DoxySeeAlso}{See also} src/journal.\+c/fsm\+\_\+journal\+\_\+push\+\_\+front() src/main/main() src/widget/topbar/modal.\+c src/widget/topbar/right.\+c src/widget/topbar/dialog.\+c src/widget/topbar/left.\+c src/widget/topbar/dispatch.\+c \texorpdfstring{$\ast$}{*} 3 src/widget/one\+\_\+rule/dispatch.\+c \doxylink{conditions_8c}{src/widget/one\+\_\+rule/algebra/conditions.\+c} \texorpdfstring{$\ast$}{*} 2 src/widget/measure/dispatch.\+c src/widget/dispatch.\+c \texorpdfstring{$\ast$}{*} 3 src/widget/all\+\_\+rules/dispatch.\+c \doxylink{preferences_2manager_8c}{src/fsm/preferences/manager.\+c} \texorpdfstring{$\ast$}{*} 8 src/fsm/measures/manager.\+c \texorpdfstring{$\ast$}{*} 2 src/fsm/measures/tools\+\_\+list.\+c \texorpdfstring{$\ast$}{*} 4 \doxylink{fsm_2dispatch_8c}{src/fsm/dispatch.\+c} \texorpdfstring{$\ast$}{*} 10 src/fsm/results/manager.\+c src/util/tree.\+c src/signal.\+c \texorpdfstring{$\ast$}{*} 38 \end{DoxySeeAlso} \begin{DoxyParams}{Parameters} {\em severity} & \texorpdfstring{$<$}{<}\texorpdfstring{$>$}{>} \\ \hline \end{DoxyParams} \begin{DoxySeeAlso}{See also} enum fsm\+\_\+enum\+\_\+journal\+\_\+severity in include/fsm.\+h \textquotesingle{}severity\textquotesingle{} is a pre-\/defined value that must be associated to each event. It ranges from zero to six \+: CRITICAL ERROR WARNING INFO MESSAGE DEBUG SPEW 0 1 2 3 4 5 6 \end{DoxySeeAlso} \begin{DoxyParams}{Parameters} {\em source} & \texorpdfstring{$<$}{<}\texorpdfstring{$>$}{>} \\ \hline \end{DoxyParams} \begin{DoxySeeAlso}{See also} enum fsm\+\_\+enum\+\_\+journal\+\_\+source in include/fsm.\+h \textquotesingle{}source\textquotesingle{} is a pre-\/defined value that can be associated to each event. It is not mandatory. It can be set to \textquotesingle{}NULL\textquotesingle{}. \end{DoxySeeAlso} \begin{DoxyParams}{Parameters} {\em \texorpdfstring{$\ast$}{*}file\+\_\+source} & \texorpdfstring{$<$}{<}\texorpdfstring{$>$}{>} the name of the file that emits the event. \\ \hline {\em \texorpdfstring{$\ast$}{*}function\+\_\+source} & \texorpdfstring{$<$}{<}\texorpdfstring{$>$}{>} the function that emits the event. \\ \hline {\em \texorpdfstring{$\ast$}{*}string\+\_\+value} & \texorpdfstring{$<$}{<}\texorpdfstring{$>$}{>} any value that can qualify the event and provides useful information when reading the log. \\ \hline \end{DoxyParams} \Hypertarget{fsm_2dispatch_8c_a435d1a5171a7d69662d701234722fee2}\label{fsm_2dispatch_8c_a435d1a5171a7d69662d701234722fee2} \index{dispatch.c@{dispatch.c}!fsm\_journal\_publication\_request@{fsm\_journal\_publication\_request}} \index{fsm\_journal\_publication\_request@{fsm\_journal\_publication\_request}!dispatch.c@{dispatch.c}} \doxysubsubsection{\texorpdfstring{fsm\_journal\_publication\_request()}{fsm\_journal\_publication\_request()}} {\footnotesize\ttfamily void fsm\+\_\+journal\+\_\+publication\+\_\+request (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})} The \doxylink{fsm_2dispatch_8c_a435d1a5171a7d69662d701234722fee2}{fsm\+\_\+journal\+\_\+publication\+\_\+request()} is called only once, by \doxylink{main_8c_a3c04138a5bfe5d72780bb7e82a18e627}{main()}, just after closing the app and before ending the program. This is to guarantee the chronological order of the events in the journal. The log is modified for each event but events can be send asynchronously. This is why the journal is only published once, before the end of "{}main()"{}, Its chronological order is therefore guaranteed. src/journal.\+c/fsm\+\_\+journal\+\_\+publish() (called here) is the last function of the program to be executed. The \doxylink{structfsm__struct__journal}{fsm\+\_\+struct\+\_\+journal} (gg\+\_\+logs) is a static instance in this file. Therefore, all the functions that read or write it are in this file. This is to avoid uncontrolled operations on it. \begin{DoxySince}{Since} 2024-\/08 \end{DoxySince} \begin{DoxySeeAlso}{See also} src/main/main() src/journal/fsm\+\_\+journal\+\_\+publish() \end{DoxySeeAlso} \Hypertarget{fsm_2dispatch_8c_ae921ecd39af67bb8dc0deb2cdc86125d}\label{fsm_2dispatch_8c_ae921ecd39af67bb8dc0deb2cdc86125d} \index{dispatch.c@{dispatch.c}!fsm\_set\_exec\_edit@{fsm\_set\_exec\_edit}} \index{fsm\_set\_exec\_edit@{fsm\_set\_exec\_edit}!dispatch.c@{dispatch.c}} \doxysubsubsection{\texorpdfstring{fsm\_set\_exec\_edit()}{fsm\_set\_exec\_edit()}} {\footnotesize\ttfamily void fsm\+\_\+set\+\_\+exec\+\_\+edit (\begin{DoxyParamCaption}\item[{int}]{choice }\end{DoxyParamCaption})} setter for the static value\+: \textquotesingle{}choice\+\_\+\+STATE\+\_\+\+RULES\+\_\+\+DATA\textquotesingle{} (in this file) see include/fsm enum fsm\+\_\+enum\+\_\+exec\+\_\+edit \{ EXEC, EDIT \} \begin{DoxySince}{Since} 2024-\/08 \end{DoxySince} \begin{DoxySeeAlso}{See also} src/signal \texorpdfstring{$\ast$}{*} 2 \end{DoxySeeAlso} \begin{DoxyParams}{Parameters} {\em choice} & \texorpdfstring{$<$}{<} a boolean value which can be "{}\+EXEC"{} or "{}\+EDIT"{} \\ \hline \end{DoxyParams} \Hypertarget{fsm_2dispatch_8c_a770bcaeb0bd6f81cddcc3cd506468fff}\label{fsm_2dispatch_8c_a770bcaeb0bd6f81cddcc3cd506468fff} \index{dispatch.c@{dispatch.c}!fsm\_set\_preferences\_modified@{fsm\_set\_preferences\_modified}} \index{fsm\_set\_preferences\_modified@{fsm\_set\_preferences\_modified}!dispatch.c@{dispatch.c}} \doxysubsubsection{\texorpdfstring{fsm\_set\_preferences\_modified()}{fsm\_set\_preferences\_modified()}} {\footnotesize\ttfamily void fsm\+\_\+set\+\_\+preferences\+\_\+modified (\begin{DoxyParamCaption}\item[{bool}]{value }\end{DoxyParamCaption})} setter for the static boolean\+: \textquotesingle{}preferences\+\_\+have\+\_\+been\+\_\+modified\textquotesingle{} \begin{DoxySince}{Since} 2024-\/08 \end{DoxySince} \begin{DoxySeeAlso}{See also} TODO To be used by any function that modifies the current user \doxylink{structpreferences}{preferences} \doxylink{fsm_2dispatch_8c_a8c67f42f95d48ee2469c9a27d65db3e6}{fsm\+\_\+journal\+\_\+event()} \end{DoxySeeAlso} \begin{DoxyParams}{Parameters} {\em value} & = TRUE if preferences\+\_\+have\+\_\+been\+\_\+modified. \\ \hline \end{DoxyParams} \Hypertarget{fsm_2dispatch_8c_af5a464b19589ba1972c9b3aa3397945a}\label{fsm_2dispatch_8c_af5a464b19589ba1972c9b3aa3397945a} \index{dispatch.c@{dispatch.c}!fsm\_set\_state\_rules\_data@{fsm\_set\_state\_rules\_data}} \index{fsm\_set\_state\_rules\_data@{fsm\_set\_state\_rules\_data}!dispatch.c@{dispatch.c}} \doxysubsubsection{\texorpdfstring{fsm\_set\_state\_rules\_data()}{fsm\_set\_state\_rules\_data()}} {\footnotesize\ttfamily void fsm\+\_\+set\+\_\+state\+\_\+rules\+\_\+data (\begin{DoxyParamCaption}\item[{int}]{choice }\end{DoxyParamCaption})} setter for the static value\+: \textquotesingle{}choice\+\_\+\+STATE\+\_\+\+RULES\+\_\+\+DATA\textquotesingle{} (in this file) see include/fsm enum fsm\+\_\+enum\+\_\+state\+\_\+rules\+\_\+data \{ SYNTH, STATE, RULES, DATA \} Today (2024-\/10) the initial page is set to \textquotesingle{}SYNTH\textquotesingle{}. \begin{DoxySeeAlso}{See also} line 292 choice\+\_\+\+STATE\+\_\+\+RULES\+\_\+\+DATA = SYNTH; NB This choice can be temporarily modified for debugging purpose\+: end of the function\+: \doxylink{fsm_2dispatch_8c}{fsm/dispatch.\+c} window\+\_\+design\+\_\+topbar\+\_\+left() \end{DoxySeeAlso} \begin{DoxySince}{Since} 2024-\/08 \end{DoxySince} \begin{DoxySeeAlso}{See also} src/signal \texorpdfstring{$\ast$}{*} 4 \end{DoxySeeAlso} \begin{DoxyParams}{Parameters} {\em choice} & \\ \hline \end{DoxyParams}