NameMapperProxy respects the withAlias flag

This commit is contained in:
Veloman Yunkan 2021-11-21 19:58:20 +04:00
parent 8fffa59974
commit 6199c11505
2 changed files with 5 additions and 3 deletions

View File

@ -59,7 +59,7 @@ class HumanReadableNameMapper : public NameMapper {
class NameMapperProxy : public NameMapper {
typedef std::shared_ptr<NameMapper> NameMapperHandle;
public:
explicit NameMapperProxy(Library& library);
NameMapperProxy(Library& library, bool withAlias);
virtual std::string getNameForId(const std::string& id) const;
virtual std::string getIdForName(const std::string& name) const;
@ -73,6 +73,7 @@ class NameMapperProxy : public NameMapper {
mutable std::mutex mutex;
Library& library;
NameMapperHandle nameMapper;
const bool withAlias;
};
}

View File

@ -63,15 +63,16 @@ std::string HumanReadableNameMapper::getIdForName(const std::string& name) const
// NameMapperProxy
////////////////////////////////////////////////////////////////////////////////
NameMapperProxy::NameMapperProxy(Library& lib)
NameMapperProxy::NameMapperProxy(Library& lib, bool withAlias)
: library(lib)
, withAlias(withAlias)
{
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);
nameMapper.reset(newNameMapper);
}