mirror of https://github.com/kiwix/libkiwix.git
NameMapperProxy respects the withAlias flag
This commit is contained in:
parent
8fffa59974
commit
6199c11505
|
@ -59,7 +59,7 @@ class HumanReadableNameMapper : public NameMapper {
|
||||||
class NameMapperProxy : public NameMapper {
|
class NameMapperProxy : public NameMapper {
|
||||||
typedef std::shared_ptr<NameMapper> NameMapperHandle;
|
typedef std::shared_ptr<NameMapper> NameMapperHandle;
|
||||||
public:
|
public:
|
||||||
explicit NameMapperProxy(Library& library);
|
NameMapperProxy(Library& library, bool withAlias);
|
||||||
|
|
||||||
virtual std::string getNameForId(const std::string& id) const;
|
virtual std::string getNameForId(const std::string& id) const;
|
||||||
virtual std::string getIdForName(const std::string& name) const;
|
virtual std::string getIdForName(const std::string& name) const;
|
||||||
|
@ -73,6 +73,7 @@ class NameMapperProxy : public NameMapper {
|
||||||
mutable std::mutex mutex;
|
mutable std::mutex mutex;
|
||||||
Library& library;
|
Library& library;
|
||||||
NameMapperHandle nameMapper;
|
NameMapperHandle nameMapper;
|
||||||
|
const bool withAlias;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,15 +63,16 @@ std::string HumanReadableNameMapper::getIdForName(const std::string& name) const
|
||||||
// NameMapperProxy
|
// NameMapperProxy
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
NameMapperProxy::NameMapperProxy(Library& lib)
|
NameMapperProxy::NameMapperProxy(Library& lib, bool withAlias)
|
||||||
: library(lib)
|
: library(lib)
|
||||||
|
, withAlias(withAlias)
|
||||||
{
|
{
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NameMapperProxy::update()
|
void NameMapperProxy::update()
|
||||||
{
|
{
|
||||||
const auto newNameMapper = new HumanReadableNameMapper(library, false);
|
const auto newNameMapper = new HumanReadableNameMapper(library, withAlias);
|
||||||
std::lock_guard<std::mutex> lock(mutex);
|
std::lock_guard<std::mutex> lock(mutex);
|
||||||
nameMapper.reset(newNameMapper);
|
nameMapper.reset(newNameMapper);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue