aboutsummaryrefslogtreecommitdiffstats
path: root/document/src/vespa/document/fieldvalue/floatfieldvalue.h
blob: dcd2285111c8fe5d885e8b82bb8845837ba177f4 (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
/**
 * \class document::FloatFieldValue
 * \ingroup fieldvalue
 *
 * \brief Wrapper for field values of datatype FLOAT.
 */
#pragma once

#include "numericfieldvalue.h"
#include <vespa/document/datatype/datatype.h>

namespace document {

class FloatFieldValue final : public NumericFieldValue<float> {
public:
    using Number = float;

    FloatFieldValue(Number value = 0) : NumericFieldValue<Number>(Type::FLOAT, value) {}

    void accept(FieldValueVisitor &visitor) override { visitor.visit(*this); }
    void accept(ConstFieldValueVisitor &visitor) const override { visitor.visit(*this); }

    const DataType *getDataType() const override { return DataType::FLOAT; }
    FloatFieldValue* clone() const override { return new FloatFieldValue(*this); }

    using NumericFieldValue<Number>::operator=;
    static std::unique_ptr<FloatFieldValue> make(Number value = 0) { return std::make_unique<FloatFieldValue>(value); }
};

} // document