::xotcl::Class
::xo::OrderedComposite
Class Hierarchy of ::xo::OrderedComposite
- ::xotcl::Object
- Meta-class:
- ::xotcl::Class
![[i]](/resources/acs-subsite/ZoomIn16.gif)
- Methods for instances:
- __api_make_doc, __api_make_forward_doc, __timediff, abstract, ad_doc, ad_forward, ad_proc, appendC, arrayC, asHTML, autonameC, check, classC, cleanupC, configureC, containsC, copyC, db_0or1rowC, db_1rowC, debug, defaultmethodC, destroyC, destroy_on_cleanup, ds, evalC, existsC, extractConfigureArg, filterC, filterguardC, filtersearch, forward, hasclass, incrC, infoC, init, instvarC, invarC, isclass, ismetaclass, ismixin, isobject, istype, lappendC, log, method, mixinC, mixinguardC, moveC, msg, noinitC, objectparameter, parametercmdC, proc, procsearch, qn, requireNamespaceC, residualargsC, self, serialize, setC, set_instance_vars_defaults, show-object, substC, traceC, unknown, unsetC, uplevelC, upvarC, volatileC, vwait
- Methods to be applied on the class (in addition to the methods provided by the meta-class):
- getExitHandler, setExitHandler, unsetExitHandler
- ::xo::OrderedComposite
- Meta-class:
- ::xotcl::Class
![[i]](/resources/acs-subsite/ZoomIn16.gif)
- Methods for instances:
- __compare, add, children, contains, delete, destroy, last_child, orderby, show
- Methods to be applied on the class:
- Methods provided by the meta-class
Class Relations
- superclass: ::xotcl::Object
![[i]](/resources/acs-subsite/ZoomIn16.gif)
- subclass: ::ListWidget
, ::xo::Chat
, ::xo::Table
, ::xo::tdom::Object
, ::xowiki::Tree![[i]](/resources/acs-subsite/ZoomIn16.gif)
::xotcl::Class create ::xo::OrderedComposite \
-superclass ::xotcl::Object
Methods
instproc __compare
::1739219 instproc __compare {a b} {
set by [my set __orderby]
set x [$a set $by]
set y [$b set $by]
if {$x < $y} {
return -1
} elseif {$x > $y} {
return 1
} else {
return 0
}
}
instproc add
::1739219 instproc add obj {
my lappend __children $obj
$obj set __parent [self]
#my log "-- adding __parent [self] to $obj -- calling after_insert"
#$obj __after_insert
}
instproc children
::1739219 instproc children {} {
set children [expr {[my exists __children] ? [my set __children] : ""}]
if {[my exists __orderby]} {
set order [expr {[my exists __order] ? [my set __order] : "increasing"}]
return [lsort -command [list my __compare] -$order $children]
} else {
return $children
}
}
instproc contains
::1739219 instproc contains cmds {
my requireNamespace ;# legacy for older xotcl versions
set m [Object info instmixin]
if {[lsearch $m [self class]::ChildManager] == -1} {
set insert 1
Object instmixin add [self class]::ChildManager
} else {
set insert 0
}
#
[self class]::ChildManager instvar composite
# push the active composite
lappend composite [self]
ns_log notice "+++ CONTAINS by [self] cmds $cmds"
# check, if we have Tcl's apply available
if {$::tcl_version >= 8.5 && [info proc ::apply] eq ""} {
ns_log notice "+++ CONTAINS using apply"
set errorOccurred [catch {::apply [list {} $cmds [self]]} errorMsg]
} else {
ns_log notice "+++ CONTAINS using ns eval"
set errorOccurred [catch {namespace eval [self] $cmds} errorMsg]
}
# pop the last active composite
set composite [lrange $composite 0 end-1]
if {$insert} {
Object instmixin delete [self class]::ChildManager
}
if {$errorOccurred} {error $errorMsg}
}
instproc delete
::1739219 instproc delete obj {
my instvar __children
set p [lsearch -exact $__children $obj]
if {$p == -1} {error "can't delete '$obj' from $__children"}
set __children [lreplace $__children $p $p]
$obj destroy
}
instproc destroy
::1739219 instproc destroy {} {
# destroy all children of the ordered composite
if {[my exists __children]} {
#my log "--W destroying children [my set __children]"
foreach c [my set __children] {
if {[my isobject $c]} {$c destroy}
}
}
#show_stack;my log "--W children murdered, now next, chlds=[my info children]"
#namespace eval [self] {namespace forget *} ;# for pre 1.4.0 versions
next
}
instproc last_child
::1739219 instproc last_child {} {
lindex [my set __children] end
}
instproc orderby
::1739219 instproc orderby {{-order "increasing"} variable} {
my set __order $order
my set __orderby $variable
}
instproc show
::1739219 instproc show {} {
next
foreach child [my children] {
$child show
}
}
Variables
::xo::OrderedComposite set __default_metaclass ::xotcl::Class
::xo::OrderedComposite set __default_superclass ::xotcl::Object