aboutsummaryrefslogtreecommitdiffstats
path: root/slobrok/src/vespa/slobrok/server/map_source.h
blob: 2a0ebf50957c013dda1037d9c638c43d0212d319 (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include "map_listener.h"
#include <memory>

namespace slobrok {

struct MapSource;

class MapSubscription {
private:
    MapSource &_source;
    MapListener &_listener;
    struct Tag {};
public:
    MapSubscription(MapSource &source, MapListener &listener, Tag);

    MapSubscription(const MapSubscription &) = delete;
    MapSubscription(MapSubscription &&) = delete;
    MapSubscription& operator=(const MapSubscription &) = delete;
    MapSubscription& operator=(MapSubscription &&) = delete;

    ~MapSubscription();

    static std::unique_ptr<MapSubscription> subscribe(MapSource &source, MapListener &listener);
};

/**
 * Interface for sources of incremental map updates.
 **/
struct MapSource {
    virtual ~MapSource();
private:
    friend class MapSubscription;
    virtual void registerListener(MapListener &listener) = 0;
    virtual void unregisterListener(MapListener &listener) = 0;
};

} // namespace slobrok