blob: 8ace4ec38e56e2ac02f945360acf546f81942098 (
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
47
48
49
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include "service_mapping.h"
#include "map_diff.h"
#include "map_source.h"
#include <vespa/vespalib/util/gencnt.h>
#include <map>
#include <set>
namespace slobrok {
/**
* @class ServiceMapMirror
* @brief Holds a name->spec map which can be incrementally updated
**/
class ServiceMapMirror : public MapSource
{
public:
using Generation = vespalib::GenCnt;
ServiceMapMirror();
~ServiceMapMirror();
/** update according to diff */
void apply(const MapDiff &diff);
/** remove all mappings */
void clear();
const Generation ¤tGeneration() const { return _currGen; }
ServiceMappingList allMappings() const;
private:
void registerListener(MapListener &listener) override;
void unregisterListener(MapListener &listener) override;
using Map = std::map<vespalib::string, vespalib::string>;
Map _map;
Generation _currGen;
std::set<MapListener *> _listeners;
};
//-----------------------------------------------------------------------------
} // namespace slobrok
|