Next Previous Contents

3. TLMP components

3.1 gurumanage

gurumanage()

This is the main function used to initiate a gurus. It has a single tag called "exec". You connect to it either a gurupath component or any variations ( gurusteps, guruiter). Return -1 if the user aborted the process

        int gurumanage(
                _F_gurumanage&c,
                const char *title,
                const char *intro,
                HELP_FILE&help)
        

3.2 gurupath

#Specbeg: guru samples / basic gurupath ([samples.tlcc,9])

        /*
            The guruengine relies on the gurupath component. All other
            components (gurusteps, guruiter) are built on top of gurupath
            and present the same logic.
        
            A gurus is presented as a graph. Every node in the graph
            presents some dialog. The dialog may be only informative or
            may contains some input fields. Each node has a validation
            function (eval) and a presentation function (dialog).
        
            Further, if there are potentially other node to visit
            after a given one, then the various node are attached
            to the path1, path2, ..., path6 tags.
        
            If there are no path tag used, then the node represents
            the end of a process, the end of a branch of the graph.
        
            If there is a path1 tag and no path2, it means there is
            only one possible path, so the next node is presented on the
            same horizontal line as the current one.
        
            If there are two or more path tags (path1, path2, ...), then
            the next nodes  represent the start of independant branches
            in the graph.
        
            The following example, presents a graph with two branches
        */
        <mod>
        static void samples_gurupath()
        {
            <glocal>
                SSTRING str;
                SSTRING lmethod,umethod;
                SSTRING lextra,uextra;
            </glocal>
            int ret = <call gurumanage>("gurupath"
                ,"This is samples_gurupath()\n"
                 "It offers two ways of searching a string",help_nil);
                <f exec>
                    <call gurupath>(mode,status);
                        <f eval>
                            settitle ("Some name to search");
                            const char *s = glocal.str.get();
                            status.is_filled = s[0] != '\0';
                            status.some_errors = status.is_filled
                                && !isalpha(s[0]);
                        </f>
                        <f dialog>
                            setintro ("Enter a string to search");
                            dia.newf_str ("A string",glocal.str);
                            edit ();
                        </f>
                        <f path1>
                            <call gurupath>(mode,status);
                                <f eval>
                                    settitle ("Lower case search method");
                                    status.is_filled = !glocal.lmethod.is_empty();
                                    status.is_possible = glocal.str.cmp("Z") > 0;
                                </f>
                                <f dialog>
                                    dia.newf_str ("How to search",glocal.lmethod);
                                    edit();
                                </f>
                                <f path1>
                                    <call gurupath>(mode,status);
                                        <f eval>
                                            settitle ("Lower case extra strategy");
                                            status.is_filled = !glocal.lextra.is_empty();
                                        </f>
                                        <f dialog>
                                            dia.newf_str ("Lower case extra",glocal.lextra);
                                            edit();
                                        </f>
                                    </call>
                                </f>
                            </call>
                        </f>
                        <f path2>
                            <call gurupath>(mode,status);
                                <f eval>
                                    settitle ("Upper case search method");
                                    status.is_filled = !glocal.umethod.is_empty();
                                    status.is_possible = glocal.str.cmp("Z") <= 0;
                                </f>
                                <f dialog>
                                    dia.newf_str ("How to search",glocal.umethod);
                                    edit();
                                </f>
                                <f path1>
                                    <call gurupath>(mode,status);
                                        <f eval>
                                            settitle ("Upper case extra strategy");
                                            status.is_filled = !glocal.uextra.is_empty();
                                        </f>
                                        <f dialog>
                                            dia.newf_str ("Upper case extra",glocal.uextra);
                                            edit();
                                        </f>
                                    </call>
                                </f>
                            </call>
                        </f>
                    </call>
                </f>
            </call>
            if (ret != -1){
                xconf_notice ("Done!");
            }
        }
        </mod>

3.3 gurupath functions

gurupath()

        void gurupath(
                _F_gurupath&c,
                GURUPATH_MODE mode,
                GURUPATH_STATUS&status)
        

_F_gurupath::settitle()

        void _F_gurupath::settitle(
                const char *title)
        

_F_gurupath::setintro()

        void _F_gurupath::setintro(
                const char *text)
        

_F_gurupath::setterminal()

