blob: abfb546f0ef40a243e1b7fd6e1fd8ab9025292ab (
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "bucket_create_notifier.h"
#include "i_bucket_create_listener.h"
#include <algorithm>
#include <cassert>
using document::BucketId;
namespace proton::bucketdb {
BucketCreateNotifier::BucketCreateNotifier()
: _listeners()
{
}
BucketCreateNotifier::~BucketCreateNotifier()
{
assert(_listeners.empty());
}
void
BucketCreateNotifier::notifyCreateBucket(const Guard & guard, const BucketId &bucket)
{
for (const auto &listener : _listeners) {
listener->notifyCreateBucket(guard, bucket);
}
}
void
BucketCreateNotifier::addListener(IBucketCreateListener *listener)
{
_listeners.push_back(listener);
}
void
BucketCreateNotifier::removeListener(IBucketCreateListener *listener)
{
auto it = std::find(_listeners.begin(), _listeners.end(), listener);
if (it != _listeners.end()) {
_listeners.erase(it);
}
}
}
|