node.tcl 700 Bytes
Newer Older
Mac Newbold's avatar
Mac Newbold committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
Class node

#print

# output format is: nodeID type link(s)
node instproc print {file} {
    global nodeid_map

    if {[info exists nodeid_map(n[$self set id])]} {
	set nodename $nodeid_map(n[$self set id])
    } else {
	set nodename n[$self set id]
    }
    $self instvar nodelinks
    puts -nonewline $file "$nodename [$self set type]"
    foreach link $nodelinks {
	puts -nonewline $file " $link"
    }
    #we have to add ". bandwidth delay" to delay nodes.
    if [string match [$self set type] delay] {
	puts -nonewline $file " . [$self set bw] [$self set delay]"
    }
    
    puts $file ""  
}


#add link

node instproc addlink {link} {
$self instvar nodelinks
lappend nodelinks $link 
}