Alexandria  2.27.0
SDC-CH common library for the Euclid project
FitsReader.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2021 Euclid Science Ground Segment
3  *
4  * This library is free software; you can redistribute it and/or modify it under
5  * the terms of the GNU Lesser General Public License as published by the Free
6  * Software Foundation; either version 3.0 of the License, or (at your option)
7  * any later version.
8  *
9  * This library is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12  * details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this library; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
25 #ifndef _TABLE_FITSREADER_H
26 #define _TABLE_FITSREADER_H
27 
28 #include "Table/TableReader.h"
29 #include <CCfits/CCfits>
30 #include <functional>
31 
32 namespace Euclid {
33 namespace Table {
34 
75 class FitsReader : public TableReader {
76 
77 public:
91  explicit FitsReader(const CCfits::HDU& hdu);
92 
95  explicit FitsReader(const std::string& filename, int hdu_index = 1);
96 
99  FitsReader(const std::string& filename, const std::string& hduName);
100 
101  FitsReader(FitsReader&&) = default;
103 
104  FitsReader(const FitsReader&) = delete;
105  FitsReader& operator=(const FitsReader&) = delete;
106 
110  virtual ~FitsReader() = default;
111 
126 
138  const ColumnInfo& getInfo() override;
139 
143  std::string getComment() override;
144 
146  void skip(long rows) override;
147 
149  bool hasMoreRows() override;
150 
152  std::size_t rowsLeft() override;
153 
154 protected:
156  Table readImpl(long rows) override;
157 
158 private:
159  void readColumnInfo();
160 
163  bool m_reading_started = false;
164  long m_total_rows = -1;
165  long m_current_row = 1;
168 
169 }; /* End of FitsReader class */
170 
171 } /* namespace Table */
172 } /* namespace Euclid */
173 
174 #endif
Provides information about the columns of a Table.
Definition: ColumnInfo.h:52
TableReader implementation for reading FITS tables.
Definition: FitsReader.h:75
void skip(long rows) override
Implements the TableReader::skip() contract.
Definition: FitsReader.cpp:162
virtual ~FitsReader()=default
Destructor.
std::vector< std::string > m_column_names
Definition: FitsReader.h:166
FitsReader(const CCfits::HDU &hdu)
Creates a FitsReader that reads from the given HDU.
Definition: FitsReader.cpp:44
std::unique_ptr< CCfits::FITS > m_fits
Definition: FitsReader.h:161
bool hasMoreRows() override
Implements the TableReader::hasMoreRows() contract.
Definition: FitsReader.cpp:167
const ColumnInfo & getInfo() override
Returns the column information of the table.
Definition: FitsReader.cpp:106
FitsReader & operator=(FitsReader &&)=default
Table readImpl(long rows) override
Implements the TableReader::readImpl() contract.
Definition: FitsReader.cpp:116
std::reference_wrapper< const CCfits::HDU > m_hdu
Definition: FitsReader.h:162
FitsReader(const FitsReader &)=delete
FitsReader & operator=(const FitsReader &)=delete
std::shared_ptr< ColumnInfo > m_column_info
Definition: FitsReader.h:167
FitsReader(FitsReader &&)=default
std::size_t rowsLeft() override
Implements the TableReader::rowsLeft() contract.
Definition: FitsReader.cpp:172
std::string getComment() override
Definition: FitsReader.cpp:111
FitsReader & fixColumnNames(std::vector< std::string > column_names)
Overrides the column names of the table.
Definition: FitsReader.cpp:52
Interface for classes reading tables.
Definition: TableReader.h:48
Represents a table.
Definition: Table.h:49