]> git.localhorst.tv Git - l2e.git/blobdiff - src/loader/TypeDescription.h
initialize objects after loading
[l2e.git] / src / loader / TypeDescription.h
index ab8c1bf1ba13328b399d721c46fb26cb2053af65..078002fed916c2a96481be4b050c205edae60331 100644 (file)
@@ -1,10 +1,3 @@
-/*
- * TypeDescription.h
- *
- *  Created on: Sep 4, 2012
- *      Author: holy
- */
-
 #ifndef LOADER_TYPEDESCRIPTION_H_
 #define LOADER_TYPEDESCRIPTION_H_
 
@@ -47,9 +40,11 @@ public:
        bool HasField(const std::string &name) const;
        const FieldDescription &GetField(const std::string &name) const;
        void Construct(void *) const;
+       void Init(void *) const;
        void Load(void *) const;
 
        void SetConstructor(void (*ctor)(void *)) { constructor = ctor; }
+       void SetInitializer(void (*init)(void *)) { initializer = init; }
        void SetLoader(void (*ld)(void *)) { loader = ld; }
        void AddSupertype(int id, std::ptrdiff_t offset);
        bool IsSubtypeOf(int id) const;
@@ -70,17 +65,28 @@ public:
        FieldIterator FieldsBegin() const { return fields.begin(); }
        FieldIterator FieldsEnd() const { return fields.end(); }
 
-       static TypeDescription &CreateOrGet(const std::string &name);
+       static TypeDescription &Create(int id, const std::string &name);
        static int GetTypeId(const std::string &);
        static const TypeDescription &Get(int id);
 
+       static int GetMaxSize();
+
        static void WriteSourceWiki(std::ostream &);
 
 private:
-       TypeDescription(int id, const std::string &name) : constructor(0), loader(0), description(0), name(name), id(id), size(0) { }
+       TypeDescription(int id, const std::string &name)
+       : constructor(0)
+       , initializer(0)
+       , loader(0)
+       , description(0)
+       , name(name)
+       , id(id)
+       , size(0)
+       { }
 
 private:
        void (*constructor)(void *);
+       void (*initializer)(void *);
        void (*loader)(void *);
        const char *description;
        std::string name;
@@ -89,10 +95,11 @@ private:
        int id;
        int size;
 
-       static std::vector<TypeDescription> typeDescriptions;
+       static std::map<int, TypeDescription> typeDescriptions;
+       static std::map<std::string, int> typeName2ID;
 
 };
 
 }
 
-#endif /* LOADER_TYPEDESCRIPTION_H_ */
+#endif