blob: 8fa234f3fdbc532499a143bd22d2b76290bd5112 (
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 Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include "documenttyperepo.h"
namespace document {
// Combines a DocumentTypeRepo and a DocumentType to allow easy access
// to the types contained in the DocumentType's namespace.
class FixedTypeRepo {
const DocumentTypeRepo *_repo;
const DocumentType *_doc_type;
public:
explicit FixedTypeRepo(const DocumentTypeRepo &repo) noexcept
: _repo(&repo), _doc_type(repo.getDefaultDocType()) {}
FixedTypeRepo(const DocumentTypeRepo &repo, const DocumentType &doc_type) noexcept
: _repo(&repo), _doc_type(&doc_type) {}
FixedTypeRepo(const DocumentTypeRepo *repo, const DocumentType *doc_type) noexcept
: _repo(repo), _doc_type(doc_type) {}
FixedTypeRepo(const DocumentTypeRepo &repo, const vespalib::string &type) noexcept;
const DataType *getDataType(int32_t id) const { return _repo->getDataType(*_doc_type, id); }
const DataType *getDataType(const vespalib::string &name) const { return _repo->getDataType(*_doc_type, name); }
const AnnotationType *getAnnotationType(int32_t id) const { return _repo->getAnnotationType(*_doc_type, id); }
const DocumentTypeRepo &getDocumentTypeRepo() const { return *_repo; }
const DocumentType &getDocumentType() const noexcept { return *_doc_type; }
const DocumentTypeRepo *getDocumentTypeRepoPtr() const { return _repo; }
const DocumentType *getDocumentTypePtr() const noexcept { return _doc_type; }
};
} // namespace document
|