aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/vespa/searchlib/fef/blueprintfactory.cpp
blob: 6f53fc0c57d5ee23b227da0e5001f915a7dcb8c0 (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "blueprintfactory.h"
#include "blueprint.h"

#include <vespa/log/log.h>
LOG_SETUP(".fef.blueprintfactory");

namespace search::fef {

BlueprintFactory::BlueprintFactory()
    : _blueprintMap()
{
}

void
BlueprintFactory::addPrototype(Blueprint::SP proto)
{
    vespalib::string name = proto->getBaseName();
    if (_blueprintMap.find(name) != _blueprintMap.end()) {
        LOG(warning, "Blueprint prototype overwritten: %s", name.c_str());
    }
    _blueprintMap[name] = std::move(proto);
}

void
BlueprintFactory::visitDumpFeatures(const IIndexEnvironment &indexEnv,
                                    IDumpFeatureVisitor &visitor) const
{
    for (const auto & entry : _blueprintMap) {
        entry.second->visitDumpFeatures(indexEnv, visitor);
    }
}

Blueprint::SP
BlueprintFactory::createBlueprint(const vespalib::string &name) const
{
    auto itr = _blueprintMap.find(name);
    if (itr == _blueprintMap.end()) {
        return {};
    }
    return itr->second->createInstance();
}

}