我在Itcl中编写了以下代码,当我使用eclipse IDE对其进行调试时,我看到程序正在创建SystemNode的实例,并且在删除此已创建的SystemNode之后,程序结束了(这意味着没有对“ SystemNode s”之后的行的任何调用) 为什么会这样,我该如何解决?
我的代码:
package require Itcl
namespace import ::itcl::*
class Node {
protected variable _type ""
protected variable _parent ""
constructor {type} {
set _type $type
}
destructor {}
public method type {} {
return $_type
}
protected method parent {pobj} {
set _parent $pobj
}
}
class SystemNode {
inherit Node
private variable _lclusters ""
private variable _lbundles ""
private method clear {} {
if { $_lclusters != "" } {
eval delete object $_lclusters
}
if { $_lbundles != "" } {
eval delete object $_lbundles
}
set _lclusters ""
set _lbundles ""
}
constructor {} {
Node::constructor "system"
} {
puts "done"
}
destructor {
clear
}
public method addCluster {cluster} {
$cluster parent $this
lappend _lclusters
}
public method addBundle {bundle} {
$bundle parent $this
lappend _lbundles
}
public method getCluster {ID} {
if { [expr {$ID < 0}] } {
return ""
}
if { [expr {$ID > [llength $_lclusters] }] } {
return ""
}
set index $ID-1
return [lindex $_lclusters $index]
}
public method getBundle {ID} {
if { [expr {$ID < 0}] } {
return ""
}
if { [expr {$ID > [llength $_lbundles] }] } {
return ""
}
set index $ID-1
return [lindex $_lbundles $index]
}
public method deleteCluster {ID} {
set index $ID-1
set temp [lindex $_lclusters $index]
if {$temp != ""} {
eval delete object $temp
set _lclusters [lreplace $_lclusters $index $index]
}
}
public method deleteBundle {ID} {
set index $ID-1
set temp [lindex $_lbundles $index]
if {$temp != ""} {
eval delete object $temp
set _lbundles [lreplace $_lbundles $index $index]
}
}
}
class ClusterNode {
inherit Node
private variable _lbundles ""
private method clear {} {
if { $_lbundles != "" } {
eval delete object $_lbundles
}
set _lbundles ""
}
constructor {} {
Node::constructor "cluster"
} {}
destructor {
clear
}
public method addBundle {bundle} {
$bundle parent $this
lappend _lbundles
}
public method getBundle {ID} {
if { [expr {$ID < 0}] } {
return ""
}
if { [expr {$ID > [llength $_lbundles] }] } {
return ""
}
set index $ID-1
return [lindex $_lbundles $index]
}
public method deleteBundle {ID} {
set index $ID-1
set temp [lindex $_lbundles $index]
if { $temp != "" } {
eval delete object $temp
set _lbundles [lreplace $_lbundles $index $index]
}
}
}
class BundleNode {
inherit Node
private variable _lports ""
private method clear {} {
if { $_lports != "" } {
eval delete object $_lports
}
set _lports ""
}
constructor {} {
Node::constructor "bundle"
} {}
destructor {
clear
}
public method addPort {port} {
$port parent $this
lappend _lports
}
}
SystemNode s
ClusterNode c
s addCluster c