#ifndef INTERMEDIATE_STORAGE_H #define INTERMEDIATE_STORAGE_H #include #include #include #include "utility/types.h" #include "data/name/NameHierarchy.h" #include "data/parser/ParseLocation.h" #include "data/SqliteStorage.h" #include "data/StorageTypes.h" class IntermediateStorage { public: IntermediateStorage(); ~IntermediateStorage(); Id addEdge(int type, Id sourceId, Id targetId); Id addNode(int type, const NameHierarchy& nameHierarchy, bool defined); Id addFile(const std::string& name, const std::string& filePath, const std::string& modificationTime); Id addFile(const std::string& filePath); void addSourceLocation(Id elementId, const ParseLocation& location, bool isScope); void addComponentAccess(Id nodeId , int type); void addCommentLocation(const ParseLocation& location); void addError(const std::string& message, bool fatal, const ParseLocation& location); void transferToStorage(SqliteStorage& storage); // TODO: remove this and use foreach-callbacks instead void forEachFile(std::function callback) const; void forEachNode(std::function callback) const; void forEachEdge(std::function callback) const; void forEachSourceLocation(std::function callback) const; void forEachComponentAccess(std::function callback) const; void forEachCommentLocation(std::function callback) const; void forEachError(std::function callback) const; private: std::string serialize(const StorageEdge& edge); std::string serialize(const StorageNode& node); std::string serialize(const StorageFile& file); std::unordered_map m_fileNamesToIds; // this is used to prevent duplicates (unique) std::unordered_map> m_fileIdsToData; std::unordered_map m_nodeNamesToIds; // this is used to prevent duplicates (unique) std::map> m_nodeIdsToData; std::unordered_map m_edgeNamesToIds; // this is used to prevent duplicates (unique) std::map> m_edgeIdsToData; std::vector m_sourceLocations; std::vector m_componentAccesses; std::vector m_commentLocations; std::vector m_errors; std::unordered_map m_nodeIdsToMemberEdgeIds; Id m_nextId; }; #endif // INTERMEDIATE_STORAGE_H