The DejaVU Framework -- hush 3.1
[.] Papers Tutorials Examples Manuals Interfaces Sources Packages Resources ?

Manual: SESSION 4 1995


[.] [man] man1 man2 man3 man4 man5 man6 man7 man8 man9 manl mann ?

NAME

session -- to manage the application

SYNOPSIS


An application object derived from session is needed to start the application. The session class encapsulates the (X window) main loop that catches all events for you. It also takes care of initializing the embedded interpreter. The preferred way of using the session class is by deriving a class, say application, in which you define the application and take care of initializing what must be initialized.


slide: SYNOPSIS

INTERFACE


    interface session  {              
<hush/session.h>

sources/java/hush.dv.api.session

session(int argc, char** argv, char* name = 0); virtual void prelude();
to do some additional initialization

virtual int main( );
defines the functionality

int run( );
to start the application

static statistics( char* opt = 0 );
to obtain statistics

void trace(int = 1);
to set global trace variable

// advanced users / system level void map();
to define window mapping

int loop(int fl=0);
to redefine the main loop

int body(int fl=0);
is executed for each iteration

};

slide: INTERFACE

DESCRIPTION


To initialize an instance of the kit and to start the main (event dispatch) loop an instance of session must be created. Per application there may only be one instance of session. The class session has been inspired directly by a similar class in the InterViews library. However, programs written with hush may also be used as an interpreter for tcl scripts. Consequently, the class session offers functions to initialize (prelude) and install (main) the functionality needed apart from a function to start the main loop (run). When creating a session object, the name of the application may be given as the last parameter. Under this name, the application is known to other Tk applications, that may communicate with eachother by means of the send command. The preferred form of creating a session is by deriving an application class from session. The main program may then be specified by overriding the virtual function main. The, otherwise empty, function prelude may be overridden to initialize widgets when the program is used for scripts only. The function run is called to start the main loop. The parameter of run may specify a program function to be executed. To execute both a script and the program function specified for run, the script must contain the command go-back as its last command. In either case, the main loop must be started by calling run. The function session::statistics may be used to obtain some statistics on the number of objects ceated and deleted. The global trace variable may be uset by calling trace(0). The default is on, to allow for checking on resource management.


slide: DESCRIPTION

EXAMPLE


  #include <hush.h>
  class application : public session {
  public:
  application(int argc, char* argv[]) : session(argc,argv,"hello") {
          trace(0); 
to turn the global trace off

} void main() {
application::main

tk->
trace(2);
makes all events for the kit visible

message* m = new message(".m","hello world"); _register(m);
to register the widget for deletion

m->pack(); } void main(int argc, char* argv[]) { session* s = new application(argc,argv); s->run();
start the main loop

delete s;
destroy the session

session::statistics();
and inspect the resources used

}
In practice a more simple form may be used, see the examples. See also examples:hush/statistics.c.
slide: EXAMPLE

SUBCLASSES


    tcl_session -- implements the default session class
  

slide: SUBCLASSES

USAGE


The average user creates an application object as indicated above. Refining the session::loop or session::body functions is for advanced users only. Consult The Hush System Reference Manual (if available).


slide: USAGE

WARNING


When the name parameter of session is 0, then no window will be mapped!


slide: WARNING

REMARKS


The example shows a "hello world" program for the hush toolkit. It displays the typical program structure, and it comparable in size to the "hello world" program for ordinary C++.


slide: REMARKS

LIBRARY


hush -- file <hush/session.h>


slide: LIBRARY

SEE ALSO

kit(4)
[.] Papers Tutorials Examples Manuals Interfaces Sources Packages Resources ?
Hush Online Technology
hush@cs.vu.nl
09/24/99