~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Open Mash Cross Reference
mash/tcl/fca/fca-fcp.tcl

Component: ~ [ mash ] ~ [ apps ] ~ [ gsm ] ~ [ lib ] ~ [ otcl ] ~ [ srm ] ~ [ tcl8.3 ] ~ [ tclcl ] ~ [ tk8.3 ] ~ [ tutorials ] ~

  1 # fca-fcp.tcl --
  2 #
  3 #       floor control policy -- should be obtained from SDR plug in
  4 #
  5 # Copyright (c) 1997-2002 The Regents of the University of California.
  6 # All rights reserved.
  7 #
  8 # Redistribution and use in source and binary forms, with or without
  9 # modification, are permitted provided that the following conditions are met:
 10 #
 11 # A. Redistributions of source code must retain the above copyright notice,
 12 #    this list of conditions and the following disclaimer.
 13 # B. Redistributions in binary form must reproduce the above copyright notice,
 14 #    this list of conditions and the following disclaimer in the documentation
 15 #    and/or other materials provided with the distribution.
 16 # C. Neither the names of the copyright holders nor the names of its
 17 #    contributors may be used to endorse or promote products derived from this
 18 #    software without specific prior written permission.
 19 #
 20 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
 21 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 22 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 23 # ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
 24 # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 25 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 26 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 27 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 28 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 29 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 30 
 31 
 32 # Data members for Class FCAFloorConfig:
 33 # floor_: on which the floor is used against
 34 #            vat, vic, mb (bit 2, bit 1, bit0)
 35 #            111 (7) - all resources;
 36 #            110 (6)- vat and vic
 37 #            ...
 38 # maxHldrs_: max number of floor holders for this floor
 39 #
 40 Class FCAFloorConfig
 41 FCAFloorConfig instproc init {floorType maxHldrs} {
 42     $self next
 43     $self instvar floorType_ maxHldrs_
 44     set maxHldrs_ $maxHldrs
 45     set floorType_ $floorType
 46 }
 47 
 48 FCAFloorConfig instproc floorType {} {
 49     $self instvar floorType_
 50     return $floorType_
 51 }
 52 
 53 FCAFloorConfig instproc maxHldrs {} {
 54     $self instvar maxHldrs_
 55     return $maxHldrs_
 56 }
 57 
 58 FCAFloorConfig instproc setMaxHldrs {max} {
 59     $self instvar maxHldrs_
 60     set maxHldrs_ $max
 61 }
 62 
 63 FCAFloorConfig instproc print {} {
 64     $self instvar floorType_ maxHldrs_
 65     puts "floorType: $floorType_  (bit 2: vat; bit 1: vic; bit 0: mb)"
 66     puts "max holders: $maxHldrs_"
 67 }
 68 
 69 # Data members of Class FCAPolicy (floorType control policy)
 70 # flCfg_ : list of floorType config's
 71 # numChairs_: number of chairs in the conference
 72 # manual_:  manually moderated
 73 # maxRqs_:  max requests that show on each one's window
 74 # maxFls_:  max number of floorTypes that can be specified
 75 
 76 
 77 Class FCAPolicy
 78 
 79 # for now:
 80 FCAPolicy instproc init { manual numModerators maxRqs } {
 81     $self next
 82     $self instvar maxFls_ flCfgs_ numModerators_ manual_ maxRqs_
 83     #if {$manual=={}} {
 84         #set manual_ 1
 85         #set numModerators_ 1
 86         #set maxRqs_ 20
 87         #set maxFls_ 2
 88         ## 1 (vat and vic as one floorType), 2 (mb as another floorType)
 89         #set f1 [new FCAFloorConfig 1 1]
 90         #set f2 [new FCAFloorConfig 2 2]
 91         #lappend flCfgs_ $f1 $f2
 92         #return
 93     #}
 94     set manual_ $manual
 95     set numModerators_ $numModerators
 96     set maxRqs_ $maxRqs
 97     set maxFls_ 0
 98     set flCfgs_ {}
 99 }
100 
101 FCAPolicy instproc addFloor { floorType maxHolders } {
102     $self instvar maxFls_ flCfgs_
103     incr maxFls_
104     lappend flCfgs_ [new FCAFloorConfig $floorType $maxHolders]
105 }
106 
107 
108 FCAPolicy instproc numFloorTypes {} {
109     $self instvar flCfgs_
110     return [llength $flCfgs_]
111 }
112 
113 FCAPolicy instproc floorConfigs {} {
114     $self instvar flCfgs_
115     return $flCfgs_
116 }
117 
118 FCAPolicy instproc maxRqs {} {
119     $self instvar maxRqs_
120     return $maxRqs_
121 }
122 
123 FCAPolicy instproc numModerators {} {
124     $self instvar numModerators_
125     return $numModerators_
126 }
127 
128 # return all the floor types (resource bitmaps)
129 FCAPolicy instproc floorTypes {} {
130     $self instvar flCfgs_
131     set returnftypes {}
132     foreach i $flCfgs_ {
133         lappend returnftypes [$i floorType]
134     }
135     return $returnftypes
136 }
137 
138 FCAPolicy instproc newFloorType {floorType maxHldrs} {
139     $self instvar maxFls_, flCfgs_
140     if {[$self numFloorTypes] >= $maxFls_} {
141         puts "There are already max $maxFls_ floors specified."
142         return
143     }
144     foreach i $flCfgs_ {
145         set f [$i floorType]
146         if {$f == $floorType } {
147             puts "There is already a floor for $floorType."
148             return
149         }
150     }
151     lappend flCfgs_ [new FCAFloorConfig $floorType $maxHldrs]
152 }
153 
154 FCAPolicy instproc setMaxRqs { maxRqs } {
155     $self instvar maxRqs_
156     set maxRqs_ $maxRqs
157 }
158 
159 FCAPolicy instproc setMaxFls { maxFls } {
160     $self instvar maxFls_
161     set maxFls_ $maxFls
162 }
163 
164 FCAPolicy instproc getMaxHdlrs { floorType } {
165     $self instvar flCfgs_
166     foreach i $flCfgs_ {
167         set f [$i floorType]
168         if {$floorType == $f} {
169             return [$i maxHldrs]
170         }
171     }
172 }
173 
174 FCAPolicy instproc setMaxHldrs {floorType max} {
175     $self instvar flCfgs_
176     foreach i $flCfgs {
177         set f [$i floorType]
178         if {$f == $floorType} {
179             $i setMaxHldrs max
180             return
181         }
182     }
183     puts "floorType($floorType) not found"
184 }
185 
186 FCAPolicy instproc print {} {
187     $self instvar flCfgs_ maxFls_ manual_ numModerators_
188     puts "manual = $manual_; num of moderators = $numModerators_"
189     puts "Floors created = [$self numFloorTypes]; max floors allowed = $maxFls_"
190     if {[$self numFloorTypes]==0} {
191         puts "No floors have been created."
192         return
193     }
194 
195     foreach i $flCfgs_ {
196         puts "$i"
197         set f [$i floorType]
198         set m [$i maxHldrs]
199         puts "floor($f); max holders($m)"
200     }
201 }
202 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.