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

#pragma once

#include "value_builder_factory.h"

namespace vespalib::eval {

/**
 * A trivial builder for DoubleValue objects
 **/
class DoubleValueBuilder : public ValueBuilder<double>
{
private:
    double _value;
public:
    DoubleValueBuilder() : _value(0.0) {}
    ~DoubleValueBuilder() override;
    ArrayRef<double>
    add_subspace(ConstArrayRef<vespalib::stringref>) override {
        return ArrayRef<double>(&_value, 1);
    }
    std::unique_ptr<Value>
    build(std::unique_ptr<ValueBuilder<double>>) override {
        return std::make_unique<DoubleValue>(_value);
    }
};

} // namespace