#ifndef FILE_REGISTER_H #define FILE_REGISTER_H #include #include #include #include #include #include #include #include "utility/file/FilePath.h" class FileManager; struct FileInfo; class FileRegister { public: explicit FileRegister(const FileManager* fileManager); void setFilePaths(const std::vector& filePaths); bool hasFilePath(const FilePath& filePath) const; const FileInfo getFileInfo(const FilePath& filePath) const; std::vector getUnparsedSourceFilePaths() const; bool hasIncludeFile(const FilePath& filePath) const; bool fileIsParsed(const FilePath& filePath) const; bool includeFileIsParsed(const FilePath& filePath) const; bool sourceFileIsParsed(const FilePath& filePath) const; FilePath consumeSourceFile(); void markIncludeFileParsing(const FilePath& filePath); void markThreadFilesParsed(); size_t getSourceFilesCount() const; size_t getParsedSourceFilesCount() const; private: enum ParseState { STATE_UNPARSED, STATE_PARSING, STATE_PARSED }; const FileManager* m_fileManager; mutable std::unordered_map m_projectFiles; mutable std::mutex m_projectFilesMutex; mutable std::unordered_map m_projectFileInfos; mutable std::mutex m_projectFileInfosMutex; std::map m_sourceFilePaths; std::map m_includeFilePaths; std::map> m_threadParsingFiles; mutable std::mutex m_sourceFileMutex; mutable std::mutex m_includeFileMutex; mutable std::mutex m_threadFileMutex; mutable std::mutex m_fileManagerMutex; }; #endif // FILE_REGISTER_H