Skip to content

Commit

Permalink
Replaced storage container for HDU (vec-deque) to prevent reference i…
Browse files Browse the repository at this point in the history
…nvalidation
  • Loading branch information
gopi487krishna committed Nov 25, 2020
1 parent ac8be8f commit 5770743
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions include/boost/astronomy/io/fits_reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ file License.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_ASTRONOMY_IO_FITS_READER_HPP
#define BOOST_ASTRONOMY_IO_FITS_READER_HPP

#include <vector>
#include <deque>
#include <string>
#include <stdexcept>
#include <map>

#include <boost/astronomy/io/header.hpp>
Expand Down Expand Up @@ -59,7 +58,7 @@ namespace boost { namespace astronomy { namespace io {
struct fits_io {
private:
FileReader file_reader;
std::vector<typename ExtensionsSupported::Extension> hdu_list;
std::deque<typename ExtensionsSupported::Extension> hdu_list;
control_block hdus_control_block;
public:
/**
Expand Down Expand Up @@ -148,28 +147,28 @@ namespace boost { namespace astronomy { namespace io {
/**
* @brief Returns the HDU at given index
*/
typename ExtensionsSupported::Extension& operator [](int index) {
typename ExtensionsSupported::Extension& operator [](int index) {
return hdu_list.at(index);
}

/**
* @brief Returns the HDU based on the hdu_name
*/
typename ExtensionsSupported::Extension& operator [](const std::string& hdu_name) {
typename ExtensionsSupported::Extension& operator [](const std::string& hdu_name) {
return hdu_list[hdus_control_block.hdus_info.at(hdu_name).hdu_index];
}

/**
* @brief Returns the list of hdu objects associated with a FITS file
*/
std::vector<typename ExtensionsSupported::Extension> get_hdu_list() {
std::deque<typename ExtensionsSupported::Extension> get_hdu_list() const {
return hdu_list;
}

/**
* @brief Returns the control block containing the hdu cache information
*/
control_block get_control_block_info() {
control_block get_control_block_info() const {
return hdus_control_block;
}

Expand Down

0 comments on commit 5770743

Please sign in to comment.