[traffic] Initialize TrafficManager with a DataSource

Signed-off-by: mvglasow <michael -at- vonglasow.com>
This commit is contained in:
mvglasow
2025-05-10 18:29:58 +03:00
parent 73d61ff655
commit a9ceec3995
3 changed files with 10 additions and 4 deletions

View File

@@ -295,7 +295,8 @@ Framework::Framework(FrameworkParams const & params, bool loadMaps)
[this]() -> StringsBundle const & { return m_stringsBundle; },
[this]() -> power_management::PowerManager const & { return m_powerManager; }),
static_cast<RoutingManager::Delegate &>(*this))
, m_trafficManager([this](string const & id) -> string { return m_storage.GetParentIdFor(id); },
, m_trafficManager(m_featuresFetcher.GetDataSource(),
[this](string const & id) -> string { return m_storage.GetParentIdFor(id); },
bind(&Framework::GetMwmsByRect, this, _1, false /* rough */),
kMaxTrafficCacheSizeBytes, m_routingManager.RoutingSession())
, m_lastReportedCountry(kInvalidCountryId)

View File

@@ -51,10 +51,12 @@ TrafficManager::CacheEntry::CacheEntry(time_point<steady_clock> const & requestT
, m_lastAvailability(traffic::TrafficInfo::Availability::Unknown)
{}
TrafficManager::TrafficManager(const CountryParentNameGetterFn &countryParentNameGetter,
TrafficManager::TrafficManager(DataSource & dataSource,
const CountryParentNameGetterFn &countryParentNameGetter,
GetMwmsByRectFn const & getMwmsByRectFn, size_t maxCacheSizeBytes,
traffic::TrafficObserver & observer)
: m_countryParentNameGetterFn(countryParentNameGetter)
: m_dataSource(dataSource)
, m_countryParentNameGetterFn(countryParentNameGetter)
, m_getMwmsByRectFn(getMwmsByRectFn)
, m_observer(observer)
, m_currentDataVersion(0)

View File

@@ -7,6 +7,7 @@
#include "drape/pointers.hpp"
#include "indexer/data_source.hpp"
#include "indexer/mwm_set.hpp"
#include "openlr/openlr_decoder.hpp"
@@ -75,7 +76,8 @@ public:
using TrafficStateChangedFn = std::function<void(TrafficState)>;
using GetMwmsByRectFn = std::function<std::vector<MwmSet::MwmId>(m2::RectD const &)>;
TrafficManager(CountryParentNameGetterFn const & countryParentNameGetter,
TrafficManager(DataSource & dataSource,
CountryParentNameGetterFn const & countryParentNameGetter,
GetMwmsByRectFn const & getMwmsByRectFn, size_t maxCacheSizeBytes,
traffic::TrafficObserver & observer);
~TrafficManager();
@@ -402,6 +404,7 @@ private:
std::for_each(activeMwms.begin(), activeMwms.end(), std::forward<F>(f));
}
DataSource & m_dataSource;
CountryParentNameGetterFn m_countryParentNameGetterFn;
GetMwmsByRectFn m_getMwmsByRectFn;
traffic::TrafficObserver & m_observer;