aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src/vespa/searchcore/proton/reference/gid_to_lid_change_registrator.cpp
blob: 75d60d1950aee795f192bd9ab604131205ddc7a0 (plain) (blame)
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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "gid_to_lid_change_registrator.h"
#include "i_gid_to_lid_change_listener.h"
#include <cassert>

namespace proton {

GidToLidChangeRegistrator::GidToLidChangeRegistrator(std::shared_ptr<IGidToLidChangeHandler> handler,
                                                     const vespalib::string &docTypeName)
    : _handler(std::move(handler)),
      _docTypeName(docTypeName),
      _keepNames()
{
}

GidToLidChangeRegistrator::~GidToLidChangeRegistrator()
{
    _handler->removeListeners(_docTypeName, _keepNames);
}

void
GidToLidChangeRegistrator::addListener(std::unique_ptr<IGidToLidChangeListener> listener)
{
    assert(listener->getDocTypeName() == _docTypeName);
    _keepNames.insert(listener->getName());
    _handler->addListener(std::move(listener));
}

} // namespace proton