blob: 9af3ef365ad870aaa17b88d01f469d83ad3486ac (
plain)
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
|
#pragma once
#include "ugc/loader.hpp"
#include "ugc/storage.hpp"
#include "ugc/types.hpp"
#include "platform/safe_callback.hpp"
#include "base/worker_thread.hpp"
#include <functional>
class Index;
struct FeatureID;
namespace ugc
{
class Api
{
public:
using UGCCallback = platform::SafeCallback<void(UGC const & ugc, UGCUpdate const & update)>;
using UGCCallbackUnsafe = std::function<void(UGC const & ugc, UGCUpdate const & update)>;
using UGCJsonToSendCallback = std::function<void(std::string && jsonStr)>;
using OnResultCallback = platform::SafeCallback<void(Storage::SettingResult const result)>;
explicit Api(Index const & index);
void GetUGC(FeatureID const & id, UGCCallbackUnsafe const & callback);
void SetUGCUpdate(FeatureID const & id, UGCUpdate const & ugc,
OnResultCallback const & callback = nullptr);
void GetUGCToSend(UGCJsonToSendCallback const & callback);
void SendingCompleted();
void SaveUGCOnDisk();
private:
void GetUGCImpl(FeatureID const & id, UGCCallbackUnsafe const & callback);
Storage::SettingResult SetUGCUpdateImpl(FeatureID const & id, UGCUpdate const & ugc);
void GetUGCToSendImpl(UGCJsonToSendCallback const & callback);
void SendingCompletedImpl();
void SaveUGCOnDiskImpl();
base::WorkerThread m_thread;
Storage m_storage;
Loader m_loader;
};
} // namespace ugc
|