home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
komix
/
DATA.Z
/
class_gens.tcl
< prev
next >
Wrap
Text File
|
1997-01-09
|
4KB
|
162 lines
#---------------------------------------------------------------------------
#
# (c) Cadre Technologies Inc. 1995
#
# File: @(#)class_gens.tcl /main/titanic/1
# Author: Harm Leijendeckers
# Description: Report on class generalizations
# Usage in: SystemVersion and CAD editor
#
#---------------------------------------------------------------------------
# SccsId = @(#)class_gens.tcl /main/titanic/1 9 Jan 1997 Copyright 1995 Cadre Technologies Inc.
eval [$cc getCustomFileContents semanticbase tcl reports]
#---------------------------------------------------------------------------
Class BaseClass : {GCObject} {
constructor
attribute class
attribute nrIn
}
constructor BaseClass {class this cl} {
set this [GCObject::constructor $class $this]
$this class $cl
$this nrIn [llength [$cl getOppositeObjectsIn $OMT_CAD_CB_GenConn \
$OMT_CAD_CB_Generalization]]
return $this
}
#---------------------------------------------------------------------------
Class ReportClassGens : {SemanticBase} {
constructor
method systemReport
method doReport
method doClass
attribute done
}
constructor ReportClassGens {class this} {
set this [SemanticBase::constructor $class $this]
$this reportName "Class Generalizations"
return $this
}
method ReportClassGens::systemReport {this} {
return [$this phaseReport]
}
method ReportClassGens::doReport {this model} {
# get all CAD Classes
set classes [concat [$model getSMObjects $OMT_CAD_CB_Class]]
if [lempty $classes] { return 0 }
set all [concat [query "getItem.isNil == 1" $classes] \
[osort getItem.name [query "getItem.isNil == 0" $classes]]]
foreach class [sortSMObjects classes] {
lappend allBases [BaseClass new $class]
}
set allDone ""
set allBasesWithNoIns [query -s class "nrIn == 0" $allBases]
foreach base [sortSMObjects allBasesWithNoIns] {
set done ""
$this doClass $base 0 Normal done
[$this report] line
set allDone [concat $allDone $done]
}
# If there are classes left, they are part of a 'loop'. This is considered
# as a design error. Therefor the algorythm to print it is very straight-
# forward: Print a generalizationtree foreach class in the loop.
if { $allDone != "" } {
foreach base [query "! class in {$allDone}" $allBases] {
set done ""
$this doClass [$base class] 0 Normal done
[$this report] line
}
}
[$this report] page
return 0
}
method ReportClassGens::doClass {this class level type _done} {
upvar 1 $_done done
if { [lsearch -exact $done $class] != -1 } {
return
}
lappend done $class
set report [$this report]
set allNormalGens [$class getOppositeObjectsOut $OMT_CAD_GenConn \
$OMT_CAD_Generalization]
set allOverlapGens [$class getOppositeObjectsOut $OMT_CAD_OverlapGenConn \
$OMT_CAD_OverlapGen]
# print nothing if there are no subclasses
#if { $level == 0 && [lempty $allNormalGens] && [lempty $allOverlapGens] } {
#return
#}
# print lines iso spaces
#$report print " |" [expr $level * 4] fill
$report space [expr $level * 4]
if { $type == "Normal" } {
$report print "- "
} else {
$report print "* "
}
$report print [$this objName $class] line
# all generalizations
foreach gen $allNormalGens {
set allSubs [$gen getOppositeObjectsOut $OMT_CAD_GenConn \
$OMT_CAD_CB_Class]
foreach sub [sortSMObjects allSubs] {
$this doClass $sub [expr $level+1] Normal done
}
}
# all generalizations
foreach gen [$class getOppositeObjectsOut $OMT_CAD_OverlapGenConn \
$OMT_CAD_OverlapGen] {
set allSubs [$gen getOppositeObjectsOut $OMT_CAD_OverlapGenConn \
$OMT_CAD_CB_Class]
foreach sub [sortSMObjects allSubs] {
$this doClass $sub [expr $level+1] Overlap done
}
}
}
proc sortSMObjects {_orig } {
upvar 1 $_orig orig
return [concat [query "getItem.isNil == 1" $orig] \
[osort getItem.name [query "getItem.isNil == 0" $orig]]]
}
# ----------------------------------------------------------------------
#
set executeMe [ReportClassGens new]