1
2
3
4
5
6 #ifndef SNGCM_AST_SYSTEM_FILE_INDEX_INCLUDED
7 #define SNGCM_AST_SYSTEM_FILE_INDEX_INCLUDED
8 #include <soulng/util/Error.hpp>
9 #include <map>
10 #include <memory>
11 #include <stdint.h>
12
13 namespace sngcm { namespace ast {
14
15 const uint32_t firstSystemFileIndex = 1000000;
16
17 class SystemFileIndex
18 {
19 public:
20 static void Init();
21 static SystemFileIndex& Instance() { Assert(instance, "system file index not initialized"); return *instance; }
22 uint32_t RegisterSystemSourceFile(const std::string& systemSourceFilePath);
23 std::string GetSystemSourceFilePath(uint32_t systemFileIndex) const;
24 void Write(const std::string& systemFileIndexFilePath);
25 void Read(const std::string& systemFileIndexFilePath);
26 private:
27 static std::unique_ptr<SystemFileIndex> instance;
28 uint32_t nextSystemFileIndex;
29 std::string cmajorRootDir;
30 std::map<uint32_t, std::string> systemFileMap;
31 SystemFileIndex();
32 };
33
34 void SystemFileIndexInit();
35
36 } }
37
38 #endif