aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src/vespa/searchcore/proton/attribute/imported_attributes_repo.h
blob: a7464ae5147d9d3565f3e79c3bea41269f6284a7 (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.
#pragma once

#include <vespa/vespalib/stllike/hash_map.h>
#include <vespa/vespalib/stllike/string.h>
#include <vector>

namespace search { namespace attribute { class ImportedAttributeVector; } }

namespace proton {

/**
 * A repository of imported attribute vector instances.
 */
class ImportedAttributesRepo {
private:
    using ImportedAttributeVector = search::attribute::ImportedAttributeVector;
    using Repo = vespalib::hash_map<vespalib::string, std::shared_ptr<ImportedAttributeVector>>;

    Repo _repo;

public:
    using UP = std::unique_ptr<ImportedAttributesRepo>;
    ImportedAttributesRepo();
    ~ImportedAttributesRepo();
    void add(const vespalib::string &name, std::shared_ptr<ImportedAttributeVector> attr);
    const std::shared_ptr<ImportedAttributeVector> & get(const vespalib::string &name) const;
    void getAll(std::vector<std::shared_ptr<ImportedAttributeVector>> &result) const;
    size_t size() const { return _repo.size(); }
};

}