Content-type: text/html Man page of Tracing TCL Variables in C++

Tracing TCL Variables in C++

Section: NSCL Data analysis package (3)
Updated: 0.1
Index Return to Main Contents



 

NAME

Tracing Intro - Introduction to tracing TCL Variables in C++.  

SYNOPSIS


CTracedVariable         - A traced TCL Variable class.
CVariableTraceCallback  - A callback class base class for tracing.
CLanguageTraceCallback  - A callback that relays to unbound functions.

 

DESCRIPTION

TCL supports planting traces on variables. A trace results in an invocation of a function whenever certain actions are performed on the specific variable. The actions that can be monitored include:

- Read access
If a traced variable has a read trace installed, any time the value of the variable is evaluated, the corresponding trace is invoked. Samples access include:

     set var                 ;# var is evaluated, trace invoked.
     set a [expr $var * 2]   ;# var is evaluated, trace invoked.

     CTCLVariable var(pInterp,"var", kfFALSE);
     var.Get();             // Any traces set are invoked.

- Write access
If a variable has a write trace installed, any time the value of the variable is modified, write traces are invoked. For example:

     incr var                ;# var is modified, write traces invoked.
     set var 5               ;# Var is modified, write traces invoked.

     CTCLVariable var(pInterp, "var", kfFALSE);
     var.Set("Abcde");       // Var modified, write traces invoked.

- Unset
If a variable has an unset trace installed, it will be invoked when the variable is destroyed. This will happen as well, if the interpreter itself is begin destroyed, for example:

     unset var              ;# unset traces on var destroyed.

     Tcl_DeleteInterp(pInterp); ;# Unset traces get called.


 Tracing in the TCL++ library is accomplished by overriding the CTCLVariable class, supplying behavior for the function call operator (operator()), and turning on tracing. This is simplified through the introduction of a set of related classes:

CTracedVariable
This class is derived from CTCLVariable. At construction time, it accepts a callback parameter and trace flags. The callback parameter is an object derived from type CVariableTraceCallback. When the trace fires the CTracedVariable class delegates the traceback functionality to the operator() of the callback object.
CVariableTraceCallback
This class is an abstract base class that defines the interface for trace callback objects. To use tracing, you will need to derive a class from CVariableCallback, supplying behavior for the operator() member function. You then create a CTracedVariable and, pass an object of your callback type as the callback parameter to the CTracedVariable's constructor.
CLanguageTraceCallback
Often, it is not necessary to have the full context of an object to execute a traceback. The CLanguageTraceCallback is a pre-built trace callback object that delegates the trace to an ``unbound'' function. Unbound functions are C++ terminology for functions that are not part of a class. This object can also be used to delegate trace callbacks to functions not written in C++.
 

SEE ALSO

CTCLTracedVariable(3), CVariableTraceCallback(3), CLanguageTraceCallback(3)
 

Index

NAME
SYNOPSIS
DESCRIPTION
SEE ALSO

This document was created by man2html, using the manual pages.
Time: 14:18:39 GMT, February 25, 2005