DEADSOFTWARE

HostDialog: Preferences dialog
[bbcp.git] / Trurl-based / System / Mod / Models.txt
1 MODULE Models;
3 (* THIS IS TEXT COPY OF BlackBox 1.6-rc6 System/Mod/Models.odc *)
4 (* DO NOT EDIT *)
6 IMPORT Kernel, Stores, Sequencers;
8 CONST
9 minVersion = 0; maxVersion = 0;
11 clean* = Sequencers.clean;
12 notUndoable* = Sequencers.notUndoable;
13 invisible* = Sequencers.invisible;
15 TYPE
16 Model* = POINTER TO ABSTRACT RECORD (Stores.Store)
17 era: INTEGER; (* stable era >= x *)
18 guard: INTEGER (* = TrapCount()+1 if model is addressee of ongoing broadcast *)
19 END;
21 Context* = POINTER TO ABSTRACT RECORD END;
23 Proposal* = ABSTRACT RECORD END;
26 Message* = ABSTRACT RECORD
27 model-: Model;
28 era-: INTEGER
29 END;
31 NeutralizeMsg* = RECORD (Message) END;
33 UpdateMsg* = EXTENSIBLE RECORD (Message) END;
36 VAR domainGuard: INTEGER; (* = TrapCount()+1 if domain is addressee of ongoing domaincast *)
39 (** Model **)
41 PROCEDURE (m: Model) Internalize- (VAR rd: Stores.Reader), EXTENSIBLE;
42 VAR thisVersion: INTEGER;
43 BEGIN
44 m.Internalize^(rd);
45 IF rd.cancelled THEN RETURN END;
46 rd.ReadVersion(minVersion, maxVersion, thisVersion)
47 END Internalize;
49 PROCEDURE (m: Model) Externalize- (VAR wr: Stores.Writer), EXTENSIBLE;
50 BEGIN
51 m.Externalize^(wr);
52 wr.WriteVersion(maxVersion)
53 END Externalize;
56 (** Context **)
58 PROCEDURE (c: Context) ThisModel* (): Model, NEW, ABSTRACT;
59 PROCEDURE (c: Context) Normalize* (): BOOLEAN, NEW, ABSTRACT;
60 PROCEDURE (c: Context) GetSize* (OUT w, h: INTEGER), NEW, ABSTRACT;
61 PROCEDURE (c: Context) SetSize* (w, h: INTEGER), NEW, EMPTY;
62 PROCEDURE (c: Context) MakeVisible* (l, t, r, b: INTEGER), NEW, EMPTY;
63 PROCEDURE (c: Context) Consider* (VAR p: Proposal), NEW, EMPTY;
66 (** miscellaneous **)
68 PROCEDURE Era* (m: Model): INTEGER;
69 BEGIN
70 ASSERT(m # NIL, 20);
71 RETURN m.era
72 END Era;
75 PROCEDURE CopyOf* (m: Model): Model;
76 BEGIN
77 ASSERT(m # NIL, 20);
78 RETURN Stores.CopyOf(m)(Model)
79 END CopyOf;
81 PROCEDURE BeginScript* (m: Model; name: Stores.OpName; OUT script: Stores.Operation);
82 (** post: (script # NIL) iff (m.domain # NIL) **)
83 VAR seq: ANYPTR;
84 BEGIN
85 ASSERT(m # NIL, 20);
86 IF m.Domain() # NIL THEN seq := m.Domain().GetSequencer() ELSE seq := NIL END;
87 IF seq # NIL THEN
88 WITH seq: Sequencers.Sequencer DO
89 seq.BeginScript(name, script)
90 ELSE
91 END
92 ELSE script := NIL
93 END
94 END BeginScript;
96 PROCEDURE Do* (m: Model; name: Stores.OpName; op: Stores.Operation);
97 (** pre: m # NIL, op # NIL, ~op.inUse **)
98 VAR seq: ANYPTR;
99 BEGIN
100 ASSERT(m # NIL, 20); ASSERT(op # NIL, 21); (* ASSERT(~op.inUse, 22); *)
101 IF m.Domain() # NIL THEN seq := m.Domain().GetSequencer() ELSE seq := NIL END;
102 IF seq # NIL THEN
103 WITH seq: Sequencers.Sequencer DO
104 seq.Do(m, name, op)
105 ELSE
106 op.Do
107 END
108 ELSE
109 op.Do
110 END
111 END Do;
113 PROCEDURE LastOp* (m: Model): Stores.Operation;
114 (** pre: m # NIL **)
115 VAR seq: ANYPTR;
116 BEGIN
117 ASSERT(m # NIL, 20);
118 IF m.Domain() # NIL THEN seq := m.Domain().GetSequencer() ELSE seq := NIL END;
119 IF seq # NIL THEN
120 WITH seq: Sequencers.Sequencer DO
121 RETURN seq.LastOp(m)
122 ELSE
123 RETURN NIL
124 END
125 ELSE
126 RETURN NIL
127 END
128 END LastOp;
130 PROCEDURE Bunch* (m: Model);
131 (** pre: m # NIL, m.Domain() # NIL **)
132 VAR seq: ANYPTR;
133 BEGIN
134 ASSERT(m # NIL, 20); ASSERT(m.Domain() # NIL, 21);
135 seq := m.Domain().GetSequencer();
136 ASSERT(seq # NIL, 22);
137 WITH seq: Sequencers.Sequencer DO
138 seq.Bunch(m)
139 ELSE
140 END
141 END Bunch;
143 PROCEDURE StopBunching* (m: Model);
144 (** pre: m # NIL **)
145 VAR seq: ANYPTR;
146 BEGIN
147 ASSERT(m # NIL, 20);
148 IF m.Domain() # NIL THEN seq := m.Domain().GetSequencer() ELSE seq := NIL END;
149 IF seq # NIL THEN
150 WITH seq: Sequencers.Sequencer DO
151 seq.StopBunching
152 ELSE
153 END
154 END
155 END StopBunching;
157 PROCEDURE EndScript* (m: Model; script: Stores.Operation);
158 (** pre: (script # NIL) iff (m.seq # NIL) **)
159 VAR seq: ANYPTR;
160 BEGIN
161 ASSERT(m # NIL, 20);
162 IF m.Domain() # NIL THEN seq := m.Domain().GetSequencer() ELSE seq := NIL END;
163 IF seq # NIL THEN
164 ASSERT(script # NIL, 21);
165 WITH seq: Sequencers.Sequencer DO
166 seq.EndScript(script)
167 ELSE
168 ASSERT(script = NIL, 21)
169 END
170 ELSE
171 ASSERT(script = NIL, 21)
172 END
173 END EndScript;
176 PROCEDURE BeginModification* (type: INTEGER; m: Model);
177 (** pre: m # NIL **)
178 VAR seq: ANYPTR;
179 BEGIN
180 ASSERT(m # NIL, 20);
181 IF m.Domain() # NIL THEN seq := m.Domain().GetSequencer() ELSE seq := NIL END;
182 IF seq # NIL THEN
183 WITH seq: Sequencers.Sequencer DO
184 seq.BeginModification(type, m)
185 ELSE
186 END
187 END
188 END BeginModification;
190 PROCEDURE EndModification* (type: INTEGER; m: Model);
191 (** pre: m # NIL **)
192 VAR seq: ANYPTR;
193 BEGIN
194 ASSERT(m # NIL, 20);
195 IF m.Domain() # NIL THEN seq := m.Domain().GetSequencer() ELSE seq := NIL END;
196 IF seq # NIL THEN
197 WITH seq: Sequencers.Sequencer DO
198 seq.EndModification(type, m)
199 ELSE
200 END
201 END
202 END EndModification;
204 PROCEDURE SetDirty* (m: Model);
205 (** pre: m # NIL **)
206 VAR seq: ANYPTR;
207 BEGIN
208 ASSERT(m # NIL, 20);
209 IF m.Domain() # NIL THEN seq := m.Domain().GetSequencer() ELSE seq := NIL END;
210 IF seq # NIL THEN
211 WITH seq: Sequencers.Sequencer DO
212 seq.SetDirty(TRUE)
213 ELSE
214 END
215 END
216 END SetDirty;
218 PROCEDURE Domaincast* (d: Stores.Domain; VAR msg: Message);
219 VAR g: INTEGER; seq: ANYPTR;
220 BEGIN
221 IF d # NIL THEN
222 seq := d.GetSequencer();
223 IF (seq # NIL) & (seq IS Sequencers.Sequencer) THEN
224 msg.model := NIL; msg.era := -1;
225 g := Kernel.trapCount + 1;
226 IF domainGuard > 0 THEN ASSERT(domainGuard # g, 20) END;
227 domainGuard := g;
228 seq(Sequencers.Sequencer).Handle(msg);
229 domainGuard := 0
230 END
231 END
232 END Domaincast;
234 PROCEDURE Broadcast* (m: Model; VAR msg: Message);
235 (** pre: model # NIL **)
236 (** post: model.era > model.era', msg.model = model, msg.era = model.era' + 1,
237 model.seq # NIL => msg sent to seq **)
238 VAR seq: ANYPTR; g: INTEGER;
239 BEGIN
240 ASSERT(m # NIL, 20);
241 msg.model := m;
242 IF m.Domain() # NIL THEN seq := m.Domain().GetSequencer() ELSE seq := NIL END;
243 IF seq # NIL THEN
244 WITH seq: Sequencers.Sequencer DO
245 INC(m.era); msg.era := m.era;
246 g := Kernel.trapCount + 1;
247 IF m.guard > 0 THEN ASSERT(m.guard # g, 21) END;
248 m.guard := g;
249 seq.Handle(msg);
250 m.guard := 0
251 ELSE
252 END
253 END
254 END Broadcast;
256 BEGIN
257 domainGuard := 0
258 END Models.