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

#pragma once

#include <string>
#include "fieldinfo.h"
#include "parameterdescriptions.h"

namespace search::fef {

/**
 * This class represents a parameter with type and value.
 * You can use convenience functions to access the parameter value as different types.
 */
class Parameter {
private:
    ParameterType::Enum _type;
    vespalib::string    _stringVal;
    double              _doubleVal;
    int64_t             _intVal;
    const search::fef::FieldInfo * _fieldVal;

public:
    Parameter(ParameterType::Enum type, const vespalib::string & value);
    Parameter & setDouble(double val) { _doubleVal = val; return *this; }
    Parameter & setInteger(int64_t val) { _intVal = val; return *this; }
    Parameter & setField(const search::fef::FieldInfo * val) { _fieldVal = val; return *this; }
    ParameterType::Enum getType() const { return _type; }
    const vespalib::string & getValue() const { return _stringVal; }
    double asDouble() const { return _doubleVal; }
    int64_t asInteger() const { return _intVal; }
    const search::fef::FieldInfo * asField() const { return _fieldVal; }
};

using ParameterList = std::vector<Parameter>;

}