12.07.2015 Views

The ns Manual (formerly ns Notes and Documentation)1 - NM Lab at ...

The ns Manual (formerly ns Notes and Documentation)1 - NM Lab at ...

The ns Manual (formerly ns Notes and Documentation)1 - NM Lab at ...

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

• tcl.enter(TclObject* o) will i<strong>ns</strong>ert a pointer to the TclObject o into the hash table.It is used by TclClass::cre<strong>at</strong>e_shadow() to i<strong>ns</strong>ert an object into the table, when th<strong>at</strong> object is cre<strong>at</strong>ed.• tcl.lookup(char* s) will retrieve the TclObject with the name s.It is used by TclObject::lookup().• tcl.remove(TclObject* o) will delete references to the TclObject o from the hash table.It is used by TclClass::delete_shadow() to remove an existing entry from the hash table, when th<strong>at</strong> object isdeleted.<strong>The</strong>se functio<strong>ns</strong> are used internally by the class TclObject <strong>and</strong> class TclClass.3.3.6 Other Oper<strong>at</strong>io<strong>ns</strong> on the InterpreterIf the above methods are not sufficient, then we must acquire the h<strong>and</strong>le to the interpreter, <strong>and</strong> write our own functio<strong>ns</strong>.• tcl.interp(void) retur<strong>ns</strong> the h<strong>and</strong>le to the interpreter th<strong>at</strong> is stored within the class Tcl.3.4 Class TclObjectclass TclObject is the base class for most of the other classes in the interpreted <strong>and</strong> compiled hierarchies. Every objectin the class TclObject is cre<strong>at</strong>ed by the user from within the interpreter. An equivalent shadow object is cre<strong>at</strong>ed in the compiledhierarchy. <strong>The</strong> two objects are closely associ<strong>at</strong>ed with each other. <strong>The</strong> class TclClass, described in the next section, contai<strong>ns</strong>the mechanisms th<strong>at</strong> perform this shadowing.In the rest of this document, we often refer to an object as a TclObject 1 . By this, we refer to a particular object th<strong>at</strong> is eitherin the class TclObject, or in a class th<strong>at</strong> is derived from the class TclObject. If it is necessary, we will explicitly qualifywhether th<strong>at</strong> object is an object within the interpreter, or an object within the compiled code. In such cases, we will use theabbrevi<strong>at</strong>io<strong>ns</strong> “interpreted object”, <strong>and</strong> “compiled object” to distinguish the two. <strong>and</strong> within the compiled code respectively.Differences from <strong>ns</strong> v1 Unlike <strong>ns</strong> v1, the class TclObject subsumes the earlier functio<strong>ns</strong> of the NsObject class. It thereforestores the interface variable bindings (Section 3.4.2) th<strong>at</strong> tie OTcl i<strong>ns</strong>tance variables in the interpreted object to correspondingC++ member variables in the compiled object. <strong>The</strong> binding is stronger than in <strong>ns</strong> v1 in th<strong>at</strong> any changes to the OTcl variablesare trapped, <strong>and</strong> the current C++ <strong>and</strong> OTcl values are made co<strong>ns</strong>istent after each access through the interpreter. <strong>The</strong> co<strong>ns</strong>istencyis done through the class I<strong>ns</strong>tVar (Section 3.8). Also unlike <strong>ns</strong> v1, objects in the class TclObject are no longer stored asa global link list. I<strong>ns</strong>tead, they are stored in a hash table in the class Tcl (Section 3.3.5).Example configur<strong>at</strong>ion of a TclObjectAgent/SRM/Adaptive).<strong>The</strong> following example illustr<strong>at</strong>es the configur<strong>at</strong>ion of an SRM agent (classset srm [new Agent/SRM/Adaptive]$srm set packetSize_ 1024$srm traffic-source $s01 In the l<strong>at</strong>est release of <strong>ns</strong> <strong>and</strong> <strong>ns</strong>/tclcl, this object has been renamed to SplitObjefct, which more accur<strong>at</strong>ely reflects its n<strong>at</strong>ure of existence. However,for the moment, we will continue to use the term TclObject to refer to these objects <strong>and</strong> this class.23

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!