Welcome to mirror list, hosted at ThFree Co, Russian Federation.

api.hpp « ugc - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 40198c076ccb018519ca0e2f7f4b44a0c220415c (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
47
48
49
#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 DataSourceBase;
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, size_t numberOfUnsynchronized)>;
  using OnResultCallback = platform::SafeCallback<void(Storage::SettingResult const result)>;
  using NumberOfUnsynchronizedCallback = std::function<void(size_t number)>;

  Api(DataSourceBase 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 SendingCompleted();
  void SaveUGCOnDisk();

  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 SendingCompletedImpl();
  void SaveUGCOnDiskImpl();

  base::WorkerThread m_thread;
  Storage m_storage;
  Loader m_loader;
};
}  // namespace ugc