/usr/share/tcltk/xotcl1.6.7-patterns/composite.xotcl is in xotcl 1.6.7-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | # $Id: composite.xotcl,v 1.4 2005/09/09 21:09:01 neumann Exp $
package provide xotcl::pattern::composite 0.9
package require XOTcl
namespace eval ::xotcl::pattern::composite {
namespace import ::xotcl::*
Class Composite -superclass Class
@ @File {
description {
Simple composite pattern meta-class taken from the paper
'Filters as a Language Support for Design Patterns in
Object-Oriented Scripting Languages'.
}
}
Composite instproc addOperations args {
foreach op $args {
if {![my exists operations($op)]} {
my set operations($op) $op
}
}
}
Composite instproc removeOperations args {
foreach op $args {
if {![my exists operations($op)]} {
my unset operations($op)
}
}
}
Composite instproc compositeFilter args {
# get the operations class variable from the object's class
set registrationclass [lindex [self filterreg] 0]
$registrationclass instvar operations
# get the request
set r [self calledproc]
# check if the request is a registered operation
if {[info exists operations($r)]} {
foreach object [my info children] {
# forward request
eval $object $r $args
}
}
return [next]
}
Composite instproc init {args} {
my array set operations {}
next
my instfilter add compositeFilter
}
namespace export Composite
}
namespace import ::xotcl::pattern::composite::*
|