]> git.localhorst.tv Git - l2e.git/blobdiff - src/loader/TypeDescription.h
removed useless comments
[l2e.git] / src / loader / TypeDescription.h
index edd0177c418fe3f344834165d7638d278749276b..262f76b9e9d79ff9bad507e31f5643ead1f4a606 100644 (file)
@@ -1,13 +1,7 @@
-/*
- * TypeDescription.h
- *
- *  Created on: Sep 4, 2012
- *      Author: holy
- */
-
 #ifndef LOADER_TYPEDESCRIPTION_H_
 #define LOADER_TYPEDESCRIPTION_H_
 
+#include <iosfwd>
 #include <map>
 #include <memory>
 #include <string>
@@ -18,15 +12,21 @@ namespace loader {
 class FieldDescription {
 
 public:
-       FieldDescription(std::ptrdiff_t offset, int type, bool reference = true, bool aggregate = false)
-       : offset(offset), type(type), reference(reference), aggregate(aggregate) { }
+       FieldDescription(std::ptrdiff_t offset, int type)
+       : description(0), offset(offset), type(type), reference(false), aggregate(false) { }
 
        std::ptrdiff_t Offset() const { return offset; };
        int TypeId() const { return type; }
        bool IsReferenced() const { return reference; }
        bool IsAggregate() const { return aggregate; }
+       const char *Description() const { return description; }
+
+       FieldDescription &SetReferenced() { reference = true; return *this; }
+       FieldDescription &SetAggregate() { aggregate = true; return *this; }
+       FieldDescription &SetDescription(const char *d) { description = d; return *this; }
 
 private:
+       const char *description;
        std::ptrdiff_t offset;
        int type;
        bool reference;
@@ -56,30 +56,37 @@ public:
        void SetSize(int s) { size = s; }
        int Size() const { return size; }
 
+       void SetDescription(const char *d) { description = d; }
+       const char *Description() const { return description; }
+
        typedef std::map<std::string, FieldDescription>::const_iterator FieldIterator;
        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 void WriteSourceWiki(std::ostream &);
+
 private:
-       TypeDescription(int id, const std::string &name) : constructor(0), loader(0), name(name), id(id), size(0) { }
+       TypeDescription(int id, const std::string &name) : constructor(0), loader(0), description(0), name(name), id(id), size(0) { }
 
 private:
        void (*constructor)(void *);
        void (*loader)(void *);
+       const char *description;
        std::string name;
        std::map<std::string, FieldDescription> fields;
        std::map<int, std::ptrdiff_t> supertypes;
        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