STIR 6.4.0
OutputFileFormat.h
Go to the documentation of this file.
1//
2//
3/*
4 Copyright (C) 2003- 2007, Hammersmith Imanet Ltd
5 This file is part of STIR.
6 SPDX-License-Identifier: Apache-2.0
7
8
9 See STIR/LICENSE.txt for details
10*/
20
21#ifndef __stir_IO_OutputFileFormat_H__
22#define __stir_IO_OutputFileFormat_H__
23
25#include "stir/NumericType.h"
26#include "stir/ByteOrder.h"
27#include <string>
28
29START_NAMESPACE_STIR
30
31class Succeeded;
32
54template <typename DataT>
55class OutputFileFormat : public RegisteredObject<OutputFileFormat<DataT>>
56{
57public:
59 static shared_ptr<OutputFileFormat<DataT>> default_sptr();
60
61 OutputFileFormat(const NumericType& = NumericType::FLOAT, const ByteOrder& = ByteOrder::native);
62
64
80 Succeeded write_to_file(std::string& filename, const DataT& data) const;
81
83
86 Succeeded write_to_file(const std::string& filename, const DataT& density) const;
87
93
96
98
103 virtual NumericType set_type_of_numbers(const NumericType&, const bool warn = false);
105
110 virtual ByteOrder set_byte_order(const ByteOrder&, const bool warn = false);
112
119 virtual void set_byte_order_and_type_of_numbers(ByteOrder&, NumericType&, const bool warn = false);
120
122
131 virtual float set_scale_to_write_data(const float new_scale_to_write_data, const bool warn = false);
132
133protected:
139
142
144
152 virtual Succeeded actual_write_to_file(std::string& filename, const DataT& density) const = 0;
153
154 // parsing stuff
155
157
158 void set_defaults() override;
160
161 void initialise_keymap() override;
163
164 bool post_processing() override;
166
167 void set_key_values() override;
168
169private:
170 static shared_ptr<OutputFileFormat<DataT>> _default_sptr;
171 // Lists of possible values for some keywords
172 static ASCIIlist_type number_format_values;
173 static ASCIIlist_type byte_order_values;
174
175 // Corresponding variables here
176
177 int number_format_index;
178 int byte_order_index;
179 int bytes_per_pixel;
180};
181
182END_NAMESPACE_STIR
183
184#endif
This file declares the stir::ByteOrder class.
This file declares the stir::NumericType class.
Declaration of class stiir::RegisteredObject.
This class provides member functions to find out what byte-order your machine is and to swap numbers.
Definition ByteOrder.h:100
@ native
Definition ByteOrder.h:107
provides names for some numeric types and methods for finding their properties.
Definition NumericType.h:55
NumericType get_type_of_numbers() const
get type used for outputting numbers
bool post_processing() override
Checks if parameters have sensible values after parsing.
Succeeded write_to_file(std::string &filename, const DataT &data) const
Write a single image to file.
virtual void set_byte_order_and_type_of_numbers(ByteOrder &, NumericType &, const bool warn=false)
set byte order and data type used for output
Succeeded write_to_file(const std::string &filename, const DataT &density) const
write a single image to file
virtual NumericType set_type_of_numbers(const NumericType &, const bool warn=false)
set type used for outputting numbers
void set_defaults() override
sets value for output data type
virtual float set_scale_to_write_data(const float new_scale_to_write_data, const bool warn=false)
set scale outputting numbers
float scale_to_write_data
scale to write the data
Definition OutputFileFormat.h:141
NumericType type_of_numbers
type used for outputting numbers
Definition OutputFileFormat.h:135
ByteOrder get_byte_order()
get byte order used for output
void initialise_keymap() override
sets keys for output data type for parsing
float get_scale_to_write_data() const
get scale to write the data
virtual Succeeded actual_write_to_file(std::string &filename, const DataT &density) const =0
virtual function called by write_to_file()
void set_key_values() override
overloaded member for ParsingObject::set_key_values()
static shared_ptr< OutputFileFormat< DataT > > default_sptr()
A function to return a default output file format.
virtual ByteOrder set_byte_order(const ByteOrder &, const bool warn=false)
set byte order used for output
ByteOrder file_byte_order
byte order used for output
Definition OutputFileFormat.h:137
a class containing an enumeration type that can be used by functions to signal successful operation o...
Definition Succeeded.h:44