author | Claus Gittinger <cg@exept.de> |
Tue, 29 Aug 2017 23:16:03 +0200 | |
changeset 4000 | d39d58494281 |
parent 3202 | 77a9af3ab997 |
permissions | -rw-r--r-- |
2452 | 1 |
" |
2 |
COPYRIGHT (c) 2008 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 |
"{ Package: 'stx:libview2' }" |
|
13 |
||
14 |
ValueHolder subclass:#BooleanValueHolder |
|
15 |
instanceVariableNames:'' |
|
16 |
classVariableNames:'' |
|
17 |
poolDictionaries:'' |
|
18 |
category:'Interface-Support-Models' |
|
19 |
! |
|
20 |
||
21 |
!BooleanValueHolder class methodsFor:'documentation'! |
|
22 |
||
23 |
copyright |
|
24 |
" |
|
25 |
COPYRIGHT (c) 2008 by Claus Gittinger |
|
26 |
All Rights Reserved |
|
27 |
||
28 |
This software is furnished under a license and may be used |
|
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
35 |
! |
|
36 |
||
37 |
documentation |
|
38 |
" |
|
39 |
a valueHolder holding a boolean. |
|
40 |
Mostly for documentation purposes and the assertion, that only boolean values |
|
41 |
are held. Also provides convenient logical operations. |
|
42 |
||
43 |
[author:] |
|
44 |
Claus Gittinger |
|
45 |
" |
|
46 |
! |
|
47 |
||
48 |
examples |
|
49 |
" |
|
50 |
[exBegin] |
|
51 |
|b nb| |
|
52 |
||
53 |
b := BooleanValueHolder new. |
|
54 |
nb := b not. |
|
55 |
b value:true. |
|
56 |
nb value. |
|
57 |
b value:false. |
|
58 |
nb value. |
|
59 |
[exEnd] |
|
60 |
" |
|
61 |
! ! |
|
62 |
||
63 |
!BooleanValueHolder class methodsFor:'instance creation'! |
|
64 |
||
65 |
new |
|
66 |
"return a new BooleanValueHolder holding false as initial value" |
|
67 |
||
68 |
^ self with:false |
|
69 |
! ! |
|
70 |
||
71 |
!BooleanValueHolder methodsFor:'accessing'! |
|
72 |
||
73 |
setValue:aBoolean |
|
74 |
self assert:aBoolean isBoolean. |
|
75 |
value := aBoolean. |
|
76 |
! ! |
|
77 |
||
78 |
!BooleanValueHolder methodsFor:'logical operations'! |
|
79 |
||
80 |
& anotherBooleanValueHolder |
|
81 |
"return another valueHolder, which returns the logical and of myself and another valueHolder" |
|
82 |
||
2464 | 83 |
^ BooleanBlockValue |
2452 | 84 |
forLogical:self and:anotherBooleanValueHolder |
85 |
||
86 |
" |
|
87 |
|b1 b2 a| |
|
88 |
||
89 |
b1 := BooleanValueHolder new. |
|
90 |
b2 := BooleanValueHolder new. |
|
91 |
a := b1 & b2. |
|
92 |
b1 value:false. |
|
93 |
b2 value:true. |
|
94 |
a value. |
|
95 |
b1 value:true. |
|
96 |
a value. |
|
97 |
" |
|
98 |
! |
|
99 |
||
2483
be285c88b641
cannot use not as selector - sigh !
Claus Gittinger <cg@exept.de>
parents:
2464
diff
changeset
|
100 |
logicalNot |
2452 | 101 |
"return another valueHolder, which returns the logical not of myself" |
102 |
||
2464 | 103 |
^ BooleanBlockValue forLogicalNot:self. |
2452 | 104 |
|
105 |
" |
|
106 |
|b nb| |
|
107 |
||
108 |
b := BooleanValueHolder new. |
|
109 |
nb := b not. |
|
110 |
b value:true. |
|
111 |
nb value. |
|
112 |
b value:false. |
|
113 |
nb value. |
|
114 |
" |
|
115 |
! |
|
116 |
||
117 |
| anotherBooleanValueHolder |
|
3202 | 118 |
"return another valueHolder, which returns the logical or of myself and another valueHolder" |
2452 | 119 |
|
2464 | 120 |
^ BooleanBlockValue |
2452 | 121 |
forLogical:self or:anotherBooleanValueHolder |
122 |
||
123 |
" |
|
124 |
|b1 b2 o| |
|
125 |
||
126 |
b1 := BooleanValueHolder new. |
|
127 |
b2 := BooleanValueHolder new. |
|
128 |
o := b1 | b2. |
|
129 |
b1 value:false. |
|
130 |
b2 value:false. |
|
131 |
o value. |
|
132 |
b1 value:true. |
|
133 |
o value. |
|
134 |
" |
|
3202 | 135 |
|
136 |
"Modified (comment): / 27-07-2013 / 09:55:01 / cg" |
|
2452 | 137 |
! ! |
138 |
||
139 |
!BooleanValueHolder class methodsFor:'documentation'! |
|
140 |
||
141 |
version |
|
3202 | 142 |
^ '$Header: /cvs/stx/stx/libview2/BooleanValueHolder.st,v 1.4 2013-07-27 08:10:10 cg Exp $' |
2452 | 143 |
! ! |
3202 | 144 |