blob: 5f1a61cc22da9d846b43b532990b1e9e351ca55b (
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
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include "datastorebase.h"
#include "entryref.h"
#include "handle.h"
#include <vespa/vespalib/util/arrayref.h>
namespace vespalib::datastore {
/**
* Allocator used to allocate entries of a specific type in an underlying data store.
*/
template <typename EntryT, typename RefT>
class Allocator
{
public:
using ConstArrayRef = vespalib::ConstArrayRef<EntryT>;
using HandleType = Handle<EntryT>;
protected:
DataStoreBase &_store;
uint32_t _typeId;
public:
Allocator(DataStoreBase &store, uint32_t typeId);
template <typename ... Args>
HandleType alloc(Args && ... args);
HandleType allocArray(ConstArrayRef array);
HandleType allocArray();
template <typename BufferType>
HandleType alloc_dynamic_array(ConstArrayRef array);
};
}
|