aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/vespa/searchlib/test/mock_attribute_manager.h
blob: 5968c6660ea6adc422d518df6316351c60bd9a28 (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include <vespa/searchlib/attribute/attributecontext.h>
#include <vespa/searchlib/attribute/attributeguard.h>
#include <vespa/searchlib/attribute/attributevector.h>
#include <vespa/searchlib/attribute/attribute_read_guard.h>
#include <vespa/searchlib/attribute/iattributemanager.h>
#include <map>

namespace search::attribute::test {

class MockAttributeManager : public search::IAttributeManager {
protected:
    using AttributeMap = std::map<string, AttributeVector::SP>;

    AttributeMap _attributes;

    AttributeVector::SP findAttribute(const vespalib::string &name) const;
public:
    MockAttributeManager();
    ~MockAttributeManager() override;

    AttributeGuard::UP getAttribute(const vespalib::string &name) const override;
    void asyncForAttribute(const vespalib::string &, std::unique_ptr<IAttributeFunctor>) const override;
    std::unique_ptr<AttributeReadGuard> getAttributeReadGuard(const vespalib::string &name, bool stableEnumGuard) const override;
    void getAttributeList(std::vector<AttributeGuard> &list) const override;
    IAttributeContext::UP createContext() const override;
    void addAttribute(const vespalib::string &name, const AttributeVector::SP &attr);
    void addAttribute(const AttributeVector::SP &attr);
    std::shared_ptr<attribute::ReadableAttributeVector> readable_attribute_vector(const string& name) const override;
};

}