home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1997 November
/
PCWorld_1997-11_cd.bin
/
software
/
programy
/
komix
/
DATA.Z
/
oper_missing.tcl
< prev
next >
Wrap
Text File
|
1997-06-03
|
9KB
|
374 lines
#---------------------------------------------------------------------------
#
# (c) Cadre Technologies Inc. 1996
#
# File: @(#)oper_missing.tcl /main/hindenburg/8
# Author: Harm Leijendeckers
# Description: Report on missing operations
# Usage in: SystemVersion and CAD editor
# Options: -o <className1> [<className2> ...]
#
#---------------------------------------------------------------------------
# SccsId = @(#)oper_missing.tcl /main/hindenburg/8 3 Jun 1997 Copyright 1996 Cadre Technologies Inc.
eval [$cc getCustomFileContents semanticbase tcl reports]
Class ReportOperMissing : {SemanticBase} {
constructor
method systemReport
method fileReport
method doReport
method doClass
method getAllOperations
method getAllConnectors
method getConnectors
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 [lempty $Options] {
$report print "Error: This report needs argument '-o <className1>\
\[<className2> ...\]'" line
return -1
}
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]
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 connDictBag [$this getAllConnectors $model $className]
if ![$connDictBag size] {
$report space 8
$report print "** no events to this class found **" line
return
}
$report line
$report space 4
$report print Event 28
$report print "Req. Args" 11
$report print Type 18
$report print Diagram line
$report space 4
$report print - 114 fill line
# retrieve operations in a UniqueBag
set operBag [$this getAllOperations $className]
$connDictBag foreach connName argBag {
$argBag foreach argcount connectorList {
# in a ccd there are no args at connectors
if { $argcount == "?" } {
if [$operBag exists $connName] {
continue
}
} elseif [$operBag exists $connName $argcount] {
continue
}
$connectorList foreach connector {
$report space 4
$report print $connName 27
$report space 4
$report print $argcount 8
$report print [$connector type] 17
$report space
$report print [[$connector 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::getAllConnectors {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 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 stdItem [[$this project] findItem top pe $classItem]
if ![$stdItem isNil] {
[$this phaseV] getDecompositions $stdItem [$this configV] \
decompFiles std dummy std
if ![lempty $std] {
set filemodel [SMFileModel new [$this configV] $std]
set stdConns [concat [$filemodel getSMObjects $OMT_STD_Event] \
[$filemodel getSMObjects $OMT_STD_StateEvent] \
$stdConns]
}
}
}
foreach smconn [concat $ccdConns $etdConns $stdConns] {
set connLabel [$smconn getLabel]
if [$connLabel isNil] {
continue
}
set itemRefs [$connLabel itemRefs]
set msgtxt [query -s item.name "item.type == pe" $itemRefs]
# use lempty iso == ""
if [lempty $msgtxt] {
continue
}
set nrargs [llength [query "item.type != pe" $itemRefs]]
# in a ccd there are no args at connectors
if [$smconn isA SMConnector] {
set conn [$smconn getConnector]
if { [$conn type] == "com_message" } {
set nrargs ?
}
}
set slotBag [$result set $msgtxt]
if [lempty $slotBag] {
set slotBag [UniqueBag new]
$result set $msgtxt $slotBag
}
$slotBag set $nrargs $conn
}
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
}
# ----------------------------------------------------------------------
#
# 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]