DejaVu -- The Framework

The problem addressed in the DejaVu project is essentially to provide support for the software engineering of (moderately complex) applications that require, apart from other functionality, multimedia interfaces and associative online help. Such support is primarily offered in the form of class libraries, most of which are written in C++. The language C++ was chosen for pragmatic reasons, since it allows for easily wrapping public domain software written in C in classes with a more user-friendly interface.

Application development generally encompasses a variety of programming tasks, including system-level software development (for example for networking or multimedia functionality), programming the user interface (including the definition of screen layout and the responsivity of the interface widgets to user actions), and the definition of (high-level) application-specific functionality. Each of these kinds of tasks may require a different approach and possibly a different application programming language. For example, the development of the user interface is often more conveniently done using a scripting language, to avoid the waiting times involved in compiling and linking. Similarly, defining knowledge-level application-specific functionality may benefit from the use of a declarative or logic programming language  [ Eliens92].

In our project, we decided from the start to support a multi-paradigm approach to software development and consequently we had to define the mutual interaction between the various language paradigms, as for example the interaction between C++ and a scripting language, such as Tcl  [ Tcl]. Current scripting languages, including Python  [ Python] and Tcl, provide facilities for being embedded in C and C++, but extending and employing these languages in C or C++ is rather cumbersome. The hush library  [ Eliens95b] offers a uniform interface to a number of script languages, and in addition, it offers a variety of widgets and multimedia extensions, that are accessible through any of the script interpreters as well as the C++ interface.

Idioms and Patterns

To realize the functionality of hush and its extensions, we employed some basic idioms and patterns  [ GOF94] derived from the handle/body idiom that was originally introduced in  [ Coplien92], notably the virtual self-reference idiom and the dynamic role-switching idiom.

Virtual self-reference

The virtual self-reference idiom has been introduced to support the development of compound widgets. It allows for (re)using the script and C++ interface of possibly compound widgets, by employing explicit redirection to an inner or primary component. Every widget can delegate part of its functionality to an inner component. It is common practice to derive a compound widget from another widget by using interface inheritance only, and to delegate functionality to an inner component by explicit redirection.

Dynamic role-switching

The dynamic role-switching idiom provides a means to offer a multitude of functional modes simultaneously. For example, a single kit object gives access to multiple (embedded) script interpreters, as well as a remote kit. The idiom is essential in supporting the multi-paradigm nature of the DejaVu framework. In our description of the design of the Web components in section Design, we will show how dynamic role-switching is employed for using various network protocols via the same (net)client class. The idiom is also used to define a (single) viewer class that is capable of displaying documents of various MIME-types (including SGML, HTML and VRML).

The Components

The hush library contains the classes providing the interface to the embedded script interpreter(s) and the classes allowing for a smooth interaction with the underlying window system, including the kit, event, handler, widget and item classes. In addition to these, hush provides the class session. Application programmers are minimally required to derive a class, say application, from session and redefine the function main. When the program is to be used as a windowing shell, the function prelude may be redefined to allow for initializing external packages or other components of the DejaVu framework. The extensions of hush include



slide: The hush extensions

User interface widgets

The hush widget library contains classes for a variety of user interface widgets, including the classes button, menu, text, canvas, filechooser and many more  [ Eliens95b]. A widget allows for binding an independently defined handler to user actions. Alternatively, a widget may declare itself to be its own handler. Allowing for delegating to an external handler helps to avoid cluttering the class name space. On the other hand, employing inheritance may result in a significant reuse of initialization code.

Simulation modeling support

Our interest in discrete event simulation was accidentally aroused by the need to provide support for Business Mathematics courses  [ BolEl94]. The simulation package we developed is fully integrated with hush, which allows the simulation developer to use the animation and hypertextual facilities offered by hush. The package provides the following classes



slide: Simulation classes

The class event (used in the simulation package) contains functions to determine the status of an event. For example, an event may be conditional (which means that it will be tried for each cycle of the scheduler) or pending (which means that its activation will be delayed until it becomes active or conditional). The library also contains a class entity representing processes, or active objects. An entity may be regarded as a ``structured event'', that is as an active object with phases in its life-cycle. In our approach, however, an explicit switch on the entity's phases must be included in the definition of the event.

Software sound facilities

Sound facilities are an essential ingredient of a framework supporting multimedia. Sound may be produced from a stored audio file or, provided that real-time sound synthesis facilities are available, from some high level representation in a sound or music description language. Apart from a reduction in the storage capacity needed (and correspondingly, the network traffic load in a distributed environment), employing a high level music/sound description language has as an additional advantage that improved synchronization and linking facilities may be offered. The DejaVu framework supports both MIDI and the sound synthesis facilities offered by Csound  [ Csound]. When creating an instance of the icsound class a process is created which is capable of receiving sound events, as defined by the Csound numerical score language, and converting these events to data for the audio device. (The icsound class inherits from a wrapper class providing the functionality for spawning of a new process that communicates with the original process via pipes.) Care is taken that the audio device is connected only once. However, multiple instances of the icsound class may exist. In addition to the icsound class, which accepts only low level sound events, instances of player may be used which accept musical events defined in the high level music description language Scot, that comes with Csound. The player class is also a handler. This allows instances of player to be embedded in scripts, as well as being activated by user-defined events.

Digital video

Digital video may be considered as another standard ingredient of hypermedia and multimedia frameworks. To employ digital video, our framework offers the class video. Apart from the usual widget creation commands, the class video has functions for reading in a video file, to play (forward) and to rewind. In addition, it offers a function to bind a frame number to an event. Binding frame numbers to events allows for both synchronization and hyperlinking, albeit in a low level fashion. Our video extension is based on the public domain xanim package and includes support for MPEG, AVI and Quicktime.

3D graphics and VRML

Another exciting development is the introduction of VRML  [ VRML] as a standard for developing 3D graphics and virtual reality on the Web. We have extended hush with widgets for displaying 3D graphics (based on the public domain Mesa  [ Mesa] library for OpenGL) and VRML scenes (based on an extension of the public domain Qvlib  [ Qvlib] parser). Due to the extensibility of our Web (browser) components, these widgets can easily be incorporated as special (Web-aware) viewers in the browser.