blob: 4f835d064bb686183f14a9389583435bcf8a4032 (
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include "currentindex.h"
#include <vespa/vespalib/stllike/string.h>
#include <vespa/vespalib/stllike/hash_map.h>
#include <vespa/vespalib/stllike/hash_set.h>
#include <utility>
namespace search::expression {
class CurrentIndexSetup {
public:
class Usage {
private:
friend class CurrentIndexSetup;
vespalib::hash_set<vespalib::string> _unbound;
void notify_unbound_struct_usage(vespalib::stringref name);
public:
Usage();
~Usage();
[[nodiscard]] bool has_single_unbound_struct() const noexcept {
return (_unbound.size() == 1);
}
vespalib::stringref get_unbound_struct_name() const;
class Bind {
private:
CurrentIndexSetup &_setup;
public:
Bind(CurrentIndexSetup &setup, Usage &usage) noexcept;
~Bind();
};
};
private:
vespalib::hash_map<vespalib::string, const CurrentIndex *> _bound;
Usage *_usage;
[[nodiscard]] Usage *capture(Usage *usage) noexcept {
return std::exchange(_usage, usage);
}
public:
CurrentIndexSetup();
~CurrentIndexSetup();
[[nodiscard]] const CurrentIndex *resolve(vespalib::stringref field_name) const;
void bind(vespalib::stringref struct_name, const CurrentIndex &index);
};
}
|