6 #include <typeregister.h>
12 class Reader
; // forward decl
14 class TypePath
: public std::vector
<std::string
> {
16 std::string
toString() const;
22 * Storable extensible data types like Views.View or TextModels.Text are derived from Store.
23 * Stores are typically allocated by suitable directories, e.g., Views.Directory or TextModels.Directory.
24 * Stores are used as base types for all objects that must be both extensible and persistent.
28 static const std::string TYPENAME
;
29 static const TypeProxy
<Store
> PROXY
;
34 static const SHORTCHAR NEWBASE
= 0xF0; // (* new base type (level = 0), i.e. not yet in dict *)
35 static const SHORTCHAR NEWEXT
= 0xF1; // (* new extension type (level = 1), i.e. not yet in dict *)
36 static const SHORTCHAR OLDTYPE
= 0xF2; // (* old type, i.e. already in dict *)
37 static const SHORTCHAR NIL
= 0x80; // (* nil store *)
38 static const SHORTCHAR LINK
= 0x81; // (* link to another elem in same file *)
39 static const SHORTCHAR STORE
= 0x82; // (* general store *)
40 static const SHORTCHAR ELEM
= 0x83; // (* elem store *)
41 static const SHORTCHAR NEWLINK
= 0x84; // (* link to another non-elem store in same file *)
48 * Get the TypeName of this object.
51 static const std::string
&getType();
53 * Get the TypeName of the supertype of this object. Return 0 pointer if no supertype.
56 static const std::string
*getSuper();
58 * Get the TypeName for this object.
60 virtual const std::string
&getTypeName() const;
62 * Get the TypePath to this object's type.
65 void getTypePath(TypePath
*path
) const;
68 * PROCEDURE (s: Store) Domain (): Domain
70 * A store may be associated with a domain. This is done by the procedure InitDomain, which assigns a domain to the store.
71 * Domain may be called by arbitrary clients.
73 //Domain* getDomain();
76 * PROCEDURE (s: Store) CopyFrom- (source: Store)
78 * Copy the contents of source to s. Copying is a deep copy.
81 * source # NIL guaranteed
82 * TYP(source) = TYP(s) guaranteed
83 * s.Domain() = NIL guaranteed
84 * s is not yet initialized guaranteed
88 * PROCEDURE (s: Store) Internalize- (VAR rd: Reader)
90 * (For backward compatibility, this method is actually still EXTENSIBLE. This may change in the future.)
91 * Reads the contents of s from reader rd. Internalize must read the same (amount of) data as is written by the corresponding Externalize procedure.
92 * Internalize is called locally.
93 * Internalize is extended by various persistent object types, e.g., models, views, and controllers.
96 * source.Domain() = NIL guaranteed
97 * source is not yet initialized guaranteed
99 virtual void internalize(Reader
&reader
);
100 // PROCEDURE (s: Store) Internalize- (VAR rd: Reader), NEW, EXTENSIBLE;
101 // VAR thisVersion: INTEGER;
103 // rd.ReadVersion(minVersion, maxStoreVersion, thisVersion);
104 // IF ~rd.cancelled & s.isElem THEN
105 // rd.ReadVersion(minVersion, maxStoreVersion, thisVersion)
106 // (* works since maxStoreVersion = maxElemVersion = 0 in pre-1.3 *)
112 * PROCEDURE (s: Store) Externalize- (VAR wr: Writer)
114 * (For backward compatibility, this method is actually still EXTENSIBLE. This may change in the future.)
115 * Write the contents of s to writer wr. Externalize must write the same (amount of) data as is read by the corresponding Internalize procedure.
116 * Externalize ist called locally.
117 * Externalize is extended by various persistent object types, e.g., models, views, and controllers.
122 * PROCEDURE (s: Store) ExternalizeAs- (VAR s1: Store)
124 * 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.
125 * ExternalizeAs ist called locally.
132 virtual std::string
toString();
135 void calcTypePath(TypePath
* out
, const std::string
&name
) const;
138 class Elem
: public Store
{
140 static const std::string TYPENAME
;
141 static const TypeProxy
<Elem
> PROXY
;
147 * Get the TypeName of this object.
150 static const std::string
&getType();
152 * Get the TypeName of the supertype of this object. Return 0 pointer if no supertype.
155 static const std::string
*getSuper();
157 * Get the TypeName for this object.
159 virtual const std::string
&getTypeName() const;
161 virtual void internalize(Reader
&reader
);
164 class Model
: public Elem
{
166 static const std::string TYPENAME
;
167 static const TypeProxy
<Model
> PROXY
;
173 * Get the TypeName of this object.
176 static const std::string
&getType();
178 * Get the TypeName of the supertype of this object. Return 0 pointer if no supertype.
181 static const std::string
*getSuper();
183 * Get the TypeName for this object.
185 virtual const std::string
&getTypeName() const;
187 virtual void internalize(Reader
&reader
);
190 class ContainerModel
: public Model
{
192 static const std::string TYPENAME
;
193 static const TypeProxy
<ContainerModel
> PROXY
;
196 ContainerModel(INTEGER id
);
197 static const std::string
&getType();
198 static const std::string
*getSuper();
199 virtual const std::string
&getTypeName() const;
200 virtual void internalize(Reader
&reader
);