node.tcl 997 Bytes
Newer Older
Mac Newbold's avatar
Mac Newbold committed
1 2 3 4 5 6 7
Class node

#print

# output format is: nodeID type link(s)
node instproc print {file} {
    global nodeid_map
8
    global prefix
Mac Newbold's avatar
Mac Newbold committed
9 10 11 12 13 14 15

    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
16 17 18
    if {! [info exists nodelinks]} {
	set nodelinks {}
    }
Mac Newbold's avatar
Mac Newbold committed
19 20
    puts -nonewline $file "$nodename [$self set type]"
    foreach link $nodelinks {
21
	puts -nonewline $file " $prefix-$link"
Mac Newbold's avatar
Mac Newbold committed
22 23 24 25 26 27 28 29 30 31 32 33 34
    }
    #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} {
35 36
    $self instvar nodelinks
    lappend nodelinks $link 
Mac Newbold's avatar
Mac Newbold committed
37
}
38 39 40 41 42 43 44 45 46 47 48 49 50 51

#getLan/setLan

node instproc setLan {lan} {
    $self set lan $lan
}

node instproc getLan {} {
    $self instvar lan
    if {![info exists lan]} {
	$self set lan ""
    }
    return [$self set lan]
}