mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-21 13:53:37 +00:00
committed by
Konstantin Pastbin
parent
c9cbb64f12
commit
76ffc99abd
36
libs/descriptions/loader.cpp
Normal file
36
libs/descriptions/loader.cpp
Normal file
@@ -0,0 +1,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
|
||||
Reference in New Issue
Block a user