STIR 6.4.0
InputStreamWithRecords.h
Go to the documentation of this file.
1//
2//
11/*
12 Copyright (C) 2003- 2011, Hammersmith Imanet Ltd
13 This file is part of STIR.
14
15 SPDX-License-Identifier: Apache-2.0
16
17 See STIR/LICENSE.txt for details
18*/
19
20#ifndef __stir_IO_InputStreamWithRecords_H__
21#define __stir_IO_InputStreamWithRecords_H__
22
23#include "stir/shared_ptr.h"
24#include "stir/Succeeded.h"
25
26#include <iostream>
27#include <string>
28#include <vector>
29
30START_NAMESPACE_STIR
31
33
58template <class RecordT, class OptionsT>
60{
61public:
62 typedef std::vector<std::streampos>::size_type SavedPosition;
64
66 inline InputStreamWithRecords(const shared_ptr<std::istream>& stream_ptr,
67 const std::size_t size_of_record_signature,
68 const std::size_t max_size_of_record,
69 const OptionsT& options);
70
72
75 inline InputStreamWithRecords(const std::string& filename,
76 const std::size_t size_of_record_signature,
77 const std::size_t max_size_of_record,
78 const OptionsT& options,
79 const std::streampos start_of_data = 0);
80
81 virtual ~InputStreamWithRecords() {}
82
83 inline virtual Succeeded get_next_record(RecordT& record) const;
84
86 inline Succeeded reset();
87
89
92 inline SavedPosition save_get_position();
93
95 inline Succeeded set_get_position(const SavedPosition&);
96
98
102 inline std::vector<std::streampos> get_saved_get_positions() const;
104
109 inline void set_saved_get_positions(const std::vector<std::streampos>&);
110
111 inline std::istream& get_stream() { return *this->stream_ptr; }
112
113private:
114 shared_ptr<std::istream> stream_ptr;
115 const std::string filename;
116
117 std::streampos starting_stream_position;
118 std::vector<std::streampos> saved_get_positions;
119
120 const std::size_t size_of_record_signature;
121 const std::size_t max_size_of_record;
122
123 const OptionsT options;
124};
125
126END_NAMESPACE_STIR
127
129
130#endif
Implementation of class stir::InputStreamWithRecords.
Declaration of class stir::Succeeded.
Succeeded reset()
go back to starting position
Definition InputStreamWithRecords.inl:110
std::vector< std::streampos > get_saved_get_positions() const
Function that enables the user to store the saved get_positions.
Definition InputStreamWithRecords.inl:172
void set_saved_get_positions(const std::vector< std::streampos > &)
Function that sets the saved get_positions.
Definition InputStreamWithRecords.inl:179
InputStreamWithRecords(const shared_ptr< std::istream > &stream_ptr, const std::size_t size_of_record_signature, const std::size_t max_size_of_record, const OptionsT &options)
Constructor taking a stream.
Definition InputStreamWithRecords.inl:29
SavedPosition save_get_position()
save current "get" position in an internal array
Definition InputStreamWithRecords.inl:127
Succeeded set_get_position(const SavedPosition &)
set current "get" position to previously saved value
Definition InputStreamWithRecords.inl:151
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...