aboutsummaryrefslogtreecommitdiffstats
path: root/config/src/vespa/config/common/configstate.h
blob: 4c61e87bb1d29311201577ec7cb05e1b24bd716b (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include "misc.h"

namespace config {

/**
 * A config state represents the current state of a config instance
 */
struct ConfigState
{
public:
    ConfigState()
        : xxhash64(""),
          generation(0),
          applyOnRestart(false)
    { }
    ConfigState(const vespalib::string & xxhash, int64_t gen, bool _applyOnRestart)
        : xxhash64(xxhash),
          generation(gen),
          applyOnRestart(_applyOnRestart)
    { }

    vespalib::string xxhash64;
    int64_t generation;
    bool applyOnRestart;

    bool isNewerGenerationThan(const ConfigState & other) const {
        return isGenerationNewer(generation, other.generation);
    }

    bool hasDifferentPayloadFrom(const ConfigState & other) const {
        return (xxhash64.compare(other.xxhash64) != 0);
    }
};

} // namespace config