3.2 Code Overview

In this document, we use the term ``interpreter'' to be synonymous with the OTcl interpreter. The code to interface with the interpreter resides in a separate directory, tclcl. The rest of the simulator code resides in the directory, ns-2. We will use the notation ~tclcl/file to refer to a particular file in the Tcl directory. Similarly, we will use the notation, ~ns/file to refer to a particular file in the ns-2 directory.

There are a number of classes defined in ~tclcl/. We only focus on the six that are used in ns: The Class TclSectionsec:Tcl contains the methods that C++ code will use to access the interpreter. The class TclObjectSectionsec:TclObject is the base class for all simulator objects that are also mirrored in the compiled hierarchy. The class TclClassSectionsec:TclClass defines the interpreted class hierarchy, and the methods to permit the user to instantiate TclObjects. The class TclCommandSectionsec:TclCommand is used to define simple global interpreter commands. The class EmbeddedTclSectionsec:EmbeddedTcl contains the methods to load higher level builtin commands that make configuring simulations easier. Finally, the class InstVarSectionsec:InstVar contains methods to access C++ member variables as OTcl instance variables.

The procedures and functions described in this chapter can be found in ~tclcl/Tcl.{cc, h}, ~tclcl/Tcl2.cc, ~tclcl/tcl-object.tcl, and, ~tclcl/tracedvar.{cc, h}. The file ~tclcl/tcl2c++.c is used in building ns, and is mentioned briefly in this chapter.

Tom Henderson 2011-11-05