Alexandria  2.16
Please provide a description of the project.
FitsReader.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2020 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 <functional>
29 #include <CCfits/CCfits>
30 #include "Table/TableReader.h"
31 
32 namespace Euclid {
33 namespace Table {
34 
75 class FitsReader : public TableReader {
76 
77 public:
78 
92  explicit FitsReader(const CCfits::HDU& hdu);
93 
96  FitsReader(const std::string& filename, int hdu_index=1);
97 
100  FitsReader(const std::string& filename, const std::string& hduName);
101 
102  FitsReader(FitsReader&&) = default;
104 
105  FitsReader(const FitsReader&) = delete;
106  FitsReader& operator=(const FitsReader&) = delete;
107 
111  virtual ~FitsReader() = default;
112 
127 
139  const ColumnInfo& getInfo() override;
140 
144  std::string getComment() override;
145 
147  void skip(long rows) override;
148 
150  bool hasMoreRows() override;
151 
153  std::size_t rowsLeft() override;
154 
155 protected:
156 
158  Table readImpl(long rows) override;
159 
160 private:
161 
162  void readColumnInfo();
163 
166  bool m_reading_started = false;
167  long m_total_rows = -1;
168  long m_current_row = 1;
171 
172 }; /* End of FitsReader class */
173 
174 } /* namespace Table */
175 } /* namespace Euclid */
176 
177 
178 #endif
Euclid::Table::FitsReader::readColumnInfo
void readColumnInfo()
Definition: FitsReader.cpp:87
std::string
STL class.
std::shared_ptr
STL class.
TableReader.h
Euclid::Table::FitsReader::getInfo
const ColumnInfo & getInfo() override
Returns the column information of the table.
Definition: FitsReader.cpp:116
Euclid::Table::FitsReader::m_hdu
std::reference_wrapper< const CCfits::HDU > m_hdu
Definition: FitsReader.h:165
Euclid::Table::FitsReader::getComment
std::string getComment() override
Definition: FitsReader.cpp:121
std::vector< std::string >
Euclid::Table::FitsReader::readImpl
Table readImpl(long rows) override
Implements the TableReader::readImpl() contract.
Definition: FitsReader.cpp:126
Euclid::Table::FitsReader::m_current_row
long m_current_row
Definition: FitsReader.h:168
Euclid::Table::FitsReader::~FitsReader
virtual ~FitsReader()=default
Destructor.
Euclid::Table::FitsReader::fixColumnNames
FitsReader & fixColumnNames(std::vector< std::string > column_names)
Overrides the column names of the table.
Definition: FitsReader.cpp:61
Euclid::Table::FitsReader::FitsReader
FitsReader(const CCfits::HDU &hdu)
Creates a FitsReader that reads from the given HDU.
Definition: FitsReader.cpp:50
Euclid::Table::ColumnInfo
Provides information about the columns of a Table.
Definition: ColumnInfo.h:52
std::reference_wrapper< const CCfits::HDU >
Euclid::Table::FitsReader::rowsLeft
std::size_t rowsLeft() override
Implements the TableReader::rowsLeft() contract.
Definition: FitsReader.cpp:172
Euclid::Table::FitsReader::FitsReader
FitsReader(const FitsReader &)=delete
Euclid::Table::FitsReader::m_fits
std::unique_ptr< CCfits::FITS > m_fits
Definition: FitsReader.h:164
Euclid::Table::FitsReader::FitsReader
FitsReader(FitsReader &&)=default
Euclid::Table::FitsReader::m_total_rows
long m_total_rows
Definition: FitsReader.h:167
Euclid::Table::FitsReader::operator=
FitsReader & operator=(FitsReader &&)=default
Euclid::Table::FitsReader::m_column_names
std::vector< std::string > m_column_names
Definition: FitsReader.h:169
Euclid::Table::FitsReader
TableReader implementation for reading FITS tables.
Definition: FitsReader.h:75
Euclid::Table::TableReader
Interface for classes reading tables.
Definition: TableReader.h:48
Euclid::Table::Table
Represents a table.
Definition: Table.h:49
std::size_t
Euclid::Table::FitsReader::operator=
FitsReader & operator=(const FitsReader &)=delete
std::unique_ptr< CCfits::FITS >
Euclid
Definition: InstOrRefHolder.h:29
Euclid::Table::FitsReader::hasMoreRows
bool hasMoreRows() override
Implements the TableReader::hasMoreRows() contract.
Definition: FitsReader.cpp:167
Euclid::Table::FitsReader::m_column_info
std::shared_ptr< ColumnInfo > m_column_info
Definition: FitsReader.h:170
Euclid::Table::FitsReader::skip
void skip(long rows) override
Implements the TableReader::skip() contract.
Definition: FitsReader.cpp:162
Euclid::Table::FitsReader::m_reading_started
bool m_reading_started
Definition: FitsReader.h:166