aboutsummaryrefslogtreecommitdiffstats
path: root/document/src/vespa/document/select/compare.h
blob: 7bf382f2a35dcfcc6a5efea38862d100bc0e0be0 (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
/**
 * @class document::select::Compare
 * @ingroup select
 *
 * @brief Node comparing two values
 *
 * @author H�kon Humberset
 * @date 2007-04-20
 * @version $Id$
 */

#pragma once

#include <memory>
#include "node.h"
#include "operator.h"
#include <vespa/document/bucket/bucketidfactory.h>

namespace document::select {

class ValueNode;

class Compare : public Node
{
private:
    std::unique_ptr<ValueNode> _left;
    std::unique_ptr<ValueNode> _right;
    const Operator& _operator;
    const BucketIdFactory& _bucketIdFactory;

    bool isLeafNode() const override { return false; }
public:
    Compare(std::unique_ptr<ValueNode> left, const Operator& op,
            std::unique_ptr<ValueNode> right,
            const BucketIdFactory& bucketidfactory);
    ~Compare();

    ResultList contains(const Context &context) const override;
    ResultList trace(const Context &context, std::ostream& trace) const override;
    void print(std::ostream&, bool verbose, const std::string& indent) const override;
    void visit(Visitor& v) const override;

    const Operator& getOperator() const { return _operator; }

    const ValueNode& getLeft() const { return *_left; }
    const ValueNode& getRight() const { return *_right; }

    Node::UP clone() const override;

    const BucketIdFactory &getBucketIdFactory(void) const { return _bucketIdFactory; }
};

}