DEADSOFTWARE

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