1 # fca-mgr.tcl --
2 #
3 # FIXME: This file needs a description here.
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 # SRMAppMgr/FCA is defined in C++
33
34
35 Class SRMAppMgr/FCA/Tcl -superclass SRMAppMgr/FCA
36 DbgOut "SRMAppMgr/FCA: [SRMAppMgr/FCA info superclass]"
37
38 SRMAppMgr/FCA/Tcl instproc init { policy moderatorIds } {
39 # data members:
40 # session_ fcPolicy_ fcDynamics_ rcvrs_ localSrcId_
41 #
42 $self next
43 $self instvar fcPolicy_ moderatorIds_
44 set fcPolicy_ $policy
45 $fcPolicy_ print
46 set moderatorIds_ $moderatorIds
47 }
48
49
50 SRMAppMgr/FCA/Tcl instproc fcPolicy {} {
51 return [$self set fcPolicy_]
52 }
53
54
55 SRMAppMgr/FCA/Tcl instproc localSrcId {} {
56 return [$self set localSrcId_]
57 }
58
59
60 SRMAppMgr/FCA/Tcl instproc create_dynamics { } {
61 $self instvar fcPolicy_ fcDynamics_ moderatorIds_ localSrcId_
62
63 if { ![info exists localSrcId_] || $localSrcId_=={} } {
64 error "SRMAppMgr/FCA/Tcl create_dynamics should be called only after\nthe local source has been attached"
65 }
66
67 if { [$self localIsModerator] } {
68 set class FCAFloorDynamics/Moderator
69 } else {
70 set class FCAFloorDynamics
71 }
72
73 set fcDynamics_ [new $class $self $fcPolicy_ $moderatorIds_]
74 }
75
76
77 SRMAppMgr/FCA/Tcl instproc session {} {
78 $self instvar session_
79 return $session_
80 }
81
82
83 # need to call this function attach_session_, since $self next does not work
84 # with methods defined inside the command() method of TclObjects
85 SRMAppMgr/FCA/Tcl instproc attach_session_ { session } {
86 $self instvar session_
87 set session_ $session
88 $self attach_session $session
89 }
90
91
92 SRMAppMgr/FCA/Tcl instproc attach_uiMgr { uiMgr } {
93 $self instvar uiMgr_
94 set uiMgr_ $uiMgr
95 }
96
97
98 SRMAppMgr/FCA/Tcl instproc uiMgr { } {
99 return [$self set uiMgr_]
100 }
101
102
103 SRMAppMgr/FCA/Tcl instproc setLocalSrcId { localSrcId } {
104 $self instvar localSrcId_
105 set localSrcId_ $localSrcId
106 }
107
108
109 SRMAppMgr/FCA/Tcl instproc isModerator {sid} {
110 $self instvar moderatorIds_
111 DbgOut "Searching for moderator $sid in $moderatorIds_"
112 set i [lsearch $moderatorIds_ $sid]
113 if { $i == -1 } {
114 return 0
115 } else {
116 return 1
117 }
118 }
119
120
121 SRMAppMgr/FCA/Tcl instproc localRcvr {} {
122 $self instvar rcvrs_ localSrcId_
123 return $rcvrs_($localSrcId_)
124 }
125
126 SRMAppMgr/FCA/Tcl instproc getRcvr {srcId} {
127 $self instvar rcvrs_
128 if {[info exist rcvrs_($srcId)]} {
129 return $rcvrs_($srcId)
130 }
131 DbgOut "rcvr for $srcId doesn't exist"
132 return ""
133 }
134
135 SRMAppMgr/FCA/Tcl instproc localIsModerator {} {
136 $self instvar localSrcId_
137 return [$self isModerator $localSrcId_]
138 }
139
140 #SRMAppMgr/FCA/Tcl instproc moderatorRcvr { moderatorSrcId } {
141 # $self instvar rcvrs_
142 # return $rcvrs_($moderatorSrcId)
143 #}
144
145
146 SRMAppMgr/FCA/Tcl instproc fcDynamics {} {
147 $self instvar fcDynamics_
148 return $fcDynamics_
149 }
150
151
152 # was new_source before
153 SRMAppMgr/FCA/Tcl instproc define_rcvr { srcId isLocal } {
154 $self instvar rcvrs_ fcDynamics_
155
156 # DbgOut "defining $srcId, isModerator = [$self isModerator $srcId]"
157
158 if { ![info exists rcvrs_($srcId)] } {
159 # if no rcvr exists
160 if { [$self isModerator $srcId] } {
161 if { $isLocal } {
162 DbgOut "Creating FCARcvr/Tcl/LocalModerator for $srcId"
163 set rcvrs_($srcId) [new FCARcvr/Tcl/LocalModerator \
164 $self $srcId]
165 } else {
166 DbgOut "Creating FCARcvr/Tcl/Moderator for $srcId"
167 set rcvrs_($srcId) [new FCARcvr/Tcl/Moderator $self $srcId]
168 }
169 } else {
170 if { $isLocal } {
171 DbgOut "Creating FCARcvr/Tcl/Local for $srcId"
172 set rcvrs_($srcId) [new FCARcvr/Tcl/Local $self $srcId]
173 } else {
174 DbgOut "Creating FCARcvr/Tcl for $srcId"
175 set rcvrs_($srcId) [new FCARcvr/Tcl $self $srcId]
176 }
177 }
178 }
179 #else {
180 # DbgOut "SRMAppMgr/FCA/Tcl::define_rcvr, moderators are : \
181 # [[$self fcDynamics] set moderatorIds_]"
182 # }
183 # DbgOut "SRMAppMgr/FCA/Tcl::define_rcvr, $srcId, return $rcvrs_($srcId), \
184 # of class [$rcvrs_($srcId) info class]"
185 return $rcvrs_($srcId)
186 }
187
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.