#ifndef INTERMEDIATE_STORAGE_H #define INTERMEDIATE_STORAGE_H #include #include #include #include "data/StorageTypes.h" #include "data/Storage.h" class IntermediateStorage: public Storage { public: IntermediateStorage(); virtual ~IntermediateStorage(); virtual Id addFile(const std::string& name, const std::string& filePath, const std::string& modificationTime); virtual Id addNode(int type, const std::string& serializedName, int definitionType); virtual Id addEdge(int type, Id sourceId, Id targetId); virtual Id addLocalSymbol(const std::string& name); virtual void addSourceLocation(Id elementId, Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol, int type); virtual void addComponentAccess(Id edgeId , int type); virtual void addCommentLocation(Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol); virtual void addError(const std::string& message, bool fatal, const std::string& filePath, uint startLine, uint startCol); virtual void forEachFile(std::function callback) const; virtual void forEachNode(std::function callback) const; virtual void forEachEdge(std::function callback) const; virtual void forEachLocalSymbol(std::function callback) const; virtual void forEachSourceLocation(std::function callback) const; virtual void forEachComponentAccess(std::function callback) const; virtual void forEachCommentLocation(std::function callback) const; virtual 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::string serialize(const StorageLocalSymbol& localSymbol); 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::unordered_map m_localSymbolNamesToIds; // this is used to prevent duplicates (unique) std::map> m_localSymbolIdsToData; 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