STIR 6.4.0
InputStreamWithRecordsFromHDF5.h
Go to the documentation of this file.
1//
2//
15/*
16 Copyright (C) 2016-2018, 2020-2021 University College London
17 Copyright (C) 2016-2019, University of Leeds
18 Copyright (C) 2016-2018, University of Hull
19
20 This file is part of STIR.
21
22 SPDX-License-Identifier: Apache-2.0
23
24 See STIR/LICENSE.txt for details
25*/
26
27#ifndef __stir_IO_InputStreamWithRecordsFromHDF5_H__
28#define __stir_IO_InputStreamWithRecordsFromHDF5_H__
29
30#include "stir/shared_ptr.h"
31#include "stir/Succeeded.h"
33#include "boost/shared_array.hpp"
34#include <string>
35#include <iostream>
36#include <vector>
37
38START_NAMESPACE_STIR
39
40namespace GE
41{
42namespace RDF_HDF5
43{
44
46
73template <class RecordT>
75{
76public:
77 typedef std::vector<std::streampos>::size_type SavedPosition;
79
81 // explicit
82 // InputStreamWithRecordsFromHDF5(const shared_ptr<H5::DataSet>& ,
83 // const std::size_t size_of_record_signature,
84 // const std::size_t max_size_of_record);
85
86 explicit InputStreamWithRecordsFromHDF5(const std::string& filename,
87 const std::size_t size_of_record_signature,
88 const std::size_t max_size_of_record);
89
91
92 inline virtual Succeeded get_next_record(RecordT& record);
93
94 virtual Succeeded set_up();
95
97 inline Succeeded reset();
98
100
103 inline SavedPosition save_get_position();
104
106 inline Succeeded set_get_position(const SavedPosition&);
107
109
113 inline std::vector<std::streampos> get_saved_get_positions() const;
115
120 inline void set_saved_get_positions(const std::vector<std::streampos>&);
121
122private:
123 shared_ptr<GEHDF5Wrapper> input_sptr;
124
125 boost::shared_array<char> data_sptr;
126
127 uint64_t m_list_size = 0;
128
129 std::streampos starting_stream_position;
130 mutable std::streampos current_offset;
131 std::vector<std::streampos> saved_get_positions;
132
133 const std::string m_filename;
134 const std::size_t size_of_record_signature;
135 const std::size_t max_size_of_record;
136
138 void read_data(char* output, const std::streampos offset, const hsize_t size) const;
139 // members for buffering
140
141 boost::shared_array<char> buffer;
142 std::size_t max_buffer_size;
144 mutable std::size_t buffer_size;
145 mutable std::streampos start_of_buffer_offset;
146 void fill_buffer(const std::streampos offset) const;
147};
148
149} // namespace RDF_HDF5
150} // namespace GE
151END_NAMESPACE_STIR
152
154
155#endif
Declaration of class stir::GE::RDF_HDF5::GEHDF5Wrapper.
Implementation of class stir::GE::RDF_HDF5::InputStreamWithRecordsFromHDF5.
Declaration of class stir::Succeeded.
std::vector< std::streampos > get_saved_get_positions() const
Function that enables the user to store the saved get_positions.
Definition InputStreamWithRecordsFromHDF5.inl:183
Succeeded set_get_position(const SavedPosition &)
set current "get" position to previously saved value
Definition InputStreamWithRecordsFromHDF5.inl:169
InputStreamWithRecordsFromHDF5(const std::string &filename, const std::size_t size_of_record_signature, const std::size_t max_size_of_record)
Constructor taking a stream.
Definition InputStreamWithRecordsFromHDF5.inl:58
Succeeded reset()
go back to starting position
Definition InputStreamWithRecordsFromHDF5.inl:147
void set_saved_get_positions(const std::vector< std::streampos > &)
Function that sets the saved get_positions.
Definition InputStreamWithRecordsFromHDF5.inl:190
SavedPosition save_get_position()
save current "get" position in an internal array
Definition InputStreamWithRecordsFromHDF5.inl:158
a class containing an enumeration type that can be used by functions to signal successful operation o...
Definition Succeeded.h:44
Import of std::shared_ptr, std::dynamic_pointer_cast and std::static_pointer_cast into the stir names...