DEADSOFTWARE

Modularize, some progress toward reading stores
[odcread.git] / store.h
1 #ifndef _STORE_H_
2 #define _STORE_H_
4 #include <oberon.h>
5 #include <domain.h>
7 namespace odc {
9 /**
10 * TYPE Store
11 * ABSTRACT
12 * Storable extensible data types like Views.View or TextModels.Text are derived from Store.
13 * Stores are typically allocated by suitable directories, e.g., Views.Directory or TextModels.Directory.
14 * Stores are used as base types for all objects that must be both extensible and persistent.
15 */
16 class Store {
17 public:
18 static const SHORTCHAR NEWBASE = 0xF0; // (* new base type (level = 0), i.e. not yet in dict *)
19 static const SHORTCHAR NEWEXT = 0xF1; // (* new extension type (level = 1), i.e. not yet in dict *)
20 static const SHORTCHAR OLDTYPE = 0xF2; // (* old type, i.e. already in dict *)
21 static const SHORTCHAR NIL = 0x80; // (* nil store *)
22 static const SHORTCHAR LINK = 0x81; // (* link to another elem in same file *)
23 static const SHORTCHAR STORE = 0x82; // (* general store *)
24 static const SHORTCHAR ELEM = 0x83; // (* elem store *)
25 static const SHORTCHAR NEWLINK = 0x84; // (* link to another non-elem store in same file *)
26 /**
27 * PROCEDURE (s: Store) Domain (): Domain
28 * NEW
29 * A store may be associated with a domain. This is done by the procedure InitDomain, which assigns a domain to the store.
30 * Domain may be called by arbitrary clients.
31 */
32 Domain* getDomain();
34 /**
35 * PROCEDURE (s: Store) CopyFrom- (source: Store)
36 * NEW, EMPTY
37 * Copy the contents of source to s. Copying is a deep copy.
38 *
39 * Pre
40 * source # NIL guaranteed
41 * TYP(source) = TYP(s) guaranteed
42 * s.Domain() = NIL guaranteed
43 * s is not yet initialized guaranteed
44 */
45 // FIXME
46 /**
47 * PROCEDURE (s: Store) Internalize- (VAR rd: Reader)
48 * NEW, EMPTY
49 * (For backward compatibility, this method is actually still EXTENSIBLE. This may change in the future.)
50 * Reads the contents of s from reader rd. Internalize must read the same (amount of) data as is written by the corresponding Externalize procedure.
51 * Internalize is called locally.
52 * Internalize is extended by various persistent object types, e.g., models, views, and controllers.
53 *
54 * Pre
55 * source.Domain() = NIL guaranteed
56 * source is not yet initialized guaranteed
57 */
58 // void internalize(Reader &reader) {
59 // PROCEDURE (s: Store) Internalize- (VAR rd: Reader), NEW, EXTENSIBLE;
60 // VAR thisVersion: INTEGER;
61 // BEGIN
62 // rd.ReadVersion(minVersion, maxStoreVersion, thisVersion);
63 // IF ~rd.cancelled & s.isElem THEN
64 // rd.ReadVersion(minVersion, maxStoreVersion, thisVersion)
65 // (* works since maxStoreVersion = maxElemVersion = 0 in pre-1.3 *)
66 // END
67 // END Internalize;
68 // }
70 /**
71 * PROCEDURE (s: Store) Externalize- (VAR wr: Writer)
72 * NEW, EMPTY
73 * (For backward compatibility, this method is actually still EXTENSIBLE. This may change in the future.)
74 * Write the contents of s to writer wr. Externalize must write the same (amount of) data as is read by the corresponding Internalize procedure.
75 * Externalize ist called locally.
76 * Externalize is extended by various persistent object types, e.g., models, views, and controllers.
77 */
78 // FIXME
80 /**
81 * PROCEDURE (s: Store) ExternalizeAs- (VAR s1: Store)
82 * NEW, EMPTY
83 * Before a store's Externalize procedure is called, its ExternalizeAs procedure is called, which gives the store the opportunity to denote another store that should be externalized in its place (a "proxy"). It is also possible to set s1 to NIL, which means that the store should not be externalized at all. This is used e.g. for compiler error markers, which are never stored.
84 * ExternalizeAs ist called locally.
85 *
86 * Pre
87 * s1 = s guaranteed
88 */
89 // FIXME
90 };
92 }
94 #endif // _STORE_H_