]> git.tdb.fi Git - libs/game.git/blobdiff - tools/setupgen/setupgen.h
Refactor the setup generator to store types in modules
[libs/game.git] / tools / setupgen / setupgen.h
index 98d1ab80472332d08b409cde37a0b644ebfe1599..e4c1b333b2df110130c7ec203d58c3fcbba0839f 100644 (file)
@@ -1,12 +1,14 @@
 #ifndef SETUPGEN_H_
 #define SETUPGEN_H_
 
+#include <list>
 #include <map>
 #include <memory>
 #include <set>
 #include <string>
 #include <msp/core/application.h>
 #include <msp/datafile/objectloader.h>
+#include <msp/fs/path.h>
 #include "enum.h"
 #include "struct.h"
 #include "type.h"
 class SetupGen: public Msp::RegisteredApplication<SetupGen>
 {
 private:
+       struct Module
+       {
+               std::string name_space;
+               std::vector<std::unique_ptr<Enum>> enums;
+               std::vector<std::unique_ptr<Struct>> structs;
+       };
+
        class Loader: public Msp::DataFile::ObjectLoader<SetupGen>
        {
+       private:
+               Module &mod;
+
        public:
-               Loader(SetupGen &);
+               Loader(SetupGen &, Module &);
 
        private:
                void init_actions() override;
@@ -29,7 +41,7 @@ private:
 
        std::string in_fn;
        std::string out_fn;
-       std::string name_space;
+       std::list<Module> modules;
        std::map<std::string, Type> types;
        std::vector<std::unique_ptr<Enum>> enums;
        std::vector<std::unique_ptr<Struct>> structs;
@@ -46,10 +58,10 @@ public:
        const Type &get_type(const std::string &) const;
 
 private:
-       void load();
-       void collect_headers();
-       void generate_header(Msp::IO::Base &) const;
-       void generate_code(Msp::IO::Base &) const;
+       void load(const Msp::FS::Path &);
+       void collect_headers(const Module &);
+       void generate_header(const Module &, Msp::IO::Base &) const;
+       void generate_code(const Module &, Msp::IO::Base &) const;
 };
 
 #endif