forked from organicmaps/organicmaps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloader.cpp
36 lines (25 loc) · 932 Bytes
/
loader.cpp
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
#include "descriptions/loader.hpp"
#include "indexer/data_source.hpp"
#include "base/assert.hpp"
#include "defines.hpp"
namespace descriptions
{
std::string Loader::GetWikiDescription(FeatureID const & featureId, std::vector<int8_t> const & langPriority)
{
auto const handle = m_dataSource.GetMwmHandleById(featureId.m_mwmId);
if (!handle.IsAlive())
return {};
auto const & value = *handle.GetValue();
if (!value.m_cont.IsExist(DESCRIPTIONS_FILE_TAG))
return {};
EntryPtr entry;
{
std::lock_guard<std::mutex> lock(m_mutex);
entry = m_deserializers.try_emplace(featureId.m_mwmId, std::make_shared<Entry>()).first->second;
}
ASSERT(entry, ());
auto readerPtr = value.m_cont.GetReader(DESCRIPTIONS_FILE_TAG);
std::lock_guard<std::mutex> lock(entry->m_mutex);
return entry->m_deserializer.Deserialize(*readerPtr.GetPtr(), featureId.m_index, langPriority);
}
} // namespace descriptions