home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
komix
/
DATA.Z
/
oper_missing.tcl
< prev
next >
Wrap
Text File
|
1997-11-28
|
11KB
|
475 lines
#---------------------------------------------------------------------------
#
# (c) Cayenne Software Inc. 1996,1997
#
# File: @(#)oper_missing.tcl /main/titanic/10
# Author: Harm Leijendeckers
# Description: Report on missing operations
# Usage in: SystemVersion and CAD editor
# Options: -o <className1> [<className2> ...]
#
#---------------------------------------------------------------------------
# SccsId = @(#)oper_missing.tcl /main/titanic/10 28 Nov 1997 Copyright 1997 Cayenne Software Inc.
eval [$cc getCustomFileContents semanticbase tcl reports]
Class ReportOperMissing : {SemanticBase} {
constructor
method systemReport
method fileReport
method doReport
method doClass
method getAllOperations
method getAllEvents
method getConnectors
method getConos
attribute QOAllCdms
}
constructor ReportOperMissing {class this} {
set this [SemanticBase::constructor $class $this]
$this reportName "Missing Operations"
return $this
}
method ReportOperMissing::fileReport {this} {
return [$this phaseReport]
}
method ReportOperMissing::systemReport {this} {
return [$this phaseReport]
}
method ReportOperMissing::doReport {this model} {
set report [$this report]
if ![[$this systemV] isNil] {
set allCdms [query "file.type == cdm" $this.systemV.localFileVersions]
} else {
set allCdms [query "file.type == cdm" \
$this.phaseV.systemVersions.localFileVersions]
}
$this QOAllCdms [QueryObject new allCdms file.name]
if [lempty $Options] {
set Options [query -s "file.name" [$this QOAllCdms]]
}
if [lempty $Options] {
$report print "Error: No classes found" line
$report print "Error: This report needs argument '-o <className1>\
\[<className2> ...\]'" line
return -1
}
set Options [lsort [flatten $Options]]
while { ![lempty $Options] } {
set className [lvarpop Options]
$this doClass $model $className
if [$report lineno] {
$report line
$report line
$report line
}
}
$report page
$report remove header
return 0
}
method ReportOperMissing::doClass {this model className} {
set report [$this report]
$report space 2
$report print "* Class: $className" line
set eventDictBag [$this getAllEvents $model $className]
if ![$eventDictBag size] {
$report space 8
$report print "** no events to this class found **" line
return
}
$report line
$report space 4
$report print Event 18
$report print "Req. Args" 10
$report print Type 18
$report print To 20
$report print Diagram line
$report space 4
$report print - 114 fill line
# retrieve operations in a UniqueBag
set operBag [$this getAllOperations $className]
$eventDictBag foreach eventName argBag {
$argBag foreach argcount compList {
# in a ccd there are no args at connectors
if { $argcount == "?" } {
if [$operBag exists $eventName] {
continue
}
} elseif [$operBag exists $eventName $argcount] {
continue
}
set toNodes ""
$compList foreach comp {
if [$comp isA Connector] {
set receiver [$comp to]
} elseif [$comp isA ConnectedNode] {
set receiver [$comp from]
} else {
set dir [$comp getPropertyValue msg_direction]
if { $dir == "backward" } {
set receiver [[[$comp from] connector] from]
} else {
set receiver [[[$comp from] connector] to]
}
}
set objLabel [lindex [$receiver labels] 0]
if ![$objLabel isNil] {
set label [$objLabel value]
if { [lsearch $toNodes $label] != -1 } continue
lappend toNodes $label
}
$report space 4
$report print $eventName 24
$report space
$report print $argcount 2
$report space
$report print [$comp type] 17
$report space
$report print $label 19
$report space
$report print [[$comp diagram] text]
$report line
}
}
}
}
method ReportOperMissing::getAllOperations {this className} {
set result [UniqueBag new]
set cdm [query "file.name == $className" [$this QOAllCdms]]
if [lempty $cdm] {
return $result
}
$cdm loadRowData {{name_type}} rowDataList
foreach rowData $rowDataList {
set row [lvarpop rowData]
if { [$row type] != "method" } {
continue
}
set rowItems [lvarpop rowData]
set rowProps [lvarpop rowData]
set cellDataList [lvarpop rowData]
set classItem [query "type == pe" $rowItems]
if [lempty $classItem] {
continue
}
$result set [$classItem name] [llength $cellDataList]
}
return $result
}
method ReportOperMissing::getAllEvents {this model className} {
set result [Dictionary new]
set ccdConns [$this getConnectors $model $className $OMT_CCD_Message \
$OMT_CCD_Class $OMT_CCD_Container $OMT_CCD_ClassRef]
set codConos [$this getConos $model $className $OMT_COD_Message \
$OMT_COD_Instance]
set etdConns [$this getConnectors $model $className $OMT_ETD_Event \
$OMT_ETD_Initiator $OMT_ETD_Object]
# all event messages in all std's to the class
set stdConns [$this getConnectors $model $className $OMT_STD_EventMessage \
$OMT_STD_Class]
# all messages in std of the class
set classItem [[$this project] findItem $className cl]
if ![$classItem isNil] {
set wi [[$this systemV] findDefinition $classItem [$this configV]]
set decl {}
if ![$wi isNil] {
set decl [$wi qualifiedDeclarations]
}
set files {}
foreach def $decl {
[$this phaseV] getDecompositions \
[$def item] [$this configV] decompFiles std dummy stds
if ![lempty $stds] {
lappend files [concat $stds]
}
}
foreach file $files {
set filemodel [SMFileModel new [$this configV] $file]
set stdConns [concat \
[$filemodel getSMObjects $OMT_STD_Event] \
[$filemodel getSMObjects $OMT_STD_StateEvent] \
$stdConns ]
}
}
foreach smobj [concat $ccdConns $codConos $etdConns $stdConns] {
set label [$smobj getLabel]
if [$label isNil] {
continue
}
set itemRefs [$label itemRefs]
set msgtxt [query -s item.name "item.type == pe" $itemRefs]
# use lempty iso == ""
if [lempty $msgtxt] {
# continue
# Show also messages without item (no semi-col. in COD flow)
set msgtxt [$this objName $smobj]
if {"$msgtxt" == "?"} continue
}
set comp [$smobj getComponents]
# in a ccd there are no args at connectors
switch [$comp type] {
com_message {
set nrargs ?
}
cod_message -
etd_event {
set type [$comp getPropertyValue msg_type]
# See all (non-return) messages as operations...
# if { "$type" != "nested" } continue
if { "$type" == "return" } continue
set nrargs [llength [query "item.type != pe" $itemRefs]]
}
default {
set nrargs [llength [query "item.type != pe" $itemRefs]]
}
}
set slotBag [$result set $msgtxt]
if [lempty $slotBag] {
set slotBag [UniqueBag new]
$result set $msgtxt $slotBag
}
$slotBag set $nrargs $comp
}
return $result
}
method ReportOperMissing::getConnectors {this model className connType args} {
set result {}
foreach toType $args {
foreach conn [$model getSMObjects $connType] {
# skip conns with no name
if [[$conn getItem] isNil] {
continue
}
# skip conns where getTo != className
set toNode [$conn getTo $toType]
if [lempty $toNode] {
continue
}
set item [$toNode getItem]
if [$item isNil] {
# exception for etd nodes
set item [$toNode getItem 0 name_type cl]
}
if ![$item isNil] {
if { [$item name] == "$className" } {
lappend result $conn
}
}
}
}
return $result
}
method ReportOperMissing::getConos {this model className conoType args} {
set result {}
foreach toType $args {
foreach cono [$model getSMObjects $conoType] {
# skip conos with no name
# if [[$cono getItem] isNil] {
# }
if {[$this objName $cono] == "?"} {
continue
}
# skip conos where getTo != className
set conn [$cono getSuperiorObjects $OMT_COD_Conn]
set comp [lindex [$cono getComponents] 0]
set dir [$comp getPropertyValue msg_direction]
if { $dir == "forward" } {
set node [$conn getTo $toType]
} else {
set node [$conn getFrom $toType]
}
if [lempty $node] {
continue
}
set item [$node getItem]
if [$item isNil] {
# exception for cod nodes
set item [$node getItem 0 name_type cl]
}
if ![$item isNil] {
if {[$item name] == "$className"} {
lappend result $cono
}
}
}
}
return $result
}
# ----------------------------------------------------------------------
#
# Class Bag
#
# ----------------------------------------------------------------------
Class Bag : {Dictionary} {
constructor
method destructor
# overloaded:
method set
method contents
method exists
}
constructor Bag {class this} {
set this [Dictionary::constructor $class $this]
return $this
}
method Bag::destructor {this} {
return [Dictionary::destructor $this]
}
# Overloaded from Dictionary.
#
method Bag::set {this key {value ""}} {
# retrieval
if { $value == "" } {
if ![$this Dictionary::exists $key] {
return
}
return [[$this Dictionary::set $key] contents]
}
# append
if ![$this Dictionary::exists $key] {
$this Dictionary::set $key [List new]
}
[$this Dictionary::set $key] append $value
}
# Overloaded from Dictionary.
#
method Bag::contents {this} {
$this foreach key valueList {
lappend result "$key [list [$valueList contents]]"
}
return [join $result]
}
# Overloaded from Dictionary.
#
method Bag::exists {this key {value ""}} {
if { $value == "" } {
return [$this Dictionary::exists $key]
}
if ![$this Dictionary::exists $key] {
return 0
}
if { [[$this Dictionary::set $key] search $value] != -1 } {
return 1
}
return 0
}
# ----------------------------------------------------------------------
#
# Class UniqueBag
#
# ----------------------------------------------------------------------
Class UniqueBag : {Bag} {
constructor
# overloaded:
method set
}
constructor UniqueBag {class this} {
set this [Bag::constructor $class $this]
return $this
}
# Overloaded from Bag. Don't insert duplicates for one key.
#
method UniqueBag::set {this key {value ""}} {
if { $value != "" } {
if { [lsearch [$this set $key] $value] != -1 } {
return ""
}
}
return [$this Bag::set $key $value]
}
# ----------------------------------------------------------------------
#
set executeMe [ReportOperMissing new]