|
DAWorkbench 0.0.1
DAWorkbench API
|
持久化的基类 更多...
#include <DAAbstractArchive.h>
类 | |
| class | PrivateData |
Public 类型 | |
| enum | ResultCode { SaveSuccess , SaveFailed , LoadSuccess , LoadFailed } |
| 结果号 | |
Public 槽 | |
| virtual void | saveAll (const QString &filePath)=0 |
| virtual void | loadAll (const QString &filePath)=0 |
信号 | |
| void | taskProgress (std::shared_ptr< DA::DAAbstractArchiveTask > task, int mode) |
| 当前进度信号 对于读取操作,这个函数会携带读取的结果 | |
| void | taskFinished (int resultCode) |
| 任务完成 | |
Public 成员函数 | |
| DAAbstractArchive (QObject *par=nullptr) | |
| virtual bool | setBaseFilePath (const QString &path) |
| 设置基础路径 | |
| QString | getBaseFilePath () const |
| virtual bool | write (const QString &relatePath, const QByteArray &byte)=0 |
| 写数据 | |
| virtual QByteArray | read (const QString &relatePath)=0 |
| 读取数据 | |
| virtual bool | remove (const QString &relatePath)=0 |
| 删除文件 | |
| void | appendTask (const std::shared_ptr< DAAbstractArchiveTask > &task) |
| int | getTaskCount () const |
| bool | isTaskQueueEmpty () const |
静态 Public 成员函数 | |
| static QString | toTemporaryPath (const QString &path) |
| 转换为临时路径 | |
| static bool | replaceFile (const QString &file, const QString &beReplaceFile) |
| 替换文件 | |
Protected 成员函数 | |
| std::shared_ptr< DAAbstractArchiveTask > | takeTask () |
| 从顶部提取一个任务 | |
持久化的基类
这个类设计中包含了一个任务队列,任务队列可以实现多线程执行批量写和读
|
pure virtual |
读取数据
| relatePath | 相对位置此位置相对BaseFilePath相对位置此位置相对BaseFilePath |
在 DA::DAZipArchive 内被实现.
|
pure virtual |
|
static |
替换文件
| file | 要被替换的文件路径,此函数执行完成后,这个文件将消失 |
| beReplaceFile | 用于替换的文件路径,这个路径文件可以不存在 |
将 beReplaceFile 重命名为 file,如果beReplaceFile已经存在,QFile::copy(file, beReplaceFile)这个函数会返回false, 因此,beReplaceFile如果存在,先要删除beReplaceFile
|
virtual |
设置基础路径
对于文件来说,基础路径就是要保存的目录,所有文件的写入都基于此目录,对应zip来说,这个路径就是zip文件路径
| path | 基础路径 |
被 DA::DAZipArchive 重载.
|
protected |
从顶部提取一个任务
|
signal |
当前进度信号 对于读取操作,这个函数会携带读取的结果
| task | 任务 |
| mode | 模式,具体为DAAbstractArchiveTask::Mode |
|
static |
转换为临时路径
|
pure virtual |