aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/vespa/searchlib/fef/test/labels.h
blob: 51dc54d583241dd78844887c81c33c29b8a25ce8 (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include <vespa/searchlib/fef/properties.h>
#include <vespa/vespalib/stllike/asciistream.h>

namespace search::fef::test {

struct Labels {
    virtual void inject(Properties &p) const = 0;
    virtual ~Labels() {}
};
struct NoLabel : public Labels {
    virtual void inject(Properties &) const override {}
    ~NoLabel() override;
};
struct SingleLabel : public Labels {
    vespalib::string label;
    uint32_t uid;
    SingleLabel(const vespalib::string &l, uint32_t x) : label(l), uid(x) {}
    virtual void inject(Properties &p) const override {
        vespalib::asciistream key;
        key << "vespa.label." << label << ".id";
        vespalib::asciistream value;
        value << uid;
        p.add(key.str(), value.str());
    }
};

}