In file modules/TclModule.h:

class TclModule : public AutoLink<TclModule>

Module description class

Inheritance:


Public Fields

static const char* tclModuleName
name of TclModule
static char* DefaultModulesPath
default path for libraries
static char* DefaultShellsPath
default path for TCL shells
static char* DefaultRessourceFileLocation
default ressource file directory
static char* RessourceModulesPath
prioritary path for libraries
static char* RessourceShellsPath
prioritary path for TCL shells
static bool verbose
verbose mode
static bool loadDynamically
if the modules should be loaded dynamically (dlopen) or statically

Public Methods

const TclString& getName (void) const
returns module name
Tcl_Interp* getInterp (void) const
returns module commands interpretor
HANDLE_TYPE getHandle (void) const
returns module dynamic library handle (0 if module was statically linked)
void displayFunctionList (void)
display all module TCL commands name
std::map < char *, CommandInformation *, CStringCompare > & getCommands (void)
returns module commands hashtable
TclModule* getMainModule (void) const
returns main application module
void newCommand (const char *name, int (*fct)(TclModule *, int, char **), const char *synopsis = 0, const char *description = 0)
builds a new Tcl command with a single callback function
void newCommand (const char *name, std::map < char *, CommandOption *, CStringCompare > *options, const char *description = 0)
registers a new Tcl command (not created here) in commands list
void display (const TclString& str) const
display a message calling display function
void display (const char *str) const
display a message calling display function
int eval (const TclString& str) const
display a TCL command calling eval function
int eval (const char *str) const
display a TCL command calling eval function
static void setDisplayFunction (DISPLAY_FUNCTION fct)
set a new display function
static void setEvalFunction (EVAL_FUNCTION fct)
set a new TCL commands evaluation function
static void setTCLDisplayFunction (const TclString& name)
set a new display function
static void setTCLEvalFunction (const TclString& name)
set a new TCL commands evaluation function
static DISPLAY_FUNCTION getDisplayFunction (void)
returns current display function
static EVAL_FUNCTION getEvalFunction (void)
returns current evaluation function
static const TclString& getTCLDisplayFunction (void)
returns current TCL display function name
static const TclString& getTCLEvalFunction (void)
returns current TCL evaluation function name
static void setMainLoop (LOOP_FUNCTION fct)
set main loop to handle TK events
static LOOP_FUNCTION getMainLoop (void)
returns main loop function
void resetResult (void)
reset result in module interpretor
void setResult (const TclString& str) const
set command result in module interpretor
void setResult (const char *str) const
set command result in module interpretor
int tickle (const TclString &s) const
Evaluates given string in module interpretor
void loadSource (const TclString& sname) throw(ShellNotFound)
Loads script file and evaluates it in module interpretor
bool windowExists (char *wname) const
test a TCL window existence
bool windowExists (const TclString& wname) const
test a TCL window existence
void newDescriptor (TclObjectKind *ok)
adds a new object descriptor created for this module
static TclModule* loadNewModule (Tcl_Interp *interp, const TclString& name) throw(DlopenFailed, ModuleNotFound, ModuleAlreadyExists, NoInitFunction)
creates a new module 'name' by dynamically loading file libname
static void shellSearchPath (TclString& path)
Returns TCL shells search paths
static void moduleSearchPath (TclString& path)
Returns modules search paths
static TclString* findLibrary (const TclString& name)
Looks for a dynamic library for module given by name
static TclModule* findModuleByName (const TclString& name)
returns TclModule pointer on module given by its name or 0 if module could not be found
static int init (MODULEMAINPROC mainProc, bool verbose, int argc, char **argv...)
initializes TCL, TK, core module, user modules and call application main procedure
static TclModule* init (Tcl_Interp *interp, const TclString& name)
initializes core module for other modules management
static void run (void)
infinite loop on TK events
static void run (unsigned int n)
n-loop on TK events
static void exit (int ret = 0)
call any module cleanup procedure and exit
static void Prompt (Tcl_Interp *interp, int partial)
print a prompt in text interface
static bool readrc (char *rfile, TclString& init, unsigned int& nbModules, TclString *& modules)
Read ressource file

