### BEGIN COPYRIGHT BLURB # # TAO - Tcl Architecture of Objects # Copyright (C) 2007 Sean Woods # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # ### END COPYRIGHT BLURB ::tao::class tdif.node { static containerObj static globalName constructor { } proc is {type} { return [isa tdif.${type}] } method /node node { return [tdif /node $node $globalName] } method globalName {} { return $globalName } method /container {} { return $containerObj } } ### # The simplest form of container # store elements as a dict ::tao::class tdif.container { inherit tdif.node static objectDict static nodeClass tdif.element constructor { cset [list objectDict ${statevar}.objects containerObj $this] set ${statevar}.objects {} } proc nodeAlias node { return $node } method /container {} { return $this } method nodeClass node { return $nodeClass } destructor { tdif clear_objects $this if [info exists $objectDict] { unset $objectDict } } ### # Return a field/value list that describe # to spawned nodes the state of the system ### chain train node { set result [nodeGet [nodeAlias $node]] dict set result globalName $globalName-[nodeAlias $node] dict set result containerObj $this dict set result class [nodeClass $node] dict set result node_id [nodeAlias $node] } method nodeGet node { set node [nodeAlias $node] if [dict exists [set $objectDict] $node] { return [dict get [set $objectDict] $node] } } method nodeGetField {node field} { set node [nodeAlias $node] if [dict exists [set $objectDict] $node $field] { return [dict get [set $objectDict] $node $field] } } method nodeGetFields {node fieldlist} { set data [nodeGet $node] foreach field $fieldlist { if [dict exists $data $field] { lappend result $field [dict get $data $field] } else { lappend result $field {} } } return $result } method nodeSet {node newvalue} { set node [nodeAlias $node] if [dict exists [set $objectDict] $node] { set data [dict get [set $objectDict] $node] dict set $objectDict $node [dict merge $data $newvalue] } else { dict set $objectDict $node $newvalue } } method nodeDelete {node} { set node [nodeAlias $node] dict unset $objectDict $node } mesh tdifAttach {} { } }