DEADSOFTWARE

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