Public

Exception classes
class DlopenFailed : public Exception
dynamic library loading failed
class ModuleNotFound : public Exception
named module could not be found
class ModuleAlreadyExists : public Exception
attempt to load a module already loaded
class NoInitFunction : public Exception
no initialization routine found for module
class ShellNotFound : public Exception
no TCL shell file found for module
Constructor
handle dynamic library handle (null if module was not dynamicaly loaded) (Tcl_Interp *interp, const TclString& name, HANDLE_TYPE handle = 0) throw(NoInitFunction)
builds a new module
Destructor
~TclModule ()
deletes module and any attached TCL command
void ... arguments (char *s...) const
Format given string in a printf-like manner and set result in interp
int ... arguments (const char *s... ) const
Format given string in a printf-like manner and evaluates command in module interpretor
boolean management
static const char* boolString (bool b)
returns "true" if b is true and "false" otherwise
static bool boolValue (char *str, bool& value)
set value to true and return true if str is "true", set value to false and return true if str is "false", return false otherwise
TCL static commands
static void DefaultDisplay (const TclModule &m, const char *str)
default display function: sends message on cerr
static int DefaultEval (const TclModule &m, const char *str)
default TCL commands evaluation function: calls Tcl_RecordAndEval
static void DefaultMainLoop (unsigned int n)
default main loop: handles TK events then activates active modules
static int Evaluate (TclModule *m, int argc, char **argv)
TCL evaluate command
static int Display (TclModule *m, int argc, char **argv)
TCL display command
static int Exit (TclModule *m, int argc, char **argv)
TCL exit command
static int Module (TclModule *m, int argc, char **argv)
TCL module command
static int Functions (TclModule *m, int argc, char **argv)
TCL functions command
static int Options (TclModule *m, int argc, char **argv)
TCL options command
static int IsModuleAvailable (TclModule *m, int argc, char **argv)
TCL isModuelAvailable command
static int IsModuleLoaded (TclModule *m, int argc, char **argv)
TCL isModuleLoaded command
static int Help (TclModule *m, int argc, char **argv)
TCL help command
static int LoadSource (TclModule *m, int argc, char **argv)
TCL loadSource command
static int SetDisplayMessageFunction (TclModule *m, int argc, char **argv)
TCL setDisplayFunction command
static int LimitedVersion (TclModule *m, int argc, char **argv)
TCL limited version command
static int SetEvalFunction (TclModule *m, int argc, char **argv)
TCL setEvalFunction command
static void activateWhenIdle (ClientData)
allow to activate activable object inside a script
static int StartScript (TclModule *m, int argc, char **argv)
TCL script command
static int EndScript (TclModule *m, int argc, char **argv)
TCL end command
static int FlushEvents (TclModule *m, int argc, char **argv)
TCL flushEvents command
static int ActivateActivables (TclModule *m, int argc, char **argv)
TCL activateActivables command
static int MainLoop (TclModule *m, int argc, char **argv)
TCL mainLoop command
static int Shell (TclModule *m, int argc, char **argv)
TCL shellsPath command
static int xgrabCmd (TclModule *m, int argc, char **argv)
TCL xgrab command

Protected Fields

Tcl_Interp* interp
module TCL interpretor
const TclString name
module name
HANDLE_TYPE handle
module dynamic library handle
std::map < char *, CommandInformation *, CStringCompare > commands
module TCL commands hashtable
std::list <TclObjectKind *> descriptor
object descriptors constructed by this module
static DISPLAY_FUNCTION displayFct
display function callback to display messages
static TclString TCLdisplayCommandName
TCL display function callback
static EVAL_FUNCTION evalFct
evaluation function callback to evaluate TCL commands
static TclString TCLevalCommandName
TCL evaluation function callback
static LOOP_FUNCTION loopFct
main application loop function

Private Fields

static const char* booleans [2]
the "true" and "false" string constants
static int initargc
main application number of command line arguments
static char** initargv
main application command line arguments
static unsigned int nmodules
number of modules
static char** modulenames
module names
static TclModule* coremodule
application core module

