diff options
author | Arsentiy Milchakov <milcars@mapswithme.com> | 2018-11-27 17:13:34 +0300 |
---|---|---|
committer | Olesia Bolovintseva <o.bolovintseva@mapswithme.com> | 2018-12-04 16:12:06 +0300 |
commit | bda368e95f07d50125496d7f94330c40aad8ad6c (patch) | |
tree | baa34f5465db22d5c96abd2736f261838f068b57 /map/framework_light.cpp | |
parent | 899ee1c5ee889774c6ca0ff10d70c8c02c94bebd (diff) |
[lightweight] "Get" methods are renamed
Diffstat (limited to 'map/framework_light.cpp')
-rw-r--r-- | map/framework_light.cpp | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/map/framework_light.cpp b/map/framework_light.cpp new file mode 100644 index 0000000000..d54dd3c6bf --- /dev/null +++ b/map/framework_light.cpp @@ -0,0 +1,118 @@ +#include "map/framework_light.hpp" + +namespace lightweight +{ +Framework::Framework(RequestTypeMask request) : m_request(request) +{ + CHECK_NOT_EQUAL(request, REQUEST_TYPE_EMPTY, ("Mask is empty")); + + if (request & REQUEST_TYPE_NUMBER_OF_UNSENT_UGC) + { + m_numberOfUnsentUGC = impl::GetNumberOfUnsentUGC(); + request ^= REQUEST_TYPE_NUMBER_OF_UNSENT_UGC; + } + + if (request & REQUEST_TYPE_USER_AUTH_STATUS) + { + m_userAuthStatus = impl::IsUserAuthenticated(); + request ^= REQUEST_TYPE_USER_AUTH_STATUS; + } + + if (request & REQUEST_TYPE_NUMBER_OF_UNSENT_EDITS) + { + // TODO: Hasn't implemented yet. + request ^= REQUEST_TYPE_NUMBER_OF_UNSENT_EDITS; + } + + if (request & REQUEST_TYPE_BOOKMARKS_CLOUD_ENABLED) + { + m_bookmarksCloudEnabled = impl::IsBookmarksCloudEnabled(); + request ^= REQUEST_TYPE_BOOKMARKS_CLOUD_ENABLED; + } + + if (request & REQUEST_TYPE_LOCATION) + { + m_countryInfoReader = std::make_unique<CountryInfoReader>(); + request ^= REQUEST_TYPE_LOCATION; + } + + if (request & REQUEST_TYPE_LOCAL_ADS_FEATURES) + { + m_localAdsFeaturesReader = std::make_unique<LocalAdsFeaturesReader>(); + request ^= REQUEST_TYPE_LOCAL_ADS_FEATURES; + } + + if (request & REQUEST_TYPE_LOCAL_ADS_STATISTICS) + { + m_localAdsStatistics = std::make_unique<Statistics>(); + request ^= REQUEST_TYPE_LOCAL_ADS_STATISTICS; + } + + if (request & REQUEST_TYPE_NOTIFICATION) + { + m_notificationManager = std::make_unique<lightweight::NotificationManager>(); + request ^= REQUEST_TYPE_NOTIFICATION; + } + + CHECK_EQUAL(request, REQUEST_TYPE_EMPTY, ("Incorrect mask type:", request)); +} + +bool Framework::IsUserAuthenticated() const +{ + ASSERT(m_request & REQUEST_TYPE_USER_AUTH_STATUS, (m_request)); + return m_userAuthStatus; +} + +size_t Framework::GetNumberOfUnsentUGC() const +{ + ASSERT(m_request & REQUEST_TYPE_NUMBER_OF_UNSENT_UGC, (m_request)); + return m_numberOfUnsentUGC; +} + + +size_t Framework::GetNumberOfUnsentEdits() const +{ + ASSERT(m_request & REQUEST_TYPE_NUMBER_OF_UNSENT_EDITS, (m_request)); + return m_numberOfUnsentEdits; +} + +bool Framework::IsBookmarksCloudEnabled() const +{ + ASSERT(m_request & REQUEST_TYPE_BOOKMARKS_CLOUD_ENABLED, (m_request)); + return m_bookmarksCloudEnabled; +} + +CountryInfoReader::Info Framework::GetLocation(m2::PointD const & pt) const +{ + ASSERT(m_request & REQUEST_TYPE_LOCATION, (m_request)); + + CHECK(m_countryInfoReader, ()); + + return m_countryInfoReader->GetMwmInfo(pt); +} + +std::vector<CampaignFeature> Framework::GetLocalAdsFeatures(double lat, double lon, + double radiusInMeters, uint32_t maxCount) +{ + ASSERT(m_request & REQUEST_TYPE_LOCAL_ADS_FEATURES, (m_request)); + + CHECK(m_localAdsFeaturesReader, ()); + + return m_localAdsFeaturesReader->GetCampaignFeatures(lat, lon, radiusInMeters, maxCount); +} + +Statistics * Framework::GetLocalAdsStatistics() +{ + ASSERT(m_request & REQUEST_TYPE_LOCAL_ADS_STATISTICS, (m_request)); + + CHECK(m_localAdsStatistics, ()); + + return m_localAdsStatistics.get(); +} + +boost::optional<notifications::NotificationCandidate> Framework::GetNotification() const +{ + return m_notificationManager->GetNotification(); +} +} // namespace lightweight + |