home *** CD-ROM | disk | FTP | other *** search
/ PC World 1997 November / PCWorld_1997-11_cd.bin / software / programy / komix / DATA.Z / cadmodel.tcl < prev    next >
Text File  |  1996-05-29  |  3KB  |  125 lines

  1. #---------------------------------------------------------------------------
  2. #
  3. #      (c)     Cadre Technologies Inc.    1996
  4. #
  5. #      File:           @(#)cadmodel.tcl    1.5
  6. #      Author:         <generated>
  7. #      Description:
  8. #---------------------------------------------------------------------------
  9. # SccsId = @(#)cadmodel.tcl    1.5   31 Jan 1996 Copyright 1996 Cadre Technologies Inc.
  10.  
  11. # Start user added include file section
  12. require "cadbinarya.tcl"
  13. require "cadclass.tcl"
  14. require "cadinhergr.tcl"
  15. require "cadnassocc.tcl"
  16. require "cadnassocn.tcl"
  17.  
  18. require "cadmodeltp.tcl"
  19. # End user added include file section
  20.  
  21.  
  22. Class CADModel : {SMPhaseModel} {
  23.     constructor
  24.     method destructor
  25.     method load
  26.     method loadClasses
  27.     method getClasses
  28.     method defineSMTypes
  29.     method makeSMTypeName
  30.     method addClass
  31.     method removeClass
  32.     attribute loaded
  33.     attribute classSet
  34. }
  35.  
  36. constructor CADModel {class this i_configVersion i_phaseVersion} {
  37.     set this [SMPhaseModel::constructor $class $this $i_configVersion $i_phaseVersion]
  38.     $this loaded 0
  39.     $this classSet [List new]
  40.     # Start constructor user section
  41.  
  42.     # Define global available SMTypes
  43.     $this defineSMTypes
  44.  
  45.     # Add creator scripts to the ObjectFactory
  46.     set objFac [$this getObjectFactory]
  47.     $objFac addCreatorScript $OMT_CAD_NAssoc \
  48.         "return \[CADNAssocNode new $this]"
  49.     $objFac addCreatorScript $OMT_CAD_NaryAssocConn \
  50.         "return \[CADNAssocConn new $this]"
  51.     # Combined types
  52.     $objFac addCreatorScript $OMT_CAD_CB_Class \
  53.         "return \[CADClass new $this]"
  54.     $objFac addCreatorScript $OMT_CAD_CB_Generalization \
  55.         "return \[CADInherGroup new $this]"
  56.     $objFac addCreatorScript $OMT_CAD_CB_Association \
  57.         "return \[CADBinaryAssoc new $this]"
  58.  
  59.     # End constructor user section
  60.     return $this
  61. }
  62.  
  63. method CADModel::destructor {this} {
  64.     # Start destructor user section
  65.     # End destructor user section
  66. }
  67.  
  68. method CADModel::load {this} {
  69.     if {[$this loaded] == 1} {
  70.         return
  71.     }
  72.     $this loaded 1
  73.     $this loadClasses
  74. }
  75.  
  76. method CADModel::loadClasses {this} {
  77.     set classes [$this getSMObjects $OMT_CAD_CB_Class]
  78.     foreach class $classes {
  79.         $this addClass $class
  80.     }
  81. }
  82.  
  83. method CADModel::getClasses {this} {
  84.     $this load
  85.     return [$this classSet]
  86. }
  87.  
  88. method CADModel::defineSMTypes {this} {
  89.     set typeIter [SMTypeIter new]
  90.     while {[$typeIter current] != ""} {
  91.         set smType [$typeIter current]
  92.         if { ![string match CAD* [$smType name]]} {
  93.             $typeIter next
  94.             continue
  95.         }
  96.         set name [$this makeSMTypeName [$smType name]]
  97.         eval "global $name"
  98.         eval "set $name $smType"
  99.         $typeIter next
  100.     }
  101.     $typeIter delete
  102.  
  103.     global anySMType; set anySMType [SMTypeDB::any]
  104.     global nilSMType; set nilSMType [SMTypeDB::nil]
  105.  
  106.     return
  107. }
  108.  
  109. method CADModel::makeSMTypeName {this type} {
  110.     regsub -all "\[ \t]+" $type "_" type
  111.     return "OMT_$type"
  112. }
  113.  
  114. # Do not delete this line -- regeneration end marker
  115.  
  116. method CADModel::addClass {this newClass} {
  117.     [$this classSet] append $newClass
  118.  
  119. }
  120.  
  121. method CADModel::removeClass {this oldClass} {
  122.     [$this classSet] removeValue $oldClass
  123. }
  124.  
  125.