Private Methods

void(*resolveSymbol(const TclString& initFct)) (TclModule*)
Tries to perform symbolic resolution given a function name
static int(*mainProc) (TclModule *, int, char **)
application main procedure
static int main (Tcl_Interp *)
Tk_Main hook procedure

Documentation

Module description class
Exception classes

class DlopenFailed: public Exception
dynamic library loading failed

class ModuleNotFound: public Exception
named module could not be found

class ModuleAlreadyExists: public Exception
attempt to load a module already loaded

class NoInitFunction: public Exception
no initialization routine found for module

class ShellNotFound: public Exception
no TCL shell file found for module

static const char* tclModuleName
name of TclModule

Tcl_Interp* interp
module TCL interpretor

const TclString name
module name

HANDLE_TYPE handle
module dynamic library handle

std::map < char *, CommandInformation *, CStringCompare > commands
module TCL commands hashtable

std::list <TclObjectKind *> descriptor
object descriptors constructed by this module

static DISPLAY_FUNCTION displayFct
display function callback to display messages

static TclString TCLdisplayCommandName
TCL display function callback

static EVAL_FUNCTION evalFct
evaluation function callback to evaluate TCL commands

static TclString TCLevalCommandName
TCL evaluation function callback

static LOOP_FUNCTION loopFct
main application loop function

Constructor

handle dynamic library handle (null if module was not dynamicaly loaded) (Tcl_Interp *interp, const TclString& name, HANDLE_TYPE handle = 0) throw(NoInitFunction)
builds a new module

Destructor

~TclModule()
deletes module and any attached TCL command

const TclString& getName(void) const
returns module name

Tcl_Interp* getInterp(void) const
returns module commands interpretor

HANDLE_TYPE getHandle(void) const
returns module dynamic library handle (0 if module was statically linked)

void displayFunctionList(void)
display all module TCL commands name

std::map < char *, CommandInformation *, CStringCompare > & getCommands(void)
returns module commands hashtable

TclModule* getMainModule(void) const
returns main application module

void newCommand(const char *name, int (*fct)(TclModule *, int, char **), const char *synopsis = 0, const char *description = 0)
builds a new Tcl command with a single callback function
Parameters:
name - command name
fct - command callback function
synopsis - command synopsis
description - command effect description

void newCommand(const char *name, std::map < char *, CommandOption *, CStringCompare > *options, const char *description = 0)
registers a new Tcl command (not created here) in commands list
Parameters:
name - command name
options - command options hashtable
description - command effect description

void display(const TclString& str) const
display a message calling display function
Parameters:
str - message to display

void display(const char *str) const
display a message calling display function
Parameters:
str - message to display

int eval(const TclString& str) const
display a TCL command calling eval function
Parameters:
str - TCL command to evaluate

int eval(const char *str) const
display a TCL command calling eval function
Parameters:
str - TCL command to evaluate

static void setDisplayFunction(DISPLAY_FUNCTION fct)
set a new display function
Parameters:
fct - display function pointer

static void setEvalFunction(EVAL_FUNCTION fct)
set a new TCL commands evaluation function
Parameters:
fct - evaluation function pointer

static void setTCLDisplayFunction(const TclString& name)
set a new display function
Parameters:
fct - TCL display function name

static void setTCLEvalFunction(const TclString& name)
set a new TCL commands evaluation function
Parameters:
fct - TCL evaluation function name

static DISPLAY_FUNCTION getDisplayFunction(void)
returns current display function

static EVAL_FUNCTION getEvalFunction(void)
returns current evaluation function

static const TclString& getTCLDisplayFunction(void)
returns current TCL display function name

static const TclString& getTCLEvalFunction(void)
returns current TCL evaluation function name

static void setMainLoop(LOOP_FUNCTION fct)
set main loop to handle TK events
Parameters:
fct - main loop function pointer (cannot be 0)

static LOOP_FUNCTION getMainLoop(void)
returns main loop function

void resetResult(void)
reset result in module interpretor

void setResult(const TclString& str) const
set command result in module interpretor
Parameters:
str - result

