You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
112 lines
2.2 KiB
C++
112 lines
2.2 KiB
C++
#pragma once
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
#include <optional>
|
|
|
|
struct ActionRecord
|
|
{
|
|
int64_t id;
|
|
std::string uuid;
|
|
std::string classType;
|
|
std::string type; // "redo" "undo" 表示在 redo 还是 undo 列表中
|
|
std::vector<char> data;
|
|
std::string timestamp;
|
|
std::string createAt;
|
|
};
|
|
|
|
struct FileData
|
|
{
|
|
FileData()
|
|
{
|
|
}
|
|
|
|
FileData(int64_t id, std::string filepath, std::vector<char> data, std::string createAt)
|
|
{
|
|
this->id = id;
|
|
this->filepath = filepath;
|
|
this->data = data;
|
|
this->createAt = createAt;
|
|
}
|
|
|
|
int64_t id;
|
|
std::string filepath;
|
|
std::vector<char> data;
|
|
std::string createAt;
|
|
};
|
|
|
|
// 原始图件和操作存储接口
|
|
class IActionStorage
|
|
{
|
|
public:
|
|
virtual ~IActionStorage() = default;
|
|
|
|
/**
|
|
* 插入文件数据
|
|
*
|
|
* \param filePath 文件绝对路径
|
|
* \param fileData 原始文件数据记录
|
|
* \return
|
|
*/
|
|
virtual bool InsertFileData(const std::string& filePath, FileData& fileData) = 0;
|
|
|
|
/**
|
|
* 获取原始文件数据
|
|
*
|
|
* \param filePath 文件绝对路径
|
|
* \return 原始文件数据记录
|
|
*/
|
|
virtual std::optional<FileData> RetrieveFileData(const std::string& filePath) = 0;
|
|
|
|
/**
|
|
* 判断是否存在原始文件数据
|
|
*
|
|
* \param filePath 文件绝对路径
|
|
* \return
|
|
*/
|
|
virtual bool ExistsFileData(const std::string& filePath) = 0;
|
|
|
|
/**
|
|
* 删除文件数据记录,包括删除 Action 记录
|
|
*
|
|
* \param filePath 文件绝对数据
|
|
*/
|
|
virtual void RemoveFileData(const std::string & filePath) = 0;
|
|
|
|
/**
|
|
* 添加文件操作记录
|
|
*
|
|
* \param filePath 文件绝对路径
|
|
* \param record 操作记录
|
|
* \return
|
|
*/
|
|
virtual bool AddActionRecord(const std::string& filePath, const ActionRecord& record) = 0;
|
|
|
|
/**
|
|
* 判断是否存在操作记录
|
|
*
|
|
* \param filePath 文件绝对路径
|
|
* \param uuid 操作 uuid
|
|
* \return
|
|
*/
|
|
virtual bool ExistsActionRecord(const std::string& filePath, const std::string& uuid) = 0;
|
|
|
|
/**
|
|
* 统计图件的 actioin 数量
|
|
*
|
|
* \param filePath 文件绝对路径
|
|
* \return
|
|
*/
|
|
virtual int ActionRecordCount(const std::string& filePath) = 0;
|
|
|
|
/**
|
|
* 获取所有操作记录
|
|
*
|
|
* \param filePath 文件绝对路径
|
|
* \return 返回所有的操作记录
|
|
*/
|
|
virtual std::vector<ActionRecord> RetrieveAllActionRecords(const std::string& filePath) = 0;
|
|
|
|
virtual void ClearBackup(const std::string& path) = 0;
|
|
};
|