Record the information about a terminal node

        void _F_gurupath::setterminal(
                const char *shorttext,
                const char *longtext)
        

_F_gurupath::edit()

        bool _F_gurupath::edit(
                HELP_FILE&help)
        

_F_gurupath::edit()

        bool _F_gurupath::edit(
                void)
        

_F_gurupath::path1()

        void _F_gurupath::path1(
                GURUPATH_MODE,
                GURUPATH_STATUS&status)
        

_F_gurupath::dobutton()

        void _F_gurupath::dobutton(
                int)
        

3.4 gurusteps

#Specification: gurusteps / principles ([gurusteps.tlcc,1])

The gurusteps component is used when you have a bunch of steps one a single line (no branches). Instead of using the gurupath like this (only eval,dialog and path1 tags):

        <call gurupath)(...);
            <f eval>
            </>
            <f dialog>
            </f>
            <f path1>
                <call gurupath>(...);
                    <f eval>
                    </>
                    <f dialog>
                    </f>
                    <f path1>
                        <call gurupath>(...);
                            <f eval>
                            </>
                            <f dialog>
                            </f>
                            <f path1>
                                // One branche
                            </f>
                            <f path2>
                                // Another branche
                            </f>
                        </call>
                    </f>
                </call>
            </f>
        </call>
you do
        <call gurusteps>(...);
            <f eval1>
            </f>
            <f dialog1>
            </f>
            <f eval2>
            </f>
            <f dialog2>
            </f>
            <f eval3>
            </f>
            <f dialog3>
            </f>
            <f path1>
                // One branche
            </f>
            <f path2>
                // Another branche
            </f>
        </call>

3.5 gurusteps functions

gurusteps provides the following tags

gurusteps()

</mod>

        void gurusteps(
                _F_gurusteps&c,
                GURUPATH_MODE mode,
                GURUPATH_STATUS&status)

_F_gurusteps::settitle()

        void _F_gurusteps::settitle(
                const char *title)
        

_F_gurusteps::setintro()

        void _F_gurusteps::setintro(
                const char *intro)
        

_F_gurusteps::setterminal()

        void _F_gurusteps::setterminal(
                const char *s,
                const char *l)
        

_F_gurusteps::edit()

        bool _F_gurusteps::edit(
                void)
        

_F_gurusteps::edit()

        bool _F_gurusteps::edit(
                HELP_FILE&help)
        

_F_gurusteps::path1()

        void _F_gurusteps::path1(
                GURUPATH_MODE,
                GURUPATH_STATUS&status)
        

3.6 guruiter

#Specification: guruiter / principles ([guruiter.tlcc,1])

The guruiter may replace a gurusteps component if you have to repeat the same question a few time. Instead of having

        <call gurusteps>(...);
            <f eval1>
            </f>
            <f dialog1>
            </f>
            <f eval2>
            </f>
            <f dialog2>
            </f>
            <f eval3>
            </f>
            <f dialog3>
            </f>
            <f path1>
                // One branche
            </f>
            <f path2>
                // Another branche
            </f>
        </call>
you do
        <call guruiter>(3,...);
            <f eval>
                // The step parameter is supplied so you know where
                // you are in the iteration
            </f>
            <f dialog>
                // The step parameter is also provided here.
            </f>
            <f path1>
                // One branche
            </f>
            <f path2>
                // Another branche
            </f>
        </call>

3.7 guruiter functions

guruiter provides the following tags

guruiter()

</mod>

        void guruiter(
                _F_guruiter&c,
                int nbsteps,
                GURUPATH_MODE mode,
                GURUPATH_STATUS&status)

_F_guruiter::settitle()

        void _F_guruiter::settitle(
                const char *title)
        

_F_guruiter::setintro()

        void _F_guruiter::setintro(
                const char *intro)
        

_F_guruiter::setterminal()

        void _F_guruiter::setterminal(
                const char *s,
                const char *l)
        

_F_guruiter::edit()

        bool _F_guruiter::edit(
                void)
        

_F_guruiter::edit()

        bool _F_guruiter::edit(
                HELP_FILE&help)
        

_F_guruiter::path1()

        void _F_guruiter::path1(
                GURUPATH_MODE,
                GURUPATH_STATUS&status)
        

Next Previous Contents