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
|
#pragma once
#include "ugc/loader.hpp"
#include "ugc/storage.hpp"
#include "ugc/types.hpp"
#include "platform/safe_callback.hpp"
#include "geometry/point2d.hpp"
#include "base/thread_pool_delayed.hpp"
#include <functional>
class DataSource;
struct FeatureID;
namespace feature
{
class TypesHolder;
}
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, size_t numberOfUnsynchronized)>;
using OnResultCallback = platform::SafeCallback<void(Storage::SettingResult const result)>;
using NumberOfUnsynchronizedCallback = std::function<void(size_t number)>;
using HasUGCForPlaceCallback = platform::SafeCallback<void(bool result)>;
Api(DataSource const & dataSource, NumberOfUnsynchronizedCallback const & callback);
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 HasUGCForPlace(uint32_t bestType, m2::PointD const & point,
HasUGCForPlaceCallback const & callback);
void SendingCompleted();
Loader & GetLoader();
private:
void GetUGCImpl(FeatureID const & id, UGCCallbackUnsafe const & callback);
Storage::SettingResult SetUGCUpdateImpl(FeatureID const & id, UGCUpdate const & ugc);
void GetUGCToSendImpl(UGCJsonToSendCallback const & callback);
void HasUGCForPlaceImpl(uint32_t bestType, m2::PointD const & point,
HasUGCForPlaceCallback const & callback) const;
void SendingCompletedImpl();
base::thread_pool::delayed::ThreadPool m_thread;
Storage m_storage;
Loader m_loader;
};
} // namespace ugc
|