blob: ddba99e9d8597944e92341f46be25dd41b3e0978 (
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
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include <memory>
namespace config {
class ConfigSubscription;
/**
* A ConfigHandle is a subscription handle that is capable of looking up config
* objects of a generic type.
*/
template <typename ConfigType>
class ConfigHandle
{
public:
typedef std::unique_ptr<ConfigHandle <ConfigType> > UP;
explicit ConfigHandle(std::shared_ptr<ConfigSubscription> subscription);
~ConfigHandle();
/**
* Return the currently available config known to the ConfigHandle. Throws
* a ConfigRuntimeException if the ConfigSubscriber has not yet been polled
* for config, and InvalidConfigException, if there are errors with the
* config payload.
*
* @return current config.
* @throws InvalidConfigException if unable instantiate the given type or
* parse config.
*/
std::unique_ptr<ConfigType> getConfig() const;
/**
* Returns whether or not this handles config has changed since the last
* call to ConfigSubscriber.nextConfig() was made.
*
* @return true if changed, false if not.
*/
bool isChanged() const;
private:
std::shared_ptr<ConfigSubscription> _subscription;
};
} // namespace config
|