#pragma once
#include<string>
#include "CivSimuResStruct.h"
/**
*@brief 方案模拟结果缓存
*/
class CivProjSmulResultCache
{
public:
	CivProjSmulResultCache();
	~CivProjSmulResultCache();

	void setProjCode(const std::string& projCode) { mProjCode = projCode; }

	void addNodeHead(const std::string& nodeCode, float head);
	void addNodePressure(const std::string& nodeCode, float pressure);
	void addPipeFlow(const std::string& pipeSn, float flow);
	void addPipeVelcoity(const std::string& pipeSn, float velcocity);
	void addPipeHeadLoss(const std::string& pipeSn, float headLoss);

	void addProjNodeHead(const std::string& nodeCode, float head);
	void addProjNodePressure(const std::string& nodeCode, float pressure);
	void addProjPipeFlow(const std::string& pipeSn, float flow);
	void addProjPipeVelcoity(const std::string& pipeSn, float velcocity);
	void addProjPipeHeadLoss(const std::string& pipeSn, float headLoss);

	void addNodeItem(ProjNodeResultItem& nodeItem);

	void addPipeItem(PorjPipeResultItem& pipeItem);

	bool saveToUri(const std::string& dbUri, const std::string& time, const std::string& projCode);

	// 缓存code到sn的映射
	void getCodeToSnMap(const std::string& uri);

private:
	std::string mProjCode; // 方案编码

	std::map<std::string, ProjNodeResultItem> mNodeCache;
	std::map<std::string, PorjPipeResultItem> mPipeCache;

	std::map<std::string, std::string> mNodeCodeSnMap;
	std::map<std::string, std::string> mLineCodeSnMap;
};
