8 #include "typeregister/typeregister.h"
9 #include "visitor/visitor.h"
10 #include "typepath/typepath.h"
13 class Reader
; // forward decl
18 * Storable extensible data types like Views.View or TextModels.Text are derived from Store.
19 * Stores are typically allocated by suitable directories, e.g., Views.Directory or TextModels.Directory.
20 * Stores are used as base types for all objects that must be both extensible and persistent.
24 static const TopTypeProxy
<Store
> PROXY
;
29 static const std::string TYPENAME
;
30 static const SHORTCHAR NEWBASE
= 0xF0; // (* new base type (level = 0), i.e. not yet in dict *)
31 static const SHORTCHAR NEWEXT
= 0xF1; // (* new extension type (level = 1), i.e. not yet in dict *)
32 static const SHORTCHAR OLDTYPE
= 0xF2; // (* old type, i.e. already in dict *)
33 static const SHORTCHAR NIL
= 0x80; // (* nil store *)
34 static const SHORTCHAR LINK
= 0x81; // (* link to another elem in same file *)
35 static const SHORTCHAR STORE
= 0x82; // (* general store *)
36 static const SHORTCHAR ELEM
= 0x83; // (* elem store *)
37 static const SHORTCHAR NEWLINK
= 0x84; // (* link to another non-elem store in same file *)
44 * Get the TypeName for this object.
46 virtual const std::string
&getTypeName() const;
48 * Get the TypePath to this object's type.
49 * I'm not sure why this was necessary, I think BlackBox uses them in some code
53 TypePath
getTypePath() const;
56 * PROCEDURE (s: Store) Domain (): Domain
58 * A store may be associated with a domain. This is done by the procedure InitDomain, which assigns a domain to the store.
59 * Domain may be called by arbitrary clients.
61 //Domain* getDomain();
64 * Read the contents of "this" from reader.
65 * Just reads the version and checks that its in the allowed range.
67 virtual void internalize(Reader
&reader
);
69 // In BlackBox, a Store will also have an externalize(writer) method.
70 // The internalize and externalize should be compatible (internalize
71 // should be able to read what externalize writes).
76 virtual std::string
toString();
79 * Receiving end of the Visitor pattern.
81 virtual void accept(Visitor
&visitor
) const;
84 void calcTypePath(TypePath
*out
, const std::string
&name
) const;
88 * An "Elem" store. Some kind of legacy BlackBox type that has been rolled into Store.
89 * I actually found it easier to keep the two separate.
91 class Elem
: public Store
{
93 static const TypeProxy
<Elem
, Store
> PROXY
;
96 static const std::string TYPENAME
;
97 virtual const std::string
&getTypeName() const;
101 * Just calls super and reads the version and checks that its in the allowed range.
103 virtual void internalize(Reader
&reader
);
107 * A "Model" store. The basis for all model objects (in MVC framework).
108 * Most objects of interest extend Model.
110 class Model
: public Elem
{
112 static const TypeProxy
<Model
, Elem
> PROXY
;
115 static const std::string TYPENAME
;
116 virtual const std::string
&getTypeName() const;
120 * Just calls super and reads the version and checks that its in the allowed range.
122 virtual void internalize(Reader
&reader
);
126 * Super type for models that contain other stuff (e.g. TextModel).
128 class ContainerModel
: public Model
{
130 static const TypeProxy
<ContainerModel
, Model
> PROXY
;
133 static const std::string TYPENAME
;
134 virtual const std::string
&getTypeName() const;
136 ContainerModel(INTEGER id
);
138 * Just calls super and reads the version and checks that its in the allowed range.
140 virtual void internalize(Reader
&reader
);