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
|
|
14 |
instanceVariableNames:''
|
|
15 |
classVariableNames:''
|
|
16 |
poolDictionaries:''
|
|
17 |
category:'Kernel-Exceptions'
|
|
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.
|
|
42 |
Also, using a QuerySignal helps in documenting the intended use of these signals.
|
|
43 |
|
|
44 |
They can be used to implement up-Queries via signals even if intermediate
|
|
45 |
errorSignal handlers are present (which is no possible with ordinary signals).
|
|
46 |
"
|
|
47 |
!
|
|
48 |
|
|
49 |
examples
|
|
50 |
"
|
|
51 |
an up-query from a deeply nested operation to a higher level:
|
|
52 |
|
|
53 |
|querySignal zero|
|
|
54 |
|
|
55 |
zero := 0.
|
|
56 |
querySignal := QuerySignal new.
|
|
57 |
querySignal handle:[:ex |
|
|
58 |
ex proceedWith:true
|
|
59 |
] do:[
|
|
60 |
'nexting'.
|
|
61 |
[
|
|
62 |
[
|
|
63 |
Object errorSignal handle:[:ex |
|
|
64 |
ex proceed
|
|
65 |
] do:[
|
|
66 |
[
|
|
67 |
1 // zero. 'a cought error'.
|
|
68 |
(querySignal raise) ifTrue:[
|
|
69 |
Transcript showCr:'query says: ok'.
|
|
70 |
] ifFalse:[
|
|
71 |
Transcript showCr:'query says: no'
|
|
72 |
]
|
|
73 |
] value
|
|
74 |
]
|
|
75 |
] value
|
|
76 |
] value
|
|
77 |
]
|
420
|
78 |
"
|
|
79 |
! !
|
|
80 |
|
|
81 |
!QuerySignal methodsFor:'queries'!
|
|
82 |
|
|
83 |
accepts:aSignal
|
|
84 |
"return true, if the receiver accepts the argument, aSignal.
|
|
85 |
(i.e. the receiver is aSignal or a parent of it). False otherwise."
|
|
86 |
|
|
87 |
|s|
|
|
88 |
|
421
|
89 |
aSignal isQuerySignal ifFalse:[^ false].
|
420
|
90 |
|
|
91 |
s := aSignal.
|
|
92 |
[s notNil] whileTrue:[
|
|
93 |
self == s ifTrue:[^ true].
|
|
94 |
s := s parent
|
|
95 |
].
|
|
96 |
^ false
|
691
|
97 |
!
|
|
98 |
|
|
99 |
isQuerySignal
|
|
100 |
^ true
|
420
|
101 |
! !
|
691
|
102 |
|
|
103 |
!QuerySignal class methodsFor:'documentation'!
|
|
104 |
|
|
105 |
version
|
|
106 |
^ '$Header: /cvs/stx/stx/libbasic/QuerySignal.st,v 1.5 1995-12-07 19:12:37 cg Exp $'
|
|
107 |
! !
|