vitrio 0.1.4
High-throughput image I/O for Cryo-Electron Microscopy (CryoEM)
Loading...
Searching...
No Matches
indexed_image_scratch.hpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2
3#pragma once
4
5#include <vitrio/export.hpp>
6#include <vitrio/image_scratch.hpp>
7#include <vitrio/image_scratch_open_mode.hpp>
8#include <vitrio/platform.hpp>
9
10#include <cstddef>
11#include <limits>
12#include <memory>
13#include <string>
14#include <unordered_map>
15
16namespace vitrio
17{
18
19class image_location_grouping;
20class image_reader_provider;
21class image_scratch_storage;
22
54 : public image_scratch
55{
56public:
95 std::shared_ptr<image_scratch_storage> storage,
96 std::size_t run_length,
97 image_scratch_open_mode mode = image_scratch_open_mode::empty
98 );
99
100 ~indexed_image_scratch() override;
101
102 std::shared_ptr<image_scratch_entry>
103 find(const std::string &key) override;
104
105private:
106 using entry_map_type =
107 std::unordered_map<std::string, std::shared_ptr<image_scratch_entry>>;
108
109 VITRIO_STD_MEMBER_INTERFACE
110 entry_map_type m_entries;
111};
112
141std::shared_ptr<image_scratch> create_host_image_scratch(
144 std::size_t run_length,
145 std::size_t max_size = std::numeric_limits<std::size_t>::max()
146);
147
189std::shared_ptr<image_scratch> create_mapped_file_image_scratch(
192 const std::string &path,
193 std::size_t run_length,
194 std::size_t max_size = std::numeric_limits<std::size_t>::max()
195);
196
259std::shared_ptr<image_scratch> create_directory_image_scratch(
262 const std::string &directory,
263 std::size_t run_length,
264 std::size_t budget
265);
266
267} // namespace vitrio
Groups a list of image locations by file.
Definition image_location_grouping.hpp:31
Interface to serve image_reader given a key.
Definition image_reader_provider.hpp:26
Copies of image files, kept where they are faster to reach than the files themselves.
Definition image_scratch.hpp:27
A scratch that holds the images that image_location-s can name, each in a slot of its storage.
Definition indexed_image_scratch.hpp:55
indexed_image_scratch(const image_location_grouping &locations, image_reader_provider &files, std::shared_ptr< image_scratch_storage > storage, std::size_t run_length, image_scratch_open_mode mode=image_scratch_open_mode::empty)
Construct a scratch for a grouping of locations.
std::shared_ptr< image_scratch_entry > find(const std::string &key) override
Get what is held of a file, to read it and to add to it.
A view of a contiguous sequence of elements.
Definition span.hpp:29