DEADSOFTWARE

Add type handling (disabled until StdTextModel.internalize is implemented)
[odcread.git] / store.h
diff --git a/store.h b/store.h
index 381cca7907670fe4565ad135eae331d52aa6319d..54438ab4845b72d44b563fa16c1901897b79099a 100644 (file)
--- a/store.h
+++ b/store.h
@@ -3,8 +3,18 @@
 
 #include <oberon.h>
 #include <domain.h>
+#include <typeregister.h>
+
+#include <string>
+#include <vector>
 
 namespace odc {
+       class Reader; // forward decl
+
+       class TypePath : public std::vector<std::string> {
+               public:
+               std::string toString() const;
+       };
 
        /**
         * TYPE Store
@@ -14,6 +24,13 @@ namespace odc {
         * Stores are used as base types for all objects that must be both extensible and persistent.
         */
        class Store {
+       private:
+               static const std::string TYPENAME;
+               static const TypeProxy<Store> PROXY;
+               static TypePath *s_typePath;
+
+               INTEGER d_id;
+
        public: 
                static const SHORTCHAR NEWBASE = 0xF0; // (* new base type (level = 0), i.e. not yet in dict *)
                static const SHORTCHAR NEWEXT = 0xF1;  // (* new extension type (level = 1), i.e. not yet in dict *)
@@ -23,13 +40,38 @@ namespace odc {
                static const SHORTCHAR STORE = 0x82;   // (* general store *)
                static const SHORTCHAR ELEM = 0x83;    // (* elem store *)
                static const SHORTCHAR NEWLINK = 0x84; // (* link to another non-elem store in same file *)
+
+               Store(INTEGER id);
+
+               INTEGER getId();
+               
+               /**
+                * Get the TypeName of this object.
+                * @see TypeRegister
+                */
+               static const std::string &getType();
+               /**
+                * Get the TypeName of the supertype of this object. Return 0 pointer if no supertype.
+                * @see TypeRegister
+                */
+               static const std::string *getSuper();
+               /**
+                * Get the TypeName for this object.
+                */
+               virtual const std::string &getTypeName() const;
+               /**
+                * Get the TypePath to this object's type.
+                * @see TypePath
+                */
+               const TypePath &getTypePath() const;
+
                /**
                 * PROCEDURE (s: Store) Domain (): Domain
                 * NEW
                 * A store may be associated with a domain. This is done by the procedure InitDomain, which assigns a domain to the store.
                 * Domain may be called by arbitrary clients.
                 */
-               Domain* getDomain();
+               //Domain* getDomain();
 
                /**
                 * PROCEDURE (s: Store) CopyFrom- (source: Store)
@@ -55,7 +97,7 @@ namespace odc {
                 * source.Domain() = NIL        guaranteed
                 * source is not yet initialized        guaranteed
                 */
-//              void internalize(Reader &reader) {
+                virtual void internalize(Reader &reader);
 //     PROCEDURE (s: Store) Internalize- (VAR rd: Reader), NEW, EXTENSIBLE;
 //             VAR thisVersion: INTEGER;
 //     BEGIN
@@ -87,8 +129,103 @@ namespace odc {
                 * s1 = s       guaranteed
                 */
                // FIXME
+
+               virtual std::string toString();
+
+               private:
+               TypePath *calcTypePath(const std::string &name) const;
+       };
+
+       class Elem : public Store {
+               private:
+               static const std::string TYPENAME;
+               static const TypeProxy<Elem> PROXY;
+
+               public:
+               Elem(INTEGER id);
+               
+               /**
+                * Get the TypeName of this object.
+                * @see TypeRegister
+                */
+               static const std::string &getType();
+               /**
+                * Get the TypeName of the supertype of this object. Return 0 pointer if no supertype.
+                * @see TypeRegister
+                */
+               static const std::string *getSuper();
+               /**
+                * Get the TypeName for this object.
+                */
+               virtual const std::string &getTypeName() const;
+
+               virtual void internalize(Reader &reader);
        };
 
+       class Model : public Elem {
+               private:
+               static const std::string TYPENAME;
+               static const TypeProxy<Model> PROXY;
+
+               public:
+               Model(INTEGER id);
+               
+               /**
+                * Get the TypeName of this object.
+                * @see TypeRegister
+                */
+               static const std::string &getType();
+               /**
+                * Get the TypeName of the supertype of this object. Return 0 pointer if no supertype.
+                * @see TypeRegister
+                */
+               static const std::string *getSuper();
+               /**
+                * Get the TypeName for this object.
+                */
+               virtual const std::string &getTypeName() const;
+
+               virtual void internalize(Reader &reader);
+       };
+
+       class ContainerModel : public Model {
+               private:
+               static const std::string TYPENAME;
+               static const TypeProxy<ContainerModel> PROXY;
+
+               public:
+               ContainerModel(INTEGER id);
+               static const std::string &getType();
+               static const std::string *getSuper();
+               virtual const std::string &getTypeName() const;
+               virtual void internalize(Reader &reader);
+       };
+
+       class TextModel : public ContainerModel {
+               private:
+               static const std::string TYPENAME;
+               static const TypeProxy<TextModel> PROXY;
+
+               public:
+               TextModel(INTEGER id);
+               static const std::string &getType();
+               static const std::string *getSuper();
+               virtual const std::string &getTypeName() const;
+               virtual void internalize(Reader &reader);
+       };
+
+       class StdTextModel : public TextModel {
+               private:
+               static const std::string TYPENAME;
+               static const TypeProxy<StdTextModel> PROXY;
+
+               public:
+               StdTextModel(INTEGER id);
+               static const std::string &getType();
+               static const std::string *getSuper();
+               virtual const std::string &getTypeName() const;
+               virtual void internalize(Reader &reader);
+       };
 }
 
 #endif // _STORE_H_