void setResult(const char *str) const
set command result in module interpretor
Parameters:
str - result

void ... arguments (char *s...) const
Format given string in a printf-like manner and set result in interp

int ... arguments(const char *s... ) const
Format given string in a printf-like manner and evaluates command in module interpretor
Returns:
TCL_OK if the command successfully evaluated, TCL_ERROR otherwise

int tickle(const TclString &s) const
Evaluates given string in module interpretor
Returns:
TCL_OK if the command successfully evaluated, TCL_ERROR otherwise
Parameters:
s - string to evaluate

void loadSource(const TclString& sname) throw(ShellNotFound)
Loads script file and evaluates it in module interpretor. File is looked for in YAV_SHELLS environnement variable, DefaultShellPath directory, and current directory.
Throws:
ShellNotFound script file was not found
Parameters:
sname - script file name

bool windowExists(char *wname) const
test a TCL window existence
Returns:
true if wname exists for this module, false otherwise
Parameters:
wname - TCL window name

bool windowExists(const TclString& wname) const
test a TCL window existence
Returns:
true if wname exists for this module, false otherwise
Parameters:
wname - TCL window name

void newDescriptor(TclObjectKind *ok)
adds a new object descriptor created for this module

void (*resolveSymbol(const TclString& initFct))(TclModule*)
Tries to perform symbolic resolution given a function name. Attempt several C++ compilers mangling resolution for a function whose name is known and taking an only TclModule * argument.
Returns:
pointer to the function body if resolution succedded, or 0 otherwise
Parameters:
initFct - function name

static TclModule* loadNewModule(Tcl_Interp *interp, const TclString& name) throw(DlopenFailed, ModuleNotFound, ModuleAlreadyExists, NoInitFunction)
creates a new module 'name' by dynamically loading file libname.so from YAV_SHELLS, TclDefaultShellsPath or current directory
Throws:
DlopenFailed dlopen call failed to open dynamic library
ModuleNotFound libname.so dynamic library could not be found
ModuleAlreadyExists module was already loaded
Parameters:
interp - module TCL interpretor
name - module name

static void shellSearchPath(TclString& path)
Returns TCL shells search paths. This is the concatenation of .yavrc shells fields, YAV_SHELLS environment variable, and default shells paths.
Parameters:
path - returned paths separated by ':'

static void moduleSearchPath(TclString& path)
Returns modules search paths. This is the concatenation of .yavrc libraries fields, TCL_MODULES environment variable, LD_LIBRARY_PATH environment variable and default modules paths.
Parameters:
path - returned paths separated by ':'

static TclString* findLibrary(const TclString& name)
Looks for a dynamic library for module given by name. Library name is lib{MODULE_NAME}.so. Search path is TCL_MODULES environnment variable, LD_LIBRARY_PATH environnement variable and DefaultModulesPath
Returns:
a pointer on a TclString containing the full library path name or 0 if the library could not be found.
Parameters:
name - module name

static TclModule* findModuleByName(const TclString& name)
returns TclModule pointer on module given by its name or 0 if module could not be found
Parameters:
name - module name

static int init(MODULEMAINPROC mainProc, bool verbose, int argc, char **argv...)
initializes TCL, TK, core module, user modules and call application main procedure
Parameters:
mainProc - application main procedure
verobse - whether to print lots of informations...
argc - number of command line arguments
argv - command line arguments list
... - null terminated list of strings indicating module names

static TclModule* init(Tcl_Interp *interp, const TclString& name)
initializes core module for other modules management
Returns:
core module pointer
Parameters:
interp - core module TCL interpretor
name - module name

static void run(void)
infinite loop on TK events

static void run(unsigned int n)
n-loop on TK events
Parameters:
n - number of iteration

static void exit(int ret = 0)
call any module cleanup procedure and exit
Parameters:
ret - shell return value

static void Prompt(Tcl_Interp *interp, int partial)
print a prompt in text interface

boolean management

static const char* boolString(bool b)
returns "true" if b is true and "false" otherwise

