420
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1995 by Claus Gittinger
|
|
3 |
All Rights Reserved
|
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
|
13 |
Signal subclass:#QuerySignal
|
1248
|
14 |
instanceVariableNames:''
|
|
15 |
classVariableNames:''
|
|
16 |
poolDictionaries:''
|
|
17 |
category:'Kernel-Exceptions'
|
420
|
18 |
!
|
|
19 |
|
|
20 |
!QuerySignal class methodsFor:'documentation'!
|
|
21 |
|
|
22 |
copyright
|
|
23 |
"
|
|
24 |
COPYRIGHT (c) 1995 by Claus Gittinger
|
|
25 |
All Rights Reserved
|
|
26 |
|
|
27 |
This software is furnished under a license and may be used
|
|
28 |
only in accordance with the terms of that license and with the
|
|
29 |
inclusion of the above copyright notice. This software may not
|
|
30 |
be provided or otherwise made available to, or used by, any
|
|
31 |
other person. No title to or ownership of the software is
|
|
32 |
hereby transferred.
|
|
33 |
"
|
|
34 |
!
|
|
35 |
|
|
36 |
documentation
|
|
37 |
"
|
|
38 |
QuerySignals are like signals, except that they are not accepted
|
|
39 |
by handlers for ordinary signals.
|
|
40 |
I.e. a signal handler for a normal signal will not handle a query
|
580
|
41 |
signal. Thus, these bypass anySignal handlers.
|
1248
|
42 |
If unhandled, no error is raised, instead they are simply ignored
|
|
43 |
(as opposed to normal signals, which raise an unhandled signal exception).
|
|
44 |
|
|
45 |
Their main use is to implement up-Queries via signals even if intermediate
|
|
46 |
errorSignal handlers are present (which is not possible with ordinary signals).
|
|
47 |
Code deep down in the calling hierarchy can post such an up-Query to ask
|
|
48 |
for some information in return or to pass some information upward.
|
580
|
49 |
|
1248
|
50 |
For example, the activityNotification mechanism is built on top of this:
|
|
51 |
everyone can send such a notification which is either handled by someone
|
|
52 |
up in the hierarchy (to show it in the windows info area) or simply
|
|
53 |
ignored.
|
|
54 |
|
|
55 |
Using QuerySignals for this (instead of regular Signals) helps in documenting
|
|
56 |
the intended usage of those signals.
|
580
|
57 |
"
|
|
58 |
!
|
|
59 |
|
|
60 |
examples
|
|
61 |
"
|
|
62 |
an up-query from a deeply nested operation to a higher level:
|
|
63 |
|
|
64 |
|querySignal zero|
|
|
65 |
|
|
66 |
zero := 0.
|
|
67 |
querySignal := QuerySignal new.
|
|
68 |
querySignal handle:[:ex |
|
|
69 |
ex proceedWith:true
|
|
70 |
] do:[
|
|
71 |
'nexting'.
|
|
72 |
[
|
|
73 |
[
|
|
74 |
Object errorSignal handle:[:ex |
|
|
75 |
ex proceed
|
|
76 |
] do:[
|
|
77 |
[
|
|
78 |
1 // zero. 'a cought error'.
|
|
79 |
(querySignal raise) ifTrue:[
|
|
80 |
Transcript showCr:'query says: ok'.
|
|
81 |
] ifFalse:[
|
|
82 |
Transcript showCr:'query says: no'
|
|
83 |
]
|
|
84 |
] value
|
|
85 |
]
|
|
86 |
] value
|
|
87 |
] value
|
|
88 |
]
|
420
|
89 |
"
|
|
90 |
! !
|
|
91 |
|
|
92 |
!QuerySignal methodsFor:'queries'!
|
|
93 |
|
|
94 |
accepts:aSignal
|
|
95 |
"return true, if the receiver accepts the argument, aSignal.
|
|
96 |
(i.e. the receiver is aSignal or a parent of it). False otherwise."
|
|
97 |
|
|
98 |
|s|
|
|
99 |
|
421
|
100 |
aSignal isQuerySignal ifFalse:[^ false].
|
420
|
101 |
|
|
102 |
s := aSignal.
|
|
103 |
[s notNil] whileTrue:[
|
|
104 |
self == s ifTrue:[^ true].
|
|
105 |
s := s parent
|
|
106 |
].
|
|
107 |
^ false
|
691
|
108 |
!
|
|
109 |
|
|
110 |
isQuerySignal
|
1249
|
111 |
"return true, if this is a querySignal - always return true here"
|
|
112 |
|
691
|
113 |
^ true
|
1249
|
114 |
|
|
115 |
"Modified: 22.4.1996 / 13:45:10 / cg"
|
420
|
116 |
! !
|
691
|
117 |
|
|
118 |
!QuerySignal class methodsFor:'documentation'!
|
|
119 |
|
|
120 |
version
|
1249
|
121 |
^ '$Header: /cvs/stx/stx/libbasic/QuerySignal.st,v 1.7 1996-04-22 11:45:15 cg Exp $'
|
691
|
122 |
! !
|