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

framework_light.hpp « map - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ec9a4fa3f69d2dbb0f1dc54cc3c822f1bb03dd74 (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#pragma once

#include "map/bookmark_manager.hpp"
#include "map/local_ads_manager.hpp"
#include "map/notifications/notification_manager.hpp"
#include "map/user.hpp"

#include "ugc/storage.hpp"

#include "storage/country_info_reader_light.hpp"

#include "geometry/point2d.hpp"

#include "base/assert.hpp"

#include <cstdint>
#include <memory>
#include <string>
#include <vector>

#include <boost/optional.hpp>

namespace lightweight
{
struct LightFrameworkTest;

enum RequestType
{
  REQUEST_TYPE_EMPTY = 0u,
  REQUEST_TYPE_NUMBER_OF_UNSENT_UGC = 1u << 0,
  REQUEST_TYPE_USER_AUTH_STATUS = 1u << 1,
  REQUEST_TYPE_NUMBER_OF_UNSENT_EDITS = 1u << 2,
  REQUEST_TYPE_BOOKMARKS_CLOUD_ENABLED = 1u << 3,
  // Be careful to use this flag. Loading with this flag can produce a hard pressure on the disk
  // and takes much time.  For example it takes ~50ms on LG Nexus 5, ~100ms on Samsung A5, ~200ms on
  // Fly IQ4403.
  REQUEST_TYPE_LOCATION = 1u << 4,
  REQUEST_TYPE_LOCAL_ADS_FEATURES = 1u << 5,
  REQUEST_TYPE_LOCAL_ADS_STATISTICS = 1u << 6,
  REQUEST_TYPE_NOTIFICATION = 1u << 7,
};

using RequestTypeMask = unsigned;

// A class which allows you to acquire data in a synchronous way.
// The common use case is to create an instance of Framework
// with specified mask, acquire data according to the mask and destroy the instance.

class Framework
{
public:
  class Delegate
  {
  public:
    virtual ~Delegate() = default;
    virtual notifications::NotificationManager & GetNotificationManager() = 0;
  };
  friend struct LightFrameworkTest;

  explicit Framework(RequestTypeMask request);

  void SetDelegate(std::unique_ptr<Delegate> delegate);

  bool IsUserAuthenticated() const;
  size_t GetNumberOfUnsentUGC() const;
  size_t GetNumberOfUnsentEdits() const;
  bool IsBookmarksCloudEnabled() const;
  CountryInfoReader::Info GetLocation(m2::PointD const & pt) const;
  std::vector<CampaignFeature> GetLocalAdsFeatures(double lat, double lon, double radiusInMeters,
                                                   uint32_t maxCount);
  Statistics * GetLocalAdsStatistics();
  notifications::Notification GetNotification() const;

private:
  RequestTypeMask m_request;
  std::unique_ptr<Delegate> m_delegate;
  bool m_userAuthStatus = false;
  size_t m_numberOfUnsentUGC = 0;
  size_t m_numberOfUnsentEdits = 0;
  bool m_bookmarksCloudEnabled = false;
  std::unique_ptr<CountryInfoReader> m_countryInfoReader;
  std::unique_ptr<LocalAdsFeaturesReader> m_localAdsFeaturesReader;
  std::unique_ptr<Statistics> m_localAdsStatistics;
};

std::string FeatureParamsToString(int64_t mwmVersion, std::string const & countryId, uint32_t featureIndex);

bool FeatureParamsFromString(std::string const & str, int64_t & mwmVersion, std::string & countryId,
                             uint32_t & featureIndex);
}  // namespace lightweight