static bool boolValue(char *str, bool& value)
set value to true and return true if str is "true", set value to false and return true if str is "false", return false otherwise
Returns:
true if str is "true" or "false", false otherwise
Parameters:
str - string
value - str boolean value (if str is "true" or "false")

TCL static commands

static void DefaultDisplay(const TclModule &m, const char *str)
default display function: sends message on cerr
Parameters:
m - calling module
str - message to display

static int DefaultEval(const TclModule &m, const char *str)
default TCL commands evaluation function: calls Tcl_RecordAndEval
Returns:
TCL_OK if command succesfully evaluated, TCL_ERROR otherwise
Parameters:
m - calling module
str - command to evaluate

static void DefaultMainLoop(unsigned int n)
default main loop: handles TK events then activates active modules
Parameters:
n - number of loops

static int Evaluate(TclModule *m, int argc, char **argv)
TCL evaluate command

static int Display(TclModule *m, int argc, char **argv)
TCL display command

static int Exit(TclModule *m, int argc, char **argv)
TCL exit command

static int Module(TclModule *m, int argc, char **argv)
TCL module command

static int Functions(TclModule *m, int argc, char **argv)
TCL functions command

static int Options(TclModule *m, int argc, char **argv)
TCL options command

static int IsModuleAvailable(TclModule *m, int argc, char **argv)
TCL isModuelAvailable command

static int IsModuleLoaded(TclModule *m, int argc, char **argv)
TCL isModuleLoaded command

static int Help(TclModule *m, int argc, char **argv)
TCL help command

static int LoadSource(TclModule *m, int argc, char **argv)
TCL loadSource command

static int SetDisplayMessageFunction(TclModule *m, int argc, char **argv)
TCL setDisplayFunction command

static int LimitedVersion(TclModule *m, int argc, char **argv)
TCL limited version command

static int SetEvalFunction(TclModule *m, int argc, char **argv)
TCL setEvalFunction command

static void activateWhenIdle(ClientData)
allow to activate activable object inside a script

static int StartScript(TclModule *m, int argc, char **argv)
TCL script command

static int EndScript(TclModule *m, int argc, char **argv)
TCL end command

static int FlushEvents(TclModule *m, int argc, char **argv)
TCL flushEvents command

static int ActivateActivables(TclModule *m, int argc, char **argv)
TCL activateActivables command

static int MainLoop(TclModule *m, int argc, char **argv)
TCL mainLoop command

static int Shell(TclModule *m, int argc, char **argv)
TCL shellsPath command

static int xgrabCmd(TclModule *m, int argc, char **argv)
TCL xgrab command

static const char* booleans[2]
the "true" and "false" string constants

static int initargc
main application number of command line arguments

static char** initargv
main application command line arguments

static unsigned int nmodules
number of modules

static char** modulenames
module names

static TclModule* coremodule
application core module

static int (*mainProc)(TclModule *, int, char **)
application main procedure

static int main(Tcl_Interp *)
Tk_Main hook procedure

static char* DefaultModulesPath
default path for libraries

static char* DefaultShellsPath
default path for TCL shells

static char* DefaultRessourceFileLocation
default ressource file directory

static char* RessourceModulesPath
prioritary path for libraries

static char* RessourceShellsPath
prioritary path for TCL shells

static bool verbose
verbose mode

static bool loadDynamically
if the modules should be loaded dynamically (dlopen) or statically

static bool readrc(char *rfile, TclString& init, unsigned int& nbModules, TclString *& modules)
Read ressource file. Ressource file is searched in: - if rfile == 0: ${HOME}/.yavrc DEFAULT_RESSOURCE_FILE_LOCATION/.yavrc - if rfile != 0: rfile ${HOME}/rfile DEFAULT_RESSOURCE_FILE_LOCATION/rfile
Returns:
true if a file was found and successfully loaded, false otherwise
Parameters:
rfile - ressource file name
init - returned initialization String
nbModules - returned number of modules
modules - returned module names array


This class has no child classes.

alphabetic index hierarchy of classes


this page has been generated automatically by doc++

(c)opyright by Malte Zöckler, Roland Wunderling
contact: doc++@zib.de