next up previous contents index
Next: 3.4.1 Creating and Destroying Up: 3.4 Class TclObject Previous: Differences from  v1 Example configuration of a TclObject

The following example illustrates the configuration of an SRM agent (Agent/SRM/Adaptive../ns-2/srm-adaptive.tcl).
        set srm [new Agent/SRM/Adaptive]
        $srm set packetSize_ 1024
        $srm traffic-source $s0
By convention in , the class Agent/SRM/Adaptive is a subclass of Agent/SRM, is a subclass of Agent, is a subclass of TclObject. The corresponding compiled class hierarchy is the ASRMAgent, derived from SRMAgent, derived from Agent, derived from TclObject respectively. The first line of the above example shows how a TclObject is created (or destroyed)Sectionsec:Creation; the next line configures a bound variableSectionsec:VarBinds; and finally, the last line illustrates the interpreted object invoking a C++ method as if they were an instance procedureSectionsec:Commands.