aboutsummaryrefslogtreecommitdiffstats
path: root/documentapi/src/vespa/documentapi/messagebus/messages/testandsetcondition.h
blob: e481cb8ec618b2e4f9cbe01a2f2c9b9dc7aec86e (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
// @author Vegard Sjonfjell
#pragma once

#include <vespa/vespalib/stllike/string.h>

namespace documentapi {

class TestAndSetCondition {
private:
    vespalib::string _selection;

public:
    TestAndSetCondition()
        : _selection()
    {}
    
    explicit TestAndSetCondition(vespalib::stringref selection)
        : _selection(selection)
    {}

    TestAndSetCondition(const TestAndSetCondition &) = default;
    TestAndSetCondition & operator=(const TestAndSetCondition &) = default;

    TestAndSetCondition(TestAndSetCondition &&) = default;
    TestAndSetCondition & operator=(TestAndSetCondition &&) = default;

    const vespalib::string & getSelection() const { return _selection; }
    bool isPresent() const noexcept { return !_selection.empty(); }

    bool operator==(const TestAndSetCondition& rhs) const noexcept {
        return (_selection == rhs._selection);
    }
};

}