-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatamanager.h
69 lines (56 loc) · 1.65 KB
/
datamanager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#ifndef BLOCK_SAVER_H_
#define BLOCK_SAVER_H_
#include <string>
#include <unordered_map>
#include <vector>
#include <memory>
class DataHandler;
class DataOperationManagerBase;
class DataManager
{
public:
using AddAndRemoveDataListPair = std::pair<std::vector<std::string>, std::vector<std::string>>;
DataManager(DataOperationManagerBase* operationManager);
// store data persistently and keep info in the cache
bool AddData(std::string id, std::vector<char>&& data);
// remove data from persistent storage and cache
void RemoveData(const std::string& id);
// list files from drive
// return new detected filenames
AddAndRemoveDataListPair DiffDataHandles(bool updateCache = true);
void SetName(std::string name)
{
m_Name = std::move(name);
}
const std::string& GetName() const
{
return m_Name;
}
const std::unordered_map<std::string, std::shared_ptr<DataHandler>>& GetDataHandlers() const
{
return m_DataHandlers;
}
std::shared_ptr<DataHandler> GetDataHandler(const std::string& id) const
{
auto iter = m_DataHandlers.find(id);
if(iter != m_DataHandlers.end())
{
return iter->second;
}
return std::shared_ptr<DataHandler>();
}
void EnableSyncDelete(bool b)
{
m_syncDelete = b;
}
bool IsSyncDelete() const
{
return m_syncDelete;
}
private:
std::unique_ptr<DataOperationManagerBase> m_FileOperationManager;
std::unordered_map<std::string, std::shared_ptr<DataHandler>> m_DataHandlers;
std::string m_Name;
bool m_syncDelete;
};
#endif // BLOCK_SAVER_H_