home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
komix
/
DATA.Z
/
msumlclass.tcl
< prev
next >
Wrap
Text File
|
1997-09-24
|
7KB
|
261 lines
#---------------------------------------------------------------------------
#
# (c) Cayenne Software Inc. 1997
#
# File: @(#)msumlclass.tcl /main/titanic/3
# Author: <generated>
# Description:
#---------------------------------------------------------------------------
# SccsId = @(#)msumlclass.tcl /main/titanic/3 24 Sep 1997 Copyright 1997 Cayenne Software Inc.
# Start user added include file section
# End user added include file section
#require "msumltype.tcl"
Class MSUMLClass : {MSUMLType} {
constructor
method destructor
method ms2ot
method otFeat2Ms
method ot2ms
method promoter
method roleSet
method addRole
method removeRole
method memberSet
method addMember
method removeMember
attribute smClass
attribute _roleSet
attribute _memberSet
}
constructor MSUMLClass {class this typeName smClass} {
set this [MSUMLType::constructor $class $this $typeName]
$this smClass $smClass
$this _roleSet [List new]
$this _memberSet [List new]
# Start constructor user section
# End constructor user section
return $this
}
method MSUMLClass::destructor {this} {
foreach ref [[$this _roleSet] contents] {
$ref _owner ""
}
foreach ref [[$this _memberSet] contents] {
$ref _owner ""
}
# Start destructor user section
[$this memberSet] foreach member {
$member delete
}
# End destructor user section
$this MSUMLType::destructor
}
method MSUMLClass::ms2ot {this rtDiag {find ""}} {
set className [$this name]
set myClass [$rtDiag findClass $className]
if ![llength $myClass] {
set myClass [$rtDiag addClass $className]
}
if [llength $find] {
#call from assoc ms2ot
return $myClass
}
puts "\tClass '$className'"
[$this memberSet] foreach msMember {
$msMember ms2ot $myClass
}
$this loadFreeTextProp $myClass
return $myClass
}
method MSUMLClass::otFeat2Ms {this} {
global trans
set msPackage [$this package]
set smModel [$msPackage smModel]
set smClassType [SMTypeDB::find "Class"]
set confV [[ClientContext::global] currentConfig]
set smClass [$this smClass]
set workItem [$smClass getWorkItem]
if [$workItem isNil] {
return $umlClass
}
set item [$smClass getItem]
set umlClass [$this msUmlObject]
# find related matrix
set systemV [$workItem owner]
set matrix [$systemV findFileVersion -byItemAndType $item cdm]
if [$matrix isNil] {
return $umlClass
}
set name [$item name]
puts "\tClass '$name' Features"
$matrix loadRowData "name_type" rows
# var rows consist of list of features
# for each feature row|list of items|properties
set file [$matrix file]
set classIsAbstract 0
set operIsAbstract 0
foreach rowData $rows {
set typeItem ""
set nameItem ""
set rowType ""
foreach item [lindex $rowData 1] {
set itemType [$item type]
set workItem [$systemV findDefinition $item $confV]
if {$itemType == "cl"} {
set typeItem $item
set smTypeClass [$smModel getNamedSMObjects $smClassType $item]
continue
}
set nameItem $workItem
if {$itemType == "de" } {
set rowType "Attribute"
set msumlMember [MSUMLAttribute new UMLAttribute $workItem]
set msFeat [$msumlMember ot2ms $umlClass]
} else {
set rowType "Operation"
set msumlMember [MSUMLOperation new UMLOperation $workItem]
set msFeat [$msumlMember ot2ms $umlClass [lindex $rowData 3]]
}
$this addMember $msumlMember
}
$trans begin
set iFeat [$msFeat getInterface IUmlMember]
$iFeat property Direction "Provide"
set IsTypeScope 0
set InitialValue ""
#properties
foreach propVal [lindex $rowData 2] {
set propName [$propVal name]
if {$propName == "is_class_feature"} {
set IsTypeScope [$propVal value]
}
if {$propName == "is_abstract"} {
set operIsAbstract [$propVal value]
}
if {$propName == "initial_value"} {
set InitialValue [$propVal value]
}
}
$iFeat property IsTypeScope $IsTypeScope
$iFeat delete
# type expression
if [llength $typeItem] {
# a type available
$msumlMember typeItem $typeItem
if {$rowType == "Operation"} {
if {$operIsAbstract == "1"} {
set classIsAbstract 1
}
set iOper [$msFeat getInterface IUmlOperation]
$iOper property IsAbstract $operIsAbstract
$iOper delete
# create UML parameter with kind is return
set msumlParam [MSUMLParameter new UMLParameter "" $nameItem $msumlMember $typeItem]
$msumlParam typeItem $typeItem
set msParam [$msumlParam ot2ms $msFeat "return"]
} else {
set iAttr [$msFeat getInterface IUmlAttribute]
$iAttr property TypeExpression [$typeItem name]
$iAttr property InitialValue $InitialValue
$iAttr delete
}
}
$trans commit
}
$trans begin
set iGenEl [$umlClass getInterface IUmlGeneralizableElement]
$iGenEl property IsAbstract $classIsAbstract
$iGenEl delete
$trans commit
return $umlClass
}
method MSUMLClass::ot2ms {this package} {
set smClass [$this smClass]
set item [$smClass getItem]
set workItem [$smClass getWorkItem]
if [$item isNil] {
if [$workItem isNil] {
# emtpy class
return
}
}
global trans
$trans begin
set name [$item name]
puts "\tClass '$name'"
set umlClass [$package createClass $name]
$this msUmlObject $umlClass
if [$workItem isNil] {
$trans commit
return $umlClass
}
# class properties
$this saveFreeTextProp $umlClass [$workItem properties]
$trans commit
return $umlClass
}
method MSUMLClass::promoter {this} {
$this MSUMLType::promoter
set noOfMembers [$this getNoOfMembers]
$this _roleSet [List new]
$this _memberSet [List new]
for {set i 1} {$i <= $noOfMembers} {incr i} {
set umlMember [$this getMemberAsUML $i]
MS[$umlMember property objectType] promote $umlMember
$this addMember $umlMember
}
}
# Do not delete this line -- regeneration end marker
method MSUMLClass::roleSet {this} {
return [$this _roleSet]
}
method MSUMLClass::addRole {this newRole} {
[$this _roleSet] append $newRole
$newRole _owner $this
}
method MSUMLClass::removeRole {this oldRole} {
$oldRole _owner ""
[$this _roleSet] removeValue $oldRole
}
method MSUMLClass::memberSet {this} {
return [$this _memberSet]
}
method MSUMLClass::addMember {this newMember} {
[$this _memberSet] append $newMember
$newMember _owner $this
}
method MSUMLClass::removeMember {this oldMember} {
$oldMember _owner ""
[$this _memberSet] removeValue $oldMember
}