Commit 8ef2adfaf2c763526ba357fc3b26db072114b487
1 parent
f9fd3498
Support writing of variable-length columns.
Showing
32 changed files
with
1108 additions
and
305 deletions
include/GFitsTableBitCol.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * GFitsTableBitCol.hpp - FITS table bit column class * | |
| 2 | + * GFitsTableBitCol.hpp - FITS table bit column class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2008-2012 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2008-2013 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -75,24 +75,24 @@ private: |
| 75 | 75 | void init_members(void); |
| 76 | 76 | void copy_members(const GFitsTableBitCol& column); |
| 77 | 77 | void free_members(void); |
| 78 | + void alloc_nulval(const unsigned char* value); | |
| 79 | + void get_bit(const int& row, const int& inx); | |
| 80 | + void set_pending(void); | |
| 78 | 81 | |
| 79 | - // Implemented pure virtual methods | |
| 80 | - virtual std::string ascii_format(void) const; | |
| 81 | - virtual void alloc_data(void); | |
| 82 | - virtual void init_data(void); | |
| 83 | - virtual void* ptr_data(const int& index = 0) { return m_data+index; } | |
| 84 | - virtual void* ptr_nulval(void) { return m_nulval; } | |
| 82 | + // Implemented virtual base class methods | |
| 83 | + virtual void alloc_data(void); | |
| 84 | + virtual void init_data(void); | |
| 85 | + virtual void fetch_data(void) const; | |
| 86 | + virtual void copy_data(const GFitsTableCol& column); | |
| 87 | + virtual void release_data(void); | |
| 88 | + virtual void* ptr_data(const int& index = 0) { return m_data+index; } | |
| 89 | + virtual void* ptr_nulval(void) { return m_nulval; } | |
| 90 | + virtual std::string ascii_format(void) const; | |
| 85 | 91 | |
| 86 | 92 | // Overloaded virtual methods |
| 87 | 93 | virtual void load_column(void); |
| 88 | 94 | virtual void save_column(void); |
| 89 | 95 | |
| 90 | - // Other private methods | |
| 91 | - void release_data(void); | |
| 92 | - void alloc_nulval(const unsigned char* value); | |
| 93 | - void get_bit(const int& row, const int& inx); | |
| 94 | - void set_pending(void); | |
| 95 | - | |
| 96 | 96 | // Private data area |
| 97 | 97 | int m_bits; //!< Total number of Bits in column |
| 98 | 98 | int m_bytes_per_row; //!< Number of Bytes per row | ... | ... |
include/GFitsTableBoolCol.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * GFitsTableBoolCol.hpp - FITS table boolean column class * | |
| 2 | + * GFitsTableBoolCol.hpp - FITS table boolean column class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2008-2012 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2008-2013 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -73,25 +73,30 @@ public: |
| 73 | 73 | |
| 74 | 74 | private: |
| 75 | 75 | // Private methods |
| 76 | - void init_members(void); | |
| 77 | - void copy_members(const GFitsTableBoolCol& column); | |
| 78 | - void free_members(void); | |
| 79 | - void save(void); | |
| 80 | - std::string ascii_format(void) const; | |
| 81 | - void alloc_data(void); | |
| 82 | - void release_data(void); | |
| 83 | - void alloc_nulval(const bool* value); | |
| 84 | - void init_data(void); | |
| 85 | - void fetch_data(void) const; | |
| 86 | - void alloc_buffer(void); | |
| 87 | - void free_buffer(void); | |
| 88 | - void* ptr_data(const int& index = 0) { return m_buffer+index; } | |
| 89 | - void* ptr_nulval(void) { return m_nulval; } | |
| 76 | + void init_members(void); | |
| 77 | + void copy_members(const GFitsTableBoolCol& column); | |
| 78 | + void free_members(void); | |
| 79 | + void alloc_nulval(const bool* value); | |
| 80 | + void alloc_buffer(void) const; | |
| 81 | + void free_buffer(void) const; | |
| 82 | + | |
| 83 | + // Implemented virtual base class methods | |
| 84 | + virtual void alloc_data(void); | |
| 85 | + virtual void init_data(void); | |
| 86 | + virtual void fetch_data(void) const; | |
| 87 | + virtual void copy_data(const GFitsTableCol& column); | |
| 88 | + virtual void release_data(void); | |
| 89 | + virtual void* ptr_data(const int& index = 0) { return m_data+index; } | |
| 90 | + virtual void* ptr_nulval(void) { return m_nulval; } | |
| 91 | + virtual std::string ascii_format(void) const; | |
| 92 | + | |
| 93 | + // Overloaded base class methods | |
| 94 | + virtual void save(void); | |
| 90 | 95 | |
| 91 | 96 | // Private data area |
| 92 | - bool* m_data; //!< Data area | |
| 93 | - char* m_buffer; //!< Data area for CFITSIO transfer | |
| 94 | - bool* m_nulval; //!< NULL value | |
| 97 | + bool* m_data; //!< Data area | |
| 98 | + bool* m_nulval; //!< NULL value | |
| 99 | + mutable char* m_buffer; //!< Data area for CFITSIO transfer | |
| 95 | 100 | }; |
| 96 | 101 | |
| 97 | 102 | #endif /* GFITSTABLEBOOLCOL_HPP */ | ... | ... |
include/GFitsTableByteCol.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * GFitsTableByteCol.hpp - FITS table Byte column class * | |
| 2 | + * GFitsTableByteCol.hpp - FITS table Byte column class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2008-2012 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2008-2013 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -70,16 +70,20 @@ public: |
| 70 | 70 | |
| 71 | 71 | private: |
| 72 | 72 | // Private methods |
| 73 | - void init_members(void); | |
| 74 | - void copy_members(const GFitsTableByteCol& column); | |
| 75 | - void free_members(void); | |
| 76 | - std::string ascii_format(void) const; | |
| 77 | - void alloc_data(void); | |
| 78 | - void release_data(void); | |
| 79 | - void alloc_nulval(const unsigned char* value); | |
| 80 | - void init_data(void); | |
| 81 | - void* ptr_data(const int& index = 0) { return m_data+index; } | |
| 82 | - void* ptr_nulval(void) { return m_nulval; } | |
| 73 | + void init_members(void); | |
| 74 | + void copy_members(const GFitsTableByteCol& column); | |
| 75 | + void free_members(void); | |
| 76 | + void alloc_nulval(const unsigned char* value); | |
| 77 | + | |
| 78 | + // Implemented virtual base class methods | |
| 79 | + virtual void alloc_data(void); | |
| 80 | + virtual void init_data(void); | |
| 81 | + virtual void fetch_data(void) const; | |
| 82 | + virtual void copy_data(const GFitsTableCol& column); | |
| 83 | + virtual void release_data(void); | |
| 84 | + virtual void* ptr_data(const int& index = 0) { return m_data+index; } | |
| 85 | + virtual void* ptr_nulval(void) { return m_nulval; } | |
| 86 | + virtual std::string ascii_format(void) const; | |
| 83 | 87 | |
| 84 | 88 | // Private data area |
| 85 | 89 | unsigned char* m_data; //!< Data vector | ... | ... |
include/GFitsTableCDoubleCol.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * GFitsTableCDoubleCol.hpp - FITS table double precision complex column * | |
| 2 | + * GFitsTableCDoubleCol.hpp - FITS table double precision complex column * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2008-2012 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2008-2013 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -71,16 +71,20 @@ public: |
| 71 | 71 | |
| 72 | 72 | private: |
| 73 | 73 | // Private methods |
| 74 | - void init_members(void); | |
| 75 | - void copy_members(const GFitsTableCDoubleCol& column); | |
| 76 | - void free_members(void); | |
| 77 | - std::string ascii_format(void) const; | |
| 78 | - void alloc_data(void); | |
| 79 | - void release_data(void); | |
| 80 | - void alloc_nulval(const GFits::cdouble* value); | |
| 81 | - void init_data(void); | |
| 82 | - void* ptr_data(const int& index = 0) { return m_data+index; } | |
| 83 | - void* ptr_nulval(void) { return m_nulval; } | |
| 74 | + void init_members(void); | |
| 75 | + void copy_members(const GFitsTableCDoubleCol& column); | |
| 76 | + void free_members(void); | |
| 77 | + void alloc_nulval(const GFits::cdouble* value); | |
| 78 | + | |
| 79 | + // Implemented virtual base class methods | |
| 80 | + virtual void alloc_data(void); | |
| 81 | + virtual void init_data(void); | |
| 82 | + virtual void fetch_data(void) const; | |
| 83 | + virtual void copy_data(const GFitsTableCol& column); | |
| 84 | + virtual void release_data(void); | |
| 85 | + virtual void* ptr_data(const int& index = 0) { return m_data+index; } | |
| 86 | + virtual void* ptr_nulval(void) { return m_nulval; } | |
| 87 | + virtual std::string ascii_format(void) const; | |
| 84 | 88 | |
| 85 | 89 | // Private data area |
| 86 | 90 | GFits::cdouble* m_data; //!< Data vector | ... | ... |
include/GFitsTableCFloatCol.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * GFitsTableCFloatCol.hpp - FITS table single precision complex column * | |
| 2 | + * GFitsTableCFloatCol.hpp - FITS table single precision complex column * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2008-2012 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2008-2013 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -71,16 +71,20 @@ public: |
| 71 | 71 | |
| 72 | 72 | private: |
| 73 | 73 | // Private methods |
| 74 | - void init_members(void); | |
| 75 | - void copy_members(const GFitsTableCFloatCol& column); | |
| 76 | - void free_members(void); | |
| 77 | - std::string ascii_format(void) const; | |
| 78 | - void alloc_data(void); | |
| 79 | - void release_data(void); | |
| 80 | - void alloc_nulval(const GFits::cfloat* value); | |
| 81 | - void init_data(void); | |
| 82 | - void* ptr_data(const int& index = 0) { return m_data+index; } | |
| 83 | - void* ptr_nulval(void) { return m_nulval; } | |
| 74 | + void init_members(void); | |
| 75 | + void copy_members(const GFitsTableCFloatCol& column); | |
| 76 | + void free_members(void); | |
| 77 | + void alloc_nulval(const GFits::cfloat* value); | |
| 78 | + | |
| 79 | + // Implemented virtual base class methods | |
| 80 | + virtual void alloc_data(void); | |
| 81 | + virtual void init_data(void); | |
| 82 | + virtual void fetch_data(void) const; | |
| 83 | + virtual void copy_data(const GFitsTableCol& column); | |
| 84 | + virtual void release_data(void); | |
| 85 | + virtual void* ptr_data(const int& index = 0) { return m_data+index; } | |
| 86 | + virtual void* ptr_nulval(void) { return m_nulval; } | |
| 87 | + virtual std::string ascii_format(void) const; | |
| 84 | 88 | |
| 85 | 89 | // Private data area |
| 86 | 90 | GFits::cfloat* m_data; //!< Data vector | ... | ... |
include/GFitsTableCol.hpp
| ... | ... | @@ -95,6 +95,7 @@ public: |
| 95 | 95 | void anynul(const int& anynul); |
| 96 | 96 | const int& anynul(void) const; |
| 97 | 97 | std::string tform_binary(void) const; |
| 98 | + bool isloaded(void) const; | |
| 98 | 99 | std::string print(const GChatter& chatter = NORMAL) const; |
| 99 | 100 | |
| 100 | 101 | protected: |
| ... | ... | @@ -107,17 +108,22 @@ protected: |
| 107 | 108 | // Protected pure virtual methods |
| 108 | 109 | virtual void alloc_data(void) = 0; |
| 109 | 110 | virtual void init_data(void) = 0; |
| 111 | + virtual void fetch_data(void) const = 0; | |
| 112 | + virtual void copy_data(const GFitsTableCol& column) = 0; | |
| 113 | + virtual void release_data(void) = 0; | |
| 110 | 114 | virtual void* ptr_data(const int& index = 0) = 0; |
| 111 | 115 | virtual void* ptr_nulval(void) = 0; |
| 112 | 116 | virtual std::string ascii_format(void) const = 0; |
| 113 | 117 | |
| 114 | 118 | // Protected virtual methods |
| 115 | 119 | virtual void save(void); |
| 116 | - virtual void fetch_data(void) const; | |
| 120 | + //virtual void fetch_data(void) const; | |
| 117 | 121 | virtual void load_column(void); |
| 118 | 122 | virtual void load_column_fixed(void); |
| 119 | 123 | virtual void load_column_variable(void); |
| 120 | 124 | virtual void save_column(void); |
| 125 | + virtual void save_column_fixed(void); | |
| 126 | + virtual void save_column_variable(void); | |
| 121 | 127 | virtual int offset(const int& row, const int& inx) const; |
| 122 | 128 | |
| 123 | 129 | // Protected data area | ... | ... |
include/GFitsTableDoubleCol.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * GFitsTableDoubleCol.hpp - FITS table double column class * | |
| 2 | + * GFitsTableDoubleCol.hpp - FITS table double column class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2012 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2013 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -70,16 +70,20 @@ public: |
| 70 | 70 | |
| 71 | 71 | private: |
| 72 | 72 | // Private methods |
| 73 | - void init_members(void); | |
| 74 | - void copy_members(const GFitsTableDoubleCol& column); | |
| 75 | - void free_members(void); | |
| 76 | - std::string ascii_format(void) const; | |
| 77 | - void alloc_data(void); | |
| 78 | - void release_data(void); | |
| 79 | - void alloc_nulval(const double* value); | |
| 80 | - void init_data(void); | |
| 81 | - void* ptr_data(const int& index = 0) { return m_data+index; } | |
| 82 | - void* ptr_nulval(void) { return m_nulval; } | |
| 73 | + void init_members(void); | |
| 74 | + void copy_members(const GFitsTableDoubleCol& column); | |
| 75 | + void free_members(void); | |
| 76 | + void alloc_nulval(const double* value); | |
| 77 | + | |
| 78 | + // Implemented virtual base class methods | |
| 79 | + virtual void alloc_data(void); | |
| 80 | + virtual void init_data(void); | |
| 81 | + virtual void fetch_data(void) const; | |
| 82 | + virtual void copy_data(const GFitsTableCol& column); | |
| 83 | + virtual void release_data(void); | |
| 84 | + virtual void* ptr_data(const int& index = 0) { return m_data+index; } | |
| 85 | + virtual void* ptr_nulval(void) { return m_nulval; } | |
| 86 | + virtual std::string ascii_format(void) const; | |
| 83 | 87 | |
| 84 | 88 | // Private data area |
| 85 | 89 | double* m_data; //!< Data vector | ... | ... |
include/GFitsTableFloatCol.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * GFitsTableFloatCol.hpp - FITS table float column class * | |
| 2 | + * GFitsTableFloatCol.hpp - FITS table float column class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2012 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2013 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -70,16 +70,20 @@ public: |
| 70 | 70 | |
| 71 | 71 | private: |
| 72 | 72 | // Private methods |
| 73 | - void init_members(void); | |
| 74 | - void copy_members(const GFitsTableFloatCol& column); | |
| 75 | - void free_members(void); | |
| 76 | - std::string ascii_format(void) const; | |
| 77 | - void alloc_data(void); | |
| 78 | - void release_data(void); | |
| 79 | - void alloc_nulval(const float* value); | |
| 80 | - void init_data(void); | |
| 81 | - void* ptr_data(const int& index = 0) { return m_data+index; } | |
| 82 | - void* ptr_nulval(void) { return m_nulval; } | |
| 73 | + void init_members(void); | |
| 74 | + void copy_members(const GFitsTableFloatCol& column); | |
| 75 | + void free_members(void); | |
| 76 | + void alloc_nulval(const float* value); | |
| 77 | + | |
| 78 | + // Implemented virtual base class methods | |
| 79 | + virtual void alloc_data(void); | |
| 80 | + virtual void init_data(void); | |
| 81 | + virtual void fetch_data(void) const; | |
| 82 | + virtual void copy_data(const GFitsTableCol& column); | |
| 83 | + virtual void release_data(void); | |
| 84 | + virtual void* ptr_data(const int& index = 0) { return m_data+index; } | |
| 85 | + virtual void* ptr_nulval(void) { return m_nulval; } | |
| 86 | + virtual std::string ascii_format(void) const; | |
| 83 | 87 | |
| 84 | 88 | // Private data area |
| 85 | 89 | float* m_data; //!< Data vector | ... | ... |
include/GFitsTableLongCol.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * GFitsTableLongCol.hpp - FITS table long column class * | |
| 2 | + * GFitsTableLongCol.hpp - FITS table long column class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2010-2013 by Jurgen Knodlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -50,7 +50,7 @@ public: |
| 50 | 50 | virtual ~GFitsTableLongCol(void); |
| 51 | 51 | |
| 52 | 52 | // Operators |
| 53 | - GFitsTableLongCol& operator= (const GFitsTableLongCol& column); | |
| 53 | + GFitsTableLongCol& operator=(const GFitsTableLongCol& column); | |
| 54 | 54 | long& operator()(const int& row, const int& inx = 0); |
| 55 | 55 | const long& operator()(const int& row, const int& inx = 0) const; |
| 56 | 56 | |
| ... | ... | @@ -70,16 +70,20 @@ public: |
| 70 | 70 | |
| 71 | 71 | private: |
| 72 | 72 | // Private methods |
| 73 | - void init_members(void); | |
| 74 | - void copy_members(const GFitsTableLongCol& column); | |
| 75 | - void free_members(void); | |
| 76 | - std::string ascii_format(void) const; | |
| 77 | - void alloc_data(void); | |
| 78 | - void release_data(void); | |
| 79 | - void alloc_nulval(const long* value); | |
| 80 | - void init_data(void); | |
| 81 | - void* ptr_data(const int& index = 0) { return m_data+index; } | |
| 82 | - void* ptr_nulval(void) { return m_nulval; } | |
| 73 | + void init_members(void); | |
| 74 | + void copy_members(const GFitsTableLongCol& column); | |
| 75 | + void free_members(void); | |
| 76 | + void alloc_nulval(const long* value); | |
| 77 | + | |
| 78 | + // Implemented virtual base class methods | |
| 79 | + virtual void alloc_data(void); | |
| 80 | + virtual void init_data(void); | |
| 81 | + virtual void fetch_data(void) const; | |
| 82 | + virtual void copy_data(const GFitsTableCol& column); | |
| 83 | + virtual void release_data(void); | |
| 84 | + virtual void* ptr_data(const int& index = 0) { return m_data+index; } | |
| 85 | + virtual void* ptr_nulval(void) { return m_nulval; } | |
| 86 | + virtual std::string ascii_format(void) const; | |
| 83 | 87 | |
| 84 | 88 | // Private data area |
| 85 | 89 | long* m_data; //!< Data vector | ... | ... |
include/GFitsTableLongLongCol.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * GFitsTableLongLongCol.hpp - FITS table long long column class * | |
| 2 | + * GFitsTableLongLongCol.hpp - FITS table long long column class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2012 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2013 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -70,16 +70,20 @@ public: |
| 70 | 70 | |
| 71 | 71 | private: |
| 72 | 72 | // Private methods |
| 73 | - void init_members(void); | |
| 74 | - void copy_members(const GFitsTableLongLongCol& column); | |
| 75 | - void free_members(void); | |
| 76 | - std::string ascii_format(void) const; | |
| 77 | - void alloc_data(void); | |
| 78 | - void release_data(void); | |
| 79 | - void alloc_nulval(const long long* value); | |
| 80 | - void init_data(void); | |
| 81 | - void* ptr_data(const int& index = 0) { return m_data+index; } | |
| 82 | - void* ptr_nulval(void) { return m_nulval; } | |
| 73 | + void init_members(void); | |
| 74 | + void copy_members(const GFitsTableLongLongCol& column); | |
| 75 | + void free_members(void); | |
| 76 | + void alloc_nulval(const long long* value); | |
| 77 | + | |
| 78 | + // Implemented virtual base class methods | |
| 79 | + virtual void alloc_data(void); | |
| 80 | + virtual void init_data(void); | |
| 81 | + virtual void fetch_data(void) const; | |
| 82 | + virtual void copy_data(const GFitsTableCol& column); | |
| 83 | + virtual void release_data(void); | |
| 84 | + virtual void* ptr_data(const int& index = 0) { return m_data+index; } | |
| 85 | + virtual void* ptr_nulval(void) { return m_nulval; } | |
| 86 | + virtual std::string ascii_format(void) const; | |
| 83 | 87 | |
| 84 | 88 | // Private data area |
| 85 | 89 | long long* m_data; //!< Data vector | ... | ... |
include/GFitsTableShortCol.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * GFitsTableShortCol.hpp - FITS table short column class * | |
| 2 | + * GFitsTableShortCol.hpp - FITS table short column class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2012 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2013 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -70,16 +70,20 @@ public: |
| 70 | 70 | |
| 71 | 71 | private: |
| 72 | 72 | // Private methods |
| 73 | - void init_members(void); | |
| 74 | - void copy_members(const GFitsTableShortCol& column); | |
| 75 | - void free_members(void); | |
| 76 | - std::string ascii_format(void) const; | |
| 77 | - void alloc_data(void); | |
| 78 | - void release_data(void); | |
| 79 | - void alloc_nulval(const short* value); | |
| 80 | - void init_data(void); | |
| 81 | - void* ptr_data(const int& index = 0) { return m_data+index; } | |
| 82 | - void* ptr_nulval(void) { return m_nulval; } | |
| 73 | + void init_members(void); | |
| 74 | + void copy_members(const GFitsTableShortCol& column); | |
| 75 | + void free_members(void); | |
| 76 | + void alloc_nulval(const short* value); | |
| 77 | + | |
| 78 | + // Implemented virtual base class methods | |
| 79 | + virtual void alloc_data(void); | |
| 80 | + virtual void init_data(void); | |
| 81 | + virtual void fetch_data(void) const; | |
| 82 | + virtual void copy_data(const GFitsTableCol& column); | |
| 83 | + virtual void release_data(void); | |
| 84 | + virtual void* ptr_data(const int& index = 0) { return m_data+index; } | |
| 85 | + virtual void* ptr_nulval(void) { return m_nulval; } | |
| 86 | + virtual std::string ascii_format(void) const; | |
| 83 | 87 | |
| 84 | 88 | // Private data area |
| 85 | 89 | short* m_data; //!< Data vector | ... | ... |
include/GFitsTableStringCol.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * GFitsTableStringCol.hpp - FITS table string column class * | |
| 2 | + * GFitsTableStringCol.hpp - FITS table string column class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2008-2012 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2008-2013 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -50,7 +50,7 @@ public: |
| 50 | 50 | virtual ~GFitsTableStringCol(void); |
| 51 | 51 | |
| 52 | 52 | // Operators |
| 53 | - GFitsTableStringCol& operator= (const GFitsTableStringCol& column); | |
| 53 | + GFitsTableStringCol& operator=(const GFitsTableStringCol& column); | |
| 54 | 54 | std::string& operator()(const int& row, const int& inx = 0); |
| 55 | 55 | const std::string& operator()(const int& row, const int& inx = 0) const; |
| 56 | 56 | |
| ... | ... | @@ -70,20 +70,25 @@ public: |
| 70 | 70 | |
| 71 | 71 | private: |
| 72 | 72 | // Private methods |
| 73 | - void init_members(void); | |
| 74 | - void copy_members(const GFitsTableStringCol& column); | |
| 75 | - void free_members(void); | |
| 76 | - void save(void); | |
| 77 | - std::string ascii_format(void) const; | |
| 78 | - void alloc_data(void); | |
| 79 | - void release_data(void); | |
| 80 | - void alloc_nulval(const std::string& value); | |
| 81 | - void init_data(void); | |
| 82 | - void fetch_data(void) const; | |
| 83 | - void alloc_buffer(void) const; | |
| 84 | - void free_buffer(void) const; | |
| 85 | - void* ptr_data(const int& index = 0) { return m_buffer+index; } | |
| 86 | - void* ptr_nulval(void) { return m_nulval; } | |
| 73 | + void init_members(void); | |
| 74 | + void copy_members(const GFitsTableStringCol& column); | |
| 75 | + void free_members(void); | |
| 76 | + void alloc_nulval(const std::string& value); | |
| 77 | + void alloc_buffer(void) const; | |
| 78 | + void free_buffer(void) const; | |
| 79 | + | |
| 80 | + // Implemented virtual base class methods | |
| 81 | + virtual void alloc_data(void); | |
| 82 | + virtual void init_data(void); | |
| 83 | + virtual void fetch_data(void) const; | |
| 84 | + virtual void copy_data(const GFitsTableCol& column); | |
| 85 | + virtual void release_data(void); | |
| 86 | + virtual void* ptr_data(const int& index = 0) { return m_data+index; } | |
| 87 | + virtual void* ptr_nulval(void) { return m_nulval; } | |
| 88 | + virtual std::string ascii_format(void) const; | |
| 89 | + | |
| 90 | + // Overloaded base class methods | |
| 91 | + virtual void save(void); | |
| 87 | 92 | |
| 88 | 93 | // Private data area |
| 89 | 94 | std::string* m_data; //!< Data area | ... | ... |
include/GFitsTableULongCol.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * GFitsTableULongCol.hpp - FITS table unsigned long column class * | |
| 2 | + * GFitsTableULongCol.hpp - FITS table unsigned long column class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2012 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2013 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -70,16 +70,20 @@ public: |
| 70 | 70 | |
| 71 | 71 | private: |
| 72 | 72 | // Private methods |
| 73 | - void init_members(void); | |
| 74 | - void copy_members(const GFitsTableULongCol& column); | |
| 75 | - void free_members(void); | |
| 76 | - std::string ascii_format(void) const; | |
| 77 | - void alloc_data(void); | |
| 78 | - void release_data(void); | |
| 79 | - void alloc_nulval(const unsigned long* value); | |
| 80 | - void init_data(void); | |
| 81 | - void* ptr_data(const int& index = 0) { return m_data+index; } | |
| 82 | - void* ptr_nulval(void) { return m_nulval; } | |
| 73 | + void init_members(void); | |
| 74 | + void copy_members(const GFitsTableULongCol& column); | |
| 75 | + void free_members(void); | |
| 76 | + void alloc_nulval(const unsigned long* value); | |
| 77 | + | |
| 78 | + // Implemented virtual base class methods | |
| 79 | + virtual void alloc_data(void); | |
| 80 | + virtual void init_data(void); | |
| 81 | + virtual void fetch_data(void) const; | |
| 82 | + virtual void copy_data(const GFitsTableCol& column); | |
| 83 | + virtual void release_data(void); | |
| 84 | + virtual void* ptr_data(const int& index = 0) { return m_data+index; } | |
| 85 | + virtual void* ptr_nulval(void) { return m_nulval; } | |
| 86 | + virtual std::string ascii_format(void) const; | |
| 83 | 87 | |
| 84 | 88 | // Private data area |
| 85 | 89 | unsigned long* m_data; //!< Data vector | ... | ... |
include/GFitsTableUShortCol.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * GFitsTableUShortCol.hpp - FITS table unsigned short column class * | |
| 2 | + * GFitsTableUShortCol.hpp - FITS table unsigned short column class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2012 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2013 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -70,16 +70,20 @@ public: |
| 70 | 70 | |
| 71 | 71 | private: |
| 72 | 72 | // Private methods |
| 73 | - void init_members(void); | |
| 74 | - void copy_members(const GFitsTableUShortCol& column); | |
| 75 | - void free_members(void); | |
| 76 | - std::string ascii_format(void) const; | |
| 77 | - void alloc_data(void); | |
| 78 | - void release_data(void); | |
| 79 | - void alloc_nulval(const unsigned short* value); | |
| 80 | - void init_data(void); | |
| 81 | - void* ptr_data(const int& index = 0) { return m_data+index; } | |
| 82 | - void* ptr_nulval(void) { return m_nulval; } | |
| 73 | + void init_members(void); | |
| 74 | + void copy_members(const GFitsTableUShortCol& column); | |
| 75 | + void free_members(void); | |
| 76 | + void alloc_nulval(const unsigned short* value); | |
| 77 | + | |
| 78 | + // Implemented virtual base class methods | |
| 79 | + virtual void alloc_data(void); | |
| 80 | + virtual void init_data(void); | |
| 81 | + virtual void fetch_data(void) const; | |
| 82 | + virtual void copy_data(const GFitsTableCol& column); | |
| 83 | + virtual void release_data(void); | |
| 84 | + virtual void* ptr_data(const int& index = 0) { return m_data+index; } | |
| 85 | + virtual void* ptr_nulval(void) { return m_nulval; } | |
| 86 | + virtual std::string ascii_format(void) const; | |
| 83 | 87 | |
| 84 | 88 | // Private data area |
| 85 | 89 | unsigned short* m_data; //!< Data vector | ... | ... |
pyext/GFitsTableCol.i
src/fits/GFits.cpp
| ... | ... | @@ -499,7 +499,7 @@ void GFits::append(const GFitsHDU& hdu) |
| 499 | 499 | // Debug header |
| 500 | 500 | #if DEBUG |
| 501 | 501 | std::cout << "GFits::append("; |
| 502 | - switch (hdu->exttype()) { | |
| 502 | + switch (hdu.exttype()) { | |
| 503 | 503 | case GFitsHDU::HT_IMAGE: |
| 504 | 504 | std::cout << "GFitsImage"; |
| 505 | 505 | break; | ... | ... |
src/fits/GFitsTable.cpp
| ... | ... | @@ -67,7 +67,7 @@ |
| 67 | 67 | /* __ Coding definitions _________________________________________________ */ |
| 68 | 68 | |
| 69 | 69 | /* __ Debug definitions __________________________________________________ */ |
| 70 | -//#define G_DEBUG_SAVE //!< Debug data_save() method | |
| 70 | +//#define G_DEBUG_SAVE //!< Debug data_save() method | |
| 71 | 71 | |
| 72 | 72 | |
| 73 | 73 | /*========================================================================== |
| ... | ... | @@ -848,6 +848,9 @@ void GFitsTable::data_save(void) |
| 848 | 848 | // Debug definition: Dump method entry |
| 849 | 849 | #if defined(G_DEBUG_SAVE) |
| 850 | 850 | std::cout << "GFitsTable::save: entry" << std::endl; |
| 851 | + for (int i = 0; i < m_cols; ++i) { | |
| 852 | + std::cout << m_columns[i]->print() << std::endl; | |
| 853 | + } | |
| 851 | 854 | #endif |
| 852 | 855 | |
| 853 | 856 | // Make sure that column lengths are consistent with table length. |
| ... | ... | @@ -901,8 +904,9 @@ void GFitsTable::data_save(void) |
| 901 | 904 | // Create FITS table |
| 902 | 905 | status = __ffcrtb(FPTR(m_fitsfile), m_type, m_rows, tfields, ttype, tform, |
| 903 | 906 | tunit, NULL, &status); |
| 904 | - if (status != 0) | |
| 907 | + if (status != 0) { | |
| 905 | 908 | throw GException::fits_error(G_DATA_SAVE, status); |
| 909 | + } | |
| 906 | 910 | |
| 907 | 911 | // De-allocate column definition arrays |
| 908 | 912 | if (m_cols > 0) { |
| ... | ... | @@ -1016,6 +1020,11 @@ void GFitsTable::data_save(void) |
| 1016 | 1020 | #endif |
| 1017 | 1021 | |
| 1018 | 1022 | } |
| 1023 | + | |
| 1024 | + // Debug option: Show where we are | |
| 1025 | + #if defined(G_DEBUG_SAVE) | |
| 1026 | + std::cout << "GFitsTable::save: Now update all columns." << std::endl; | |
| 1027 | + #endif | |
| 1019 | 1028 | |
| 1020 | 1029 | // Update all columns. The 'm_colnum' field specifies where in the |
| 1021 | 1030 | // FITS file the column resides. If 'm_colnum=0' then we have a new |
| ... | ... | @@ -1049,13 +1058,24 @@ void GFitsTable::data_save(void) |
| 1049 | 1058 | |
| 1050 | 1059 | // Now write column into FITS file (only if length is positive) |
| 1051 | 1060 | if (m_columns[i]->length() > 0) { |
| 1061 | + // Debug option: Show which column we're going to write | |
| 1062 | + #if defined(G_DEBUG_SAVE) | |
| 1063 | + std::cout << "GFitsTable::save: Write column " << i; | |
| 1064 | + std::cout << "." << std::endl; | |
| 1065 | + #endif | |
| 1052 | 1066 | m_columns[i]->save(); |
| 1053 | 1067 | } |
| 1054 | 1068 | |
| 1055 | 1069 | } // endif: column was valid |
| 1056 | 1070 | } // endfor: looped over all table columns |
| 1057 | 1071 | |
| 1058 | - // Delete all unused columns from FITS file. We do this from last to | |
| 1072 | + // Debug option: Show where we are | |
| 1073 | + #if defined(G_DEBUG_SAVE) | |
| 1074 | + std::cout << "GFitsTable::save: Now delete all obsolete columns."; | |
| 1075 | + std::cout << std::endl; | |
| 1076 | + #endif | |
| 1077 | + | |
| 1078 | + // Delete all obsolete columns from FITS file. We do this from last to | |
| 1059 | 1079 | // first so that the column numbers remain valid. Also note that |
| 1060 | 1080 | // FITS column counting starts from 1. |
| 1061 | 1081 | for (int colnum = num_cols; colnum > 0; --colnum) { |
| ... | ... | @@ -1103,6 +1123,12 @@ void GFitsTable::data_save(void) |
| 1103 | 1123 | |
| 1104 | 1124 | } // endelse: FITS table has been updated |
| 1105 | 1125 | |
| 1126 | + // Debug option: Show where we are | |
| 1127 | + #if defined(G_DEBUG_SAVE) | |
| 1128 | + std::cout << "GFitsTable::save: Now update the FITS header for all columns."; | |
| 1129 | + std::cout << std::endl; | |
| 1130 | + #endif | |
| 1131 | + | |
| 1106 | 1132 | // Now update the header for all columns (unit and TDIM information) |
| 1107 | 1133 | for (int i = 0; i < m_cols; ++i) { |
| 1108 | 1134 | ... | ... |
src/fits/GFitsTableBitCol.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GFitsTableBitCol.cpp - FITS table Bit column class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2008-2012 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2008-2013 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -46,6 +46,7 @@ |
| 46 | 46 | /* __ Coding definitions _________________________________________________ */ |
| 47 | 47 | |
| 48 | 48 | /* __ Debug definitions __________________________________________________ */ |
| 49 | +//#define G_CALL_GRAPH //!< Dump call graph in console | |
| 49 | 50 | |
| 50 | 51 | |
| 51 | 52 | /*========================================================================== |
| ... | ... | @@ -162,10 +163,10 @@ GFitsTableBitCol& GFitsTableBitCol::operator= (const GFitsTableBitCol& column) |
| 162 | 163 | * |
| 163 | 164 | * Provides access to data in a column. |
| 164 | 165 | ***************************************************************************/ |
| 165 | -bool& GFitsTableBitCol::operator() (const int& row, const int& inx) | |
| 166 | +bool& GFitsTableBitCol::operator()(const int& row, const int& inx) | |
| 166 | 167 | { |
| 167 | 168 | // If data are not available then load them now |
| 168 | - if (m_data == NULL) fetch_data(); | |
| 169 | + if (m_data == NULL) this->fetch_data(); | |
| 169 | 170 | |
| 170 | 171 | // Set any pending Bit |
| 171 | 172 | set_pending(); |
| ... | ... | @@ -192,7 +193,7 @@ bool& GFitsTableBitCol::operator() (const int& row, const int& inx) |
| 192 | 193 | * |
| 193 | 194 | * Provides access to data in a column. |
| 194 | 195 | ***************************************************************************/ |
| 195 | -const bool& GFitsTableBitCol::operator() (const int& row, const int& inx) const | |
| 196 | +const bool& GFitsTableBitCol::operator()(const int& row, const int& inx) const | |
| 196 | 197 | { |
| 197 | 198 | // Circumvent const correctness |
| 198 | 199 | GFitsTableBitCol* ptr = const_cast<GFitsTableBitCol*>(this); |
| ... | ... | @@ -537,6 +538,11 @@ void GFitsTableBitCol::nulval(const unsigned char* value) |
| 537 | 538 | ***************************************************************************/ |
| 538 | 539 | void GFitsTableBitCol::init_members(void) |
| 539 | 540 | { |
| 541 | + // Optionally print call graph | |
| 542 | + #if defined(G_CALL_GRAPH) | |
| 543 | + printf("GFitsTableBitCol::init_members\n"); | |
| 544 | + #endif | |
| 545 | + | |
| 540 | 546 | // Initialise members |
| 541 | 547 | m_type = __TBIT; |
| 542 | 548 | m_bits = 0; |
| ... | ... | @@ -549,6 +555,11 @@ void GFitsTableBitCol::init_members(void) |
| 549 | 555 | m_bit_byte = 0; |
| 550 | 556 | m_bit_mask = 0; |
| 551 | 557 | |
| 558 | + // Optionally print call graph | |
| 559 | + #if defined(G_CALL_GRAPH) | |
| 560 | + printf("exit GFitsTableBitCol::init_members\n"); | |
| 561 | + #endif | |
| 562 | + | |
| 552 | 563 | // Return |
| 553 | 564 | return; |
| 554 | 565 | } |
| ... | ... | @@ -561,7 +572,6 @@ void GFitsTableBitCol::init_members(void) |
| 561 | 572 | ***************************************************************************/ |
| 562 | 573 | void GFitsTableBitCol::copy_members(const GFitsTableBitCol& column) |
| 563 | 574 | { |
| 564 | - // Fetch column data if not yet fetched. The casting circumvents the | |
| 565 | 575 | // const correctness |
| 566 | 576 | bool not_loaded = (column.m_data == NULL); |
| 567 | 577 | if (not_loaded) { |
| ... | ... | @@ -571,6 +581,8 @@ void GFitsTableBitCol::copy_members(const GFitsTableBitCol& column) |
| 571 | 581 | // Copy attributes |
| 572 | 582 | m_type = column.m_type; |
| 573 | 583 | m_size = column.m_size; |
| 584 | + m_varlen = column.m_varlen; | |
| 585 | + m_rowstart = column.m_rowstart; | |
| 574 | 586 | m_bits = column.m_bits; |
| 575 | 587 | m_bytes_per_row = column.m_bytes_per_row; |
| 576 | 588 | m_bits_per_row = column.m_bits_per_row; |
| ... | ... | @@ -587,9 +599,6 @@ void GFitsTableBitCol::copy_members(const GFitsTableBitCol& column) |
| 587 | 599 | } |
| 588 | 600 | |
| 589 | 601 | // Copy NULL value |
| 590 | - alloc_nulval(column.m_nulval); | |
| 591 | - | |
| 592 | - // Small memory option: release column if it was fetch above | |
| 593 | 602 | #if defined(G_SMALL_MEMORY) |
| 594 | 603 | if (not_loaded) { |
| 595 | 604 | const_cast<GFitsTableBitCol*>(&column)->release_data(); |
| ... | ... | @@ -606,6 +615,11 @@ void GFitsTableBitCol::copy_members(const GFitsTableBitCol& column) |
| 606 | 615 | ***************************************************************************/ |
| 607 | 616 | void GFitsTableBitCol::free_members(void) |
| 608 | 617 | { |
| 618 | + // Optionally print call graph | |
| 619 | + #if defined(G_CALL_GRAPH) | |
| 620 | + printf("GFitsTableBitCol::free_members\n"); | |
| 621 | + #endif | |
| 622 | + | |
| 609 | 623 | // Free memory |
| 610 | 624 | if (m_data != NULL) delete [] m_data; |
| 611 | 625 | if (m_nulval != NULL) delete m_nulval; |
| ... | ... | @@ -617,6 +631,11 @@ void GFitsTableBitCol::free_members(void) |
| 617 | 631 | // Reset load flag |
| 618 | 632 | m_size = 0; |
| 619 | 633 | |
| 634 | + // Optionally print call graph | |
| 635 | + #if defined(G_CALL_GRAPH) | |
| 636 | + printf("exit GFitsTableBitCol::free_members\n"); | |
| 637 | + #endif | |
| 638 | + | |
| 620 | 639 | // Return |
| 621 | 640 | return; |
| 622 | 641 | } |
| ... | ... | @@ -646,6 +665,11 @@ std::string GFitsTableBitCol::ascii_format(void) const |
| 646 | 665 | ***************************************************************************/ |
| 647 | 666 | void GFitsTableBitCol::alloc_data(void) |
| 648 | 667 | { |
| 668 | + // Optionally print call graph | |
| 669 | + #if defined(G_CALL_GRAPH) | |
| 670 | + printf("GFitsTableBitCol::alloc_data(%d)\n", m_size); | |
| 671 | + #endif | |
| 672 | + | |
| 649 | 673 | // Free any existing memory |
| 650 | 674 | if (m_data != NULL) delete [] m_data; |
| 651 | 675 | |
| ... | ... | @@ -657,6 +681,63 @@ void GFitsTableBitCol::alloc_data(void) |
| 657 | 681 | m_data = new unsigned char[m_size]; |
| 658 | 682 | } |
| 659 | 683 | |
| 684 | + // Optionally print call graph | |
| 685 | + #if defined(G_CALL_GRAPH) | |
| 686 | + printf("exit GFitsTableBitCol::alloc_data(m_data=%x)\n", m_data); | |
| 687 | + #endif | |
| 688 | + | |
| 689 | + // Return | |
| 690 | + return; | |
| 691 | +} | |
| 692 | + | |
| 693 | + | |
| 694 | +/***********************************************************************//** | |
| 695 | + * @brief Fetch column data | |
| 696 | + * | |
| 697 | + * This method fetches column data when needed. It is declared const, so | |
| 698 | + * that const data access methods can be implemented. | |
| 699 | + * | |
| 700 | + * If a FITS file is attached to the column the data are loaded into memory | |
| 701 | + * from the FITS file. If no FITS file is attached, memory is allocated | |
| 702 | + * to hold the column data and all cells are initialised. | |
| 703 | + * | |
| 704 | + * This method calls GFitsTableCol::load_column to do the job. | |
| 705 | + ***************************************************************************/ | |
| 706 | +void GFitsTableBitCol::fetch_data(void) const | |
| 707 | +{ | |
| 708 | + // Save column (circumvent const correctness) | |
| 709 | + const_cast<GFitsTableBitCol*>(this)->load_column(); | |
| 710 | + | |
| 711 | + // Return | |
| 712 | + return; | |
| 713 | +} | |
| 714 | + | |
| 715 | + | |
| 716 | +/***********************************************************************//** | |
| 717 | + * @brief Copy column data | |
| 718 | + * | |
| 719 | + * @param[in] column Column. | |
| 720 | + * | |
| 721 | + * Copies all data from a column. This method is called from the base class | |
| 722 | + * copy constructor. | |
| 723 | + ***************************************************************************/ | |
| 724 | +void GFitsTableBitCol::copy_data(const GFitsTableCol& column) | |
| 725 | +{ | |
| 726 | + // Type-cast to the correct column type | |
| 727 | + const GFitsTableBitCol* ptr = static_cast<const GFitsTableBitCol*>(&column); | |
| 728 | + | |
| 729 | + // Copy column data (only if column contains data) | |
| 730 | + if (ptr->m_data != NULL && ptr->m_size > 0) { | |
| 731 | + m_size = ptr->m_size; | |
| 732 | + alloc_data(); | |
| 733 | + for (int i = 0; i < ptr->m_size; ++i) { | |
| 734 | + m_data[i] = ptr->m_data[i]; | |
| 735 | + } | |
| 736 | + } | |
| 737 | + | |
| 738 | + // Copy NULL value | |
| 739 | + alloc_nulval(ptr->m_nulval); | |
| 740 | + | |
| 660 | 741 | // Return |
| 661 | 742 | return; |
| 662 | 743 | } | ... | ... |
src/fits/GFitsTableBoolCol.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * GFitsTableBoolCol.cpp - FITS table boolean column class * | |
| 2 | + * GFitsTableBoolCol.cpp - FITS table boolean column class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | 4 | * copyright (C) 2010-2013 by Juergen Knoedlseder * |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| ... | ... | @@ -521,8 +521,10 @@ void GFitsTableBoolCol::copy_members(const GFitsTableBoolCol& column) |
| 521 | 521 | } |
| 522 | 522 | |
| 523 | 523 | // Copy attributes |
| 524 | - m_type = column.m_type; | |
| 525 | - m_size = column.m_size; | |
| 524 | + m_type = column.m_type; | |
| 525 | + m_size = column.m_size; | |
| 526 | + m_varlen = column.m_varlen; | |
| 527 | + m_rowstart = column.m_rowstart; | |
| 526 | 528 | |
| 527 | 529 | // Copy column data |
| 528 | 530 | if (column.m_data != NULL && m_size > 0) { |
| ... | ... | @@ -645,6 +647,75 @@ void GFitsTableBoolCol::alloc_data(void) |
| 645 | 647 | |
| 646 | 648 | |
| 647 | 649 | /***********************************************************************//** |
| 650 | + * @brief Fetch column data | |
| 651 | + * | |
| 652 | + * If a FITS file is attached to the column the data are loaded into memory | |
| 653 | + * from the FITS file. If no FITS file is attached, memory is allocated | |
| 654 | + * to hold the column data and all cells are set to 0. | |
| 655 | + * | |
| 656 | + * Refer to GFitsTableCol::load_column for more information. | |
| 657 | + ***************************************************************************/ | |
| 658 | +void GFitsTableBoolCol::fetch_data(void) const | |
| 659 | +{ | |
| 660 | + // Calculate size of memory | |
| 661 | + m_size = m_number * m_length; | |
| 662 | + | |
| 663 | + // Free old buffer memory | |
| 664 | + free_buffer(); | |
| 665 | + //const_cast<GFitsTableBoolCol*>(this)->free_buffer(); | |
| 666 | + | |
| 667 | + // Allocate buffer memory | |
| 668 | + //const_cast<GFitsTableBoolCol*>(this)->alloc_buffer(); | |
| 669 | + alloc_buffer(); | |
| 670 | + | |
| 671 | + // Save column | |
| 672 | + const_cast<GFitsTableBoolCol*>(this)->load_column(); | |
| 673 | + | |
| 674 | + // Extract values from buffer | |
| 675 | + for (int i = 0; i < m_size; ++i) { | |
| 676 | + m_data[i] = (bool)m_buffer[i]; | |
| 677 | + } | |
| 678 | + | |
| 679 | + // Free buffer memory | |
| 680 | + //const_cast<GFitsTableBoolCol*>(this)->free_buffer(); | |
| 681 | + free_buffer(); | |
| 682 | + | |
| 683 | + // Return | |
| 684 | + return; | |
| 685 | +} | |
| 686 | + | |
| 687 | + | |
| 688 | +/***********************************************************************//** | |
| 689 | + * @brief Copy column data | |
| 690 | + * | |
| 691 | + * @param[in] column Column. | |
| 692 | + * | |
| 693 | + * Copies all data from a column. This method is called from the base class | |
| 694 | + * copy constructor. | |
| 695 | + ***************************************************************************/ | |
| 696 | +void GFitsTableBoolCol::copy_data(const GFitsTableCol& column) | |
| 697 | +{ | |
| 698 | + // Type-cast to the correct column type | |
| 699 | + const GFitsTableBoolCol* ptr = static_cast<const GFitsTableBoolCol*>(&column); | |
| 700 | + | |
| 701 | + // Copy column data (only if column contains data) | |
| 702 | + if (ptr->m_data != NULL && ptr->m_size > 0) { | |
| 703 | + m_size = ptr->m_size; | |
| 704 | + alloc_data(); | |
| 705 | + for (int i = 0; i < ptr->m_size; ++i) { | |
| 706 | + m_data[i] = ptr->m_data[i]; | |
| 707 | + } | |
| 708 | + } | |
| 709 | + | |
| 710 | + // Copy NULL value | |
| 711 | + alloc_nulval(ptr->m_nulval); | |
| 712 | + | |
| 713 | + // Return | |
| 714 | + return; | |
| 715 | +} | |
| 716 | + | |
| 717 | + | |
| 718 | +/***********************************************************************//** | |
| 648 | 719 | * @brief Release column data |
| 649 | 720 | ***************************************************************************/ |
| 650 | 721 | void GFitsTableBoolCol::release_data(void) |
| ... | ... | @@ -701,48 +772,12 @@ void GFitsTableBoolCol::init_data(void) |
| 701 | 772 | |
| 702 | 773 | |
| 703 | 774 | /***********************************************************************//** |
| 704 | - * @brief Fetch column data | |
| 705 | - * | |
| 706 | - * If a FITS file is attached to the column the data are loaded into memory | |
| 707 | - * from the FITS file. If no FITS file is attached, memory is allocated | |
| 708 | - * to hold the column data and all cells are set to 0. | |
| 709 | - * | |
| 710 | - * Refer to GFitsTableCol::load_column for more information. | |
| 711 | - ***************************************************************************/ | |
| 712 | -void GFitsTableBoolCol::fetch_data(void) const | |
| 713 | -{ | |
| 714 | - // Calculate size of memory | |
| 715 | - m_size = m_number * m_length; | |
| 716 | - | |
| 717 | - // Free old buffer memory | |
| 718 | - const_cast<GFitsTableBoolCol*>(this)->free_buffer(); | |
| 719 | - | |
| 720 | - // Allocate buffer memory | |
| 721 | - const_cast<GFitsTableBoolCol*>(this)->alloc_buffer(); | |
| 722 | - | |
| 723 | - // Save column | |
| 724 | - const_cast<GFitsTableBoolCol*>(this)->load_column(); | |
| 725 | - | |
| 726 | - // Extract values from buffer | |
| 727 | - for (int i = 0; i < m_size; ++i) { | |
| 728 | - m_data[i] = (bool)m_buffer[i]; | |
| 729 | - } | |
| 730 | - | |
| 731 | - // Free buffer memory | |
| 732 | - const_cast<GFitsTableBoolCol*>(this)->free_buffer(); | |
| 733 | - | |
| 734 | - // Return | |
| 735 | - return; | |
| 736 | -} | |
| 737 | - | |
| 738 | - | |
| 739 | -/***********************************************************************//** | |
| 740 | 775 | * @brief Allocate CFITSIO transfer buffer |
| 741 | 776 | * |
| 742 | 777 | * The CFITSIO transfer buffer allows transparent conversion from the CFITSIO |
| 743 | 778 | * storage format to a vector of bool values. |
| 744 | 779 | ***************************************************************************/ |
| 745 | -void GFitsTableBoolCol::alloc_buffer(void) | |
| 780 | +void GFitsTableBoolCol::alloc_buffer(void) const | |
| 746 | 781 | { |
| 747 | 782 | // Allocate and initialise buffer memory |
| 748 | 783 | if (m_size > 0) { |
| ... | ... | @@ -762,7 +797,7 @@ void GFitsTableBoolCol::alloc_buffer(void) |
| 762 | 797 | * |
| 763 | 798 | * Release memory that has been allocated for the CFITSIO transfer buffer. |
| 764 | 799 | ***************************************************************************/ |
| 765 | -void GFitsTableBoolCol::free_buffer(void) | |
| 800 | +void GFitsTableBoolCol::free_buffer(void) const | |
| 766 | 801 | { |
| 767 | 802 | // Free buffer |
| 768 | 803 | if (m_buffer != NULL) delete [] m_buffer; |
| ... | ... | @@ -773,10 +808,3 @@ void GFitsTableBoolCol::free_buffer(void) |
| 773 | 808 | // Return |
| 774 | 809 | return; |
| 775 | 810 | } |
| 776 | - | |
| 777 | - | |
| 778 | -/*========================================================================== | |
| 779 | - = = | |
| 780 | - = Friends = | |
| 781 | - = = | |
| 782 | - ==========================================================================*/ | ... | ... |
src/fits/GFitsTableByteCol.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * GFitsTableByteCol.cpp - FITS table Byte column class * | |
| 2 | + * GFitsTableByteCol.cpp - FITS table Byte column class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | 4 | * copyright (C) 2010-2013 by Juergen Knoedlseder * |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| ... | ... | @@ -526,8 +526,10 @@ void GFitsTableByteCol::copy_members(const GFitsTableByteCol& column) |
| 526 | 526 | } |
| 527 | 527 | |
| 528 | 528 | // Copy attributes |
| 529 | - m_type = column.m_type; | |
| 530 | - m_size = column.m_size; | |
| 529 | + m_type = column.m_type; | |
| 530 | + m_size = column.m_size; | |
| 531 | + m_varlen = column.m_varlen; | |
| 532 | + m_rowstart = column.m_rowstart; | |
| 531 | 533 | |
| 532 | 534 | // Copy column data |
| 533 | 535 | if (column.m_data != NULL && m_size > 0) { |
| ... | ... | @@ -611,6 +613,49 @@ void GFitsTableByteCol::alloc_data(void) |
| 611 | 613 | |
| 612 | 614 | |
| 613 | 615 | /***********************************************************************//** |
| 616 | + * @brief Fetch column data | |
| 617 | + ***************************************************************************/ | |
| 618 | +void GFitsTableByteCol::fetch_data(void) const | |
| 619 | +{ | |
| 620 | + // Save column (circumvent const correctness) | |
| 621 | + const_cast<GFitsTableByteCol*>(this)->load_column(); | |
| 622 | + | |
| 623 | + // Return | |
| 624 | + return; | |
| 625 | +} | |
| 626 | + | |
| 627 | + | |
| 628 | +/***********************************************************************//** | |
| 629 | + * @brief Copy column data | |
| 630 | + * | |
| 631 | + * @param[in] column Column. | |
| 632 | + * | |
| 633 | + * Copies all data from a column. This method is called from the base class | |
| 634 | + * copy constructor. | |
| 635 | + ***************************************************************************/ | |
| 636 | +void GFitsTableByteCol::copy_data(const GFitsTableCol& column) | |
| 637 | +{ | |
| 638 | + // Type-cast to the correct column type | |
| 639 | + const GFitsTableByteCol* ptr = static_cast<const GFitsTableByteCol*>(&column); | |
| 640 | + | |
| 641 | + // Copy column data (only if column contains data) | |
| 642 | + if (ptr->m_data != NULL && ptr->m_size > 0) { | |
| 643 | + m_size = ptr->m_size; | |
| 644 | + alloc_data(); | |
| 645 | + for (int i = 0; i < ptr->m_size; ++i) { | |
| 646 | + m_data[i] = ptr->m_data[i]; | |
| 647 | + } | |
| 648 | + } | |
| 649 | + | |
| 650 | + // Copy NULL value | |
| 651 | + alloc_nulval(ptr->m_nulval); | |
| 652 | + | |
| 653 | + // Return | |
| 654 | + return; | |
| 655 | +} | |
| 656 | + | |
| 657 | + | |
| 658 | +/***********************************************************************//** | |
| 614 | 659 | * @brief Release column data |
| 615 | 660 | ***************************************************************************/ |
| 616 | 661 | void GFitsTableByteCol::release_data(void) | ... | ... |
src/fits/GFitsTableCDoubleCol.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * GFitsTableCDoubleCol.cpp - FITS table double precision complex column * | |
| 2 | + * GFitsTableCDoubleCol.cpp - FITS table double precision complex column * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | 4 | * copyright (C) 2010-2013 by Juergen Knoedlseder * |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| ... | ... | @@ -528,8 +528,10 @@ void GFitsTableCDoubleCol::copy_members(const GFitsTableCDoubleCol& column) |
| 528 | 528 | } |
| 529 | 529 | |
| 530 | 530 | // Copy attributes |
| 531 | - m_type = column.m_type; | |
| 532 | - m_size = column.m_size; | |
| 531 | + m_type = column.m_type; | |
| 532 | + m_size = column.m_size; | |
| 533 | + m_varlen = column.m_varlen; | |
| 534 | + m_rowstart = column.m_rowstart; | |
| 533 | 535 | |
| 534 | 536 | // Copy column data |
| 535 | 537 | if (column.m_data != NULL && m_size > 0) { |
| ... | ... | @@ -616,6 +618,49 @@ void GFitsTableCDoubleCol::alloc_data(void) |
| 616 | 618 | |
| 617 | 619 | |
| 618 | 620 | /***********************************************************************//** |
| 621 | + * @brief Fetch column data | |
| 622 | + ***************************************************************************/ | |
| 623 | +void GFitsTableCDoubleCol::fetch_data(void) const | |
| 624 | +{ | |
| 625 | + // Save column (circumvent const correctness) | |
| 626 | + const_cast<GFitsTableCDoubleCol*>(this)->load_column(); | |
| 627 | + | |
| 628 | + // Return | |
| 629 | + return; | |
| 630 | +} | |
| 631 | + | |
| 632 | + | |
| 633 | +/***********************************************************************//** | |
| 634 | + * @brief Copy column data | |
| 635 | + * | |
| 636 | + * @param[in] column Column. | |
| 637 | + * | |
| 638 | + * Copies all data from a column. This method is called from the base class | |
| 639 | + * copy constructor. | |
| 640 | + ***************************************************************************/ | |
| 641 | +void GFitsTableCDoubleCol::copy_data(const GFitsTableCol& column) | |
| 642 | +{ | |
| 643 | + // Type-cast to the correct column type | |
| 644 | + const GFitsTableCDoubleCol* ptr = static_cast<const GFitsTableCDoubleCol*>(&column); | |
| 645 | + | |
| 646 | + // Copy column data (only if column contains data) | |
| 647 | + if (ptr->m_data != NULL && ptr->m_size > 0) { | |
| 648 | + m_size = ptr->m_size; | |
| 649 | + alloc_data(); | |
| 650 | + for (int i = 0; i < ptr->m_size; ++i) { | |
| 651 | + m_data[i] = ptr->m_data[i]; | |
| 652 | + } | |
| 653 | + } | |
| 654 | + | |
| 655 | + // Copy NULL value | |
| 656 | + alloc_nulval(ptr->m_nulval); | |
| 657 | + | |
| 658 | + // Return | |
| 659 | + return; | |
| 660 | +} | |
| 661 | + | |
| 662 | + | |
| 663 | +/***********************************************************************//** | |
| 619 | 664 | * @brief Release column data |
| 620 | 665 | ***************************************************************************/ |
| 621 | 666 | void GFitsTableCDoubleCol::release_data(void) | ... | ... |
src/fits/GFitsTableCFloatCol.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * GFitsTableCFloatCol.cpp - FITS table single precision complex column * | |
| 2 | + * GFitsTableCFloatCol.cpp - FITS table single precision complex column * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | 4 | * copyright (C) 2010-2013 by Juergen Knoedlseder * |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| ... | ... | @@ -528,8 +528,10 @@ void GFitsTableCFloatCol::copy_members(const GFitsTableCFloatCol& column) |
| 528 | 528 | } |
| 529 | 529 | |
| 530 | 530 | // Copy attributes |
| 531 | - m_type = column.m_type; | |
| 532 | - m_size = column.m_size; | |
| 531 | + m_type = column.m_type; | |
| 532 | + m_size = column.m_size; | |
| 533 | + m_varlen = column.m_varlen; | |
| 534 | + m_rowstart = column.m_rowstart; | |
| 533 | 535 | |
| 534 | 536 | // Copy column data |
| 535 | 537 | if (column.m_data != NULL && m_size > 0) { |
| ... | ... | @@ -616,6 +618,49 @@ void GFitsTableCFloatCol::alloc_data(void) |
| 616 | 618 | |
| 617 | 619 | |
| 618 | 620 | /***********************************************************************//** |
| 621 | + * @brief Fetch column data | |
| 622 | + ***************************************************************************/ | |
| 623 | +void GFitsTableCFloatCol::fetch_data(void) const | |
| 624 | +{ | |
| 625 | + // Save column (circumvent const correctness) | |
| 626 | + const_cast<GFitsTableCFloatCol*>(this)->load_column(); | |
| 627 | + | |
| 628 | + // Return | |
| 629 | + return; | |
| 630 | +} | |
| 631 | + | |
| 632 | + | |
| 633 | +/***********************************************************************//** | |
| 634 | + * @brief Copy column data | |
| 635 | + * | |
| 636 | + * @param[in] column Column. | |
| 637 | + * | |
| 638 | + * Copies all data from a column. This method is called from the base class | |
| 639 | + * copy constructor. | |
| 640 | + ***************************************************************************/ | |
| 641 | +void GFitsTableCFloatCol::copy_data(const GFitsTableCol& column) | |
| 642 | +{ | |
| 643 | + // Type-cast to the correct column type | |
| 644 | + const GFitsTableCFloatCol* ptr = static_cast<const GFitsTableCFloatCol*>(&column); | |
| 645 | + | |
| 646 | + // Copy column data (only if column contains data) | |
| 647 | + if (ptr->m_data != NULL && ptr->m_size > 0) { | |
| 648 | + m_size = ptr->m_size; | |
| 649 | + alloc_data(); | |
| 650 | + for (int i = 0; i < ptr->m_size; ++i) { | |
| 651 | + m_data[i] = ptr->m_data[i]; | |
| 652 | + } | |
| 653 | + } | |
| 654 | + | |
| 655 | + // Copy NULL value | |
| 656 | + alloc_nulval(ptr->m_nulval); | |
| 657 | + | |
| 658 | + // Return | |
| 659 | + return; | |
| 660 | +} | |
| 661 | + | |
| 662 | + | |
| 663 | +/***********************************************************************//** | |
| 619 | 664 | * @brief Release column data |
| 620 | 665 | ***************************************************************************/ |
| 621 | 666 | void GFitsTableCFloatCol::release_data(void) | ... | ... |
src/fits/GFitsTableCol.cpp
| ... | ... | @@ -44,6 +44,7 @@ |
| 44 | 44 | /* __ Coding definitions _________________________________________________ */ |
| 45 | 45 | |
| 46 | 46 | /* __ Debug definitions __________________________________________________ */ |
| 47 | +//#define G_CALL_GRAPH //!< Dump call graph in console | |
| 47 | 48 | |
| 48 | 49 | |
| 49 | 50 | /*========================================================================== |
| ... | ... | @@ -309,6 +310,21 @@ std::string GFitsTableCol::tform_binary(void) const |
| 309 | 310 | |
| 310 | 311 | |
| 311 | 312 | /***********************************************************************//** |
| 313 | + * @brief Signals if column has already been loaded | |
| 314 | + * | |
| 315 | + * @return True if column has been loaded, false otherwise. | |
| 316 | + ***************************************************************************/ | |
| 317 | +bool GFitsTableCol::isloaded(void) const | |
| 318 | +{ | |
| 319 | + // Circumvent const correctness | |
| 320 | + GFitsTableCol* column = const_cast<GFitsTableCol*>(this); | |
| 321 | + | |
| 322 | + // Return flag | |
| 323 | + return (column->ptr_data() != NULL); | |
| 324 | +} | |
| 325 | + | |
| 326 | + | |
| 327 | +/***********************************************************************//** | |
| 312 | 328 | * @brief Print column information |
| 313 | 329 | * |
| 314 | 330 | * @param[in] chatter Chattiness (defaults to NORMAL). |
| ... | ... | @@ -431,6 +447,7 @@ void GFitsTableCol::save(void) |
| 431 | 447 | * |
| 432 | 448 | * This method calls GFitsTableCol::load_column to do the job. |
| 433 | 449 | ***************************************************************************/ |
| 450 | +/* | |
| 434 | 451 | void GFitsTableCol::fetch_data(void) const |
| 435 | 452 | { |
| 436 | 453 | // Save column (circumvent const correctness) |
| ... | ... | @@ -439,14 +456,18 @@ void GFitsTableCol::fetch_data(void) const |
| 439 | 456 | // Return |
| 440 | 457 | return; |
| 441 | 458 | } |
| 442 | - | |
| 459 | +*/ | |
| 443 | 460 | |
| 444 | 461 | /***********************************************************************//** |
| 445 | 462 | * @brief Load table column from FITS file |
| 463 | + * | |
| 464 | + * Loads table column from FITS file by calling the load_column_variable() | |
| 465 | + * method for variable-length columns and load_column_fixed() for fixed- | |
| 466 | + * length columns. | |
| 446 | 467 | ***************************************************************************/ |
| 447 | 468 | void GFitsTableCol::load_column(void) |
| 448 | 469 | { |
| 449 | - // Load variable-length of fixed-length column | |
| 470 | + // Load variable-length or fixed-length column from FITS file | |
| 450 | 471 | if (isvariable()) { |
| 451 | 472 | load_column_variable(); |
| 452 | 473 | } |
| ... | ... | @@ -664,6 +685,28 @@ void GFitsTableCol::load_column_variable(void) |
| 664 | 685 | /***********************************************************************//** |
| 665 | 686 | * @brief Save table column into FITS file |
| 666 | 687 | * |
| 688 | + * Save table column into FITS file by calling the save_column_variable() | |
| 689 | + * method for variable-length columns and save_column_fixed() for fixed- | |
| 690 | + * length columns. | |
| 691 | + ***************************************************************************/ | |
| 692 | +void GFitsTableCol::save_column(void) | |
| 693 | +{ | |
| 694 | + // Save variable-length or fixed-length column into FITS file | |
| 695 | + if (isvariable()) { | |
| 696 | + save_column_variable(); | |
| 697 | + } | |
| 698 | + else { | |
| 699 | + save_column_fixed(); | |
| 700 | + } | |
| 701 | + | |
| 702 | + // Return | |
| 703 | + return; | |
| 704 | +} | |
| 705 | + | |
| 706 | + | |
| 707 | +/***********************************************************************//** | |
| 708 | + * @brief Save table column into FITS file | |
| 709 | + * | |
| 667 | 710 | * @exception GException::fits_hdu_not_found |
| 668 | 711 | * Specified HDU not found in FITS file. |
| 669 | 712 | * @exception GException::fits_error |
| ... | ... | @@ -679,7 +722,7 @@ void GFitsTableCol::load_column_variable(void) |
| 679 | 722 | * These methods are implemented by the derived column classes which |
| 680 | 723 | * implement a specific storage class (i.e. float, double, short, ...). |
| 681 | 724 | ***************************************************************************/ |
| 682 | -void GFitsTableCol::save_column(void) | |
| 725 | +void GFitsTableCol::save_column_fixed(void) | |
| 683 | 726 | { |
| 684 | 727 | // Continue only if a FITS file is connected and data have been loaded |
| 685 | 728 | if (FPTR(m_fitsfile)->Fptr != NULL && m_colnum > 0 && ptr_data() != NULL) { |
| ... | ... | @@ -710,6 +753,67 @@ void GFitsTableCol::save_column(void) |
| 710 | 753 | |
| 711 | 754 | |
| 712 | 755 | /***********************************************************************//** |
| 756 | + * @brief Save table column into FITS file | |
| 757 | + * | |
| 758 | + * @exception GException::fits_hdu_not_found | |
| 759 | + * Specified HDU not found in FITS file. | |
| 760 | + * @exception GException::fits_error | |
| 761 | + * Error occured during writing of the column data. | |
| 762 | + * | |
| 763 | + * The table column is only saved if it is linked to a FITS file and if the | |
| 764 | + * data are indeed present in the class instance. This avoids saving of data | |
| 765 | + * that have not been modified. | |
| 766 | + * | |
| 767 | + * The method make use of the virtual methods | |
| 768 | + * GFitsTableCol::ptr_data and | |
| 769 | + * GFitsTableCol::ptr_nulval. | |
| 770 | + * These methods are implemented by the derived column classes which | |
| 771 | + * implement a specific storage class (i.e. float, double, short, ...). | |
| 772 | + ***************************************************************************/ | |
| 773 | +void GFitsTableCol::save_column_variable(void) | |
| 774 | +{ | |
| 775 | + // Continue only if a FITS file is connected and data have been loaded | |
| 776 | + if (FPTR(m_fitsfile)->Fptr != NULL && m_colnum > 0 && ptr_data() != NULL) { | |
| 777 | + | |
| 778 | + // Move to the HDU | |
| 779 | + int status = 0; | |
| 780 | + status = __ffmahd(FPTR(m_fitsfile), | |
| 781 | + (FPTR(m_fitsfile)->HDUposition)+1, NULL, | |
| 782 | + &status); | |
| 783 | + if (status != 0) { | |
| 784 | + throw GException::fits_hdu_not_found(G_SAVE_COLUMN, | |
| 785 | + (FPTR(m_fitsfile)->HDUposition)+1, | |
| 786 | + status); | |
| 787 | + } | |
| 788 | + | |
| 789 | + // Save the column data row-by-row | |
| 790 | + for (int row = 0; row < m_length; ++row) { | |
| 791 | + | |
| 792 | + // Save row data | |
| 793 | + status = __ffpcn(FPTR(m_fitsfile), | |
| 794 | + std::abs(m_type), | |
| 795 | + m_colnum, | |
| 796 | + row+1, | |
| 797 | + 1, | |
| 798 | + elements(row), | |
| 799 | + ptr_data(m_rowstart[row]), | |
| 800 | + ptr_nulval(), | |
| 801 | + &status); | |
| 802 | + if (status != 0) { | |
| 803 | + throw GException::fits_error(G_SAVE_COLUMN, status, | |
| 804 | + "for column \""+m_name+"\"."); | |
| 805 | + } | |
| 806 | + | |
| 807 | + } // endfor: looped over rows | |
| 808 | + | |
| 809 | + } // endif: FITS file was connected | |
| 810 | + | |
| 811 | + // Return | |
| 812 | + return; | |
| 813 | +} | |
| 814 | + | |
| 815 | + | |
| 816 | +/***********************************************************************//** | |
| 713 | 817 | * @brief Compute offset of column element in memory |
| 714 | 818 | * |
| 715 | 819 | * @param[in] row Row of column. |
| ... | ... | @@ -757,6 +861,11 @@ int GFitsTableCol::offset(const int& row, const int& inx) const |
| 757 | 861 | ***************************************************************************/ |
| 758 | 862 | void GFitsTableCol::init_members(void) |
| 759 | 863 | { |
| 864 | + // Optionally print call graph | |
| 865 | + #if defined(G_CALL_GRAPH) | |
| 866 | + printf("GFitsTableCol::init_members\n"); | |
| 867 | + #endif | |
| 868 | + | |
| 760 | 869 | // Allocate FITS file pointer |
| 761 | 870 | m_fitsfile = new __fitsfile; |
| 762 | 871 | FPTR(m_fitsfile)->HDUposition = 0; |
| ... | ... | @@ -778,6 +887,11 @@ void GFitsTableCol::init_members(void) |
| 778 | 887 | m_size = 0; |
| 779 | 888 | m_anynul = 0; |
| 780 | 889 | |
| 890 | + // Optionally print call graph | |
| 891 | + #if defined(G_CALL_GRAPH) | |
| 892 | + printf("exit GFitsTableCol::init_members\n"); | |
| 893 | + #endif | |
| 894 | + | |
| 781 | 895 | // Return |
| 782 | 896 | return; |
| 783 | 897 | } |
| ... | ... | @@ -817,12 +931,22 @@ void GFitsTableCol::copy_members(const GFitsTableCol& column) |
| 817 | 931 | ***************************************************************************/ |
| 818 | 932 | void GFitsTableCol::free_members(void) |
| 819 | 933 | { |
| 934 | + // Optionally print call graph | |
| 935 | + #if defined(G_CALL_GRAPH) | |
| 936 | + printf("GFitsTableCol::free_members\n"); | |
| 937 | + #endif | |
| 938 | + | |
| 820 | 939 | // Free memory |
| 821 | 940 | if (m_fitsfile != NULL) delete FPTR(m_fitsfile); |
| 822 | 941 | |
| 823 | 942 | // Mark memory as free |
| 824 | 943 | m_fitsfile = NULL; |
| 825 | 944 | |
| 945 | + // Optionally print call graph | |
| 946 | + #if defined(G_CALL_GRAPH) | |
| 947 | + printf("exit GFitsTableCol::free_members\n"); | |
| 948 | + #endif | |
| 949 | + | |
| 826 | 950 | // Return |
| 827 | 951 | return; |
| 828 | 952 | } | ... | ... |
src/fits/GFitsTableDoubleCol.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * GFitsTableDoubleCol.cpp - FITS table double column class * | |
| 2 | + * GFitsTableDoubleCol.cpp - FITS table double column class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | 4 | * copyright (C) 2010-2013 by Juergen Knoedlseder * |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| ... | ... | @@ -526,8 +526,10 @@ void GFitsTableDoubleCol::copy_members(const GFitsTableDoubleCol& column) |
| 526 | 526 | } |
| 527 | 527 | |
| 528 | 528 | // Copy attributes |
| 529 | - m_type = column.m_type; | |
| 530 | - m_size = column.m_size; | |
| 529 | + m_type = column.m_type; | |
| 530 | + m_size = column.m_size; | |
| 531 | + m_varlen = column.m_varlen; | |
| 532 | + m_rowstart = column.m_rowstart; | |
| 531 | 533 | |
| 532 | 534 | // Copy column data |
| 533 | 535 | if (column.m_data != NULL && m_size > 0) { |
| ... | ... | @@ -614,6 +616,49 @@ void GFitsTableDoubleCol::alloc_data(void) |
| 614 | 616 | |
| 615 | 617 | |
| 616 | 618 | /***********************************************************************//** |
| 619 | + * @brief Fetch column data | |
| 620 | + ***************************************************************************/ | |
| 621 | +void GFitsTableDoubleCol::fetch_data(void) const | |
| 622 | +{ | |
| 623 | + // Save column (circumvent const correctness) | |
| 624 | + const_cast<GFitsTableDoubleCol*>(this)->load_column(); | |
| 625 | + | |
| 626 | + // Return | |
| 627 | + return; | |
| 628 | +} | |
| 629 | + | |
| 630 | + | |
| 631 | +/***********************************************************************//** | |
| 632 | + * @brief Copy column data | |
| 633 | + * | |
| 634 | + * @param[in] column Column. | |
| 635 | + * | |
| 636 | + * Copies all data from a column. This method is called from the base class | |
| 637 | + * copy constructor. | |
| 638 | + ***************************************************************************/ | |
| 639 | +void GFitsTableDoubleCol::copy_data(const GFitsTableCol& column) | |
| 640 | +{ | |
| 641 | + // Type-cast to the correct column type | |
| 642 | + const GFitsTableDoubleCol* ptr = static_cast<const GFitsTableDoubleCol*>(&column); | |
| 643 | + | |
| 644 | + // Copy column data (only if column contains data) | |
| 645 | + if (ptr->m_data != NULL && ptr->m_size > 0) { | |
| 646 | + m_size = ptr->m_size; | |
| 647 | + alloc_data(); | |
| 648 | + for (int i = 0; i < ptr->m_size; ++i) { | |
| 649 | + m_data[i] = ptr->m_data[i]; | |
| 650 | + } | |
| 651 | + } | |
| 652 | + | |
| 653 | + // Copy NULL value | |
| 654 | + alloc_nulval(ptr->m_nulval); | |
| 655 | + | |
| 656 | + // Return | |
| 657 | + return; | |
| 658 | +} | |
| 659 | + | |
| 660 | + | |
| 661 | +/***********************************************************************//** | |
| 617 | 662 | * @brief Release column data |
| 618 | 663 | ***************************************************************************/ |
| 619 | 664 | void GFitsTableDoubleCol::release_data(void) | ... | ... |
src/fits/GFitsTableFloatCol.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * GFitsTableFloatCol.cpp - FITS table float column class * | |
| 2 | + * GFitsTableFloatCol.cpp - FITS table float column class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | 4 | * copyright (C) 2010-2013 by Juergen Knoedlseder * |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| ... | ... | @@ -127,7 +127,7 @@ GFitsTableFloatCol::~GFitsTableFloatCol(void) |
| 127 | 127 | * |
| 128 | 128 | * @param[in] column Table column. |
| 129 | 129 | ***************************************************************************/ |
| 130 | -GFitsTableFloatCol& GFitsTableFloatCol::operator= (const GFitsTableFloatCol& column) | |
| 130 | +GFitsTableFloatCol& GFitsTableFloatCol::operator=(const GFitsTableFloatCol& column) | |
| 131 | 131 | { |
| 132 | 132 | // Execute only if object is not identical |
| 133 | 133 | if (this != &column) { |
| ... | ... | @@ -526,8 +526,10 @@ void GFitsTableFloatCol::copy_members(const GFitsTableFloatCol& column) |
| 526 | 526 | } |
| 527 | 527 | |
| 528 | 528 | // Copy attributes |
| 529 | - m_type = column.m_type; | |
| 530 | - m_size = column.m_size; | |
| 529 | + m_type = column.m_type; | |
| 530 | + m_size = column.m_size; | |
| 531 | + m_varlen = column.m_varlen; | |
| 532 | + m_rowstart = column.m_rowstart; | |
| 531 | 533 | |
| 532 | 534 | // Copy column data |
| 533 | 535 | if (column.m_data != NULL && m_size > 0) { |
| ... | ... | @@ -614,6 +616,49 @@ void GFitsTableFloatCol::alloc_data(void) |
| 614 | 616 | |
| 615 | 617 | |
| 616 | 618 | /***********************************************************************//** |
| 619 | + * @brief Fetch column data | |
| 620 | + ***************************************************************************/ | |
| 621 | +void GFitsTableFloatCol::fetch_data(void) const | |
| 622 | +{ | |
| 623 | + // Save column (circumvent const correctness) | |
| 624 | + const_cast<GFitsTableFloatCol*>(this)->load_column(); | |
| 625 | + | |
| 626 | + // Return | |
| 627 | + return; | |
| 628 | +} | |
| 629 | + | |
| 630 | + | |
| 631 | +/***********************************************************************//** | |
| 632 | + * @brief Copy column data | |
| 633 | + * | |
| 634 | + * @param[in] column Column. | |
| 635 | + * | |
| 636 | + * Copies all data from a column. This method is called from the base class | |
| 637 | + * copy constructor. | |
| 638 | + ***************************************************************************/ | |
| 639 | +void GFitsTableFloatCol::copy_data(const GFitsTableCol& column) | |
| 640 | +{ | |
| 641 | + // Type-cast to the correct column type | |
| 642 | + const GFitsTableFloatCol* ptr = static_cast<const GFitsTableFloatCol*>(&column); | |
| 643 | + | |
| 644 | + // Copy column data (only if column contains data) | |
| 645 | + if (ptr->m_data != NULL && ptr->m_size > 0) { | |
| 646 | + m_size = ptr->m_size; | |
| 647 | + alloc_data(); | |
| 648 | + for (int i = 0; i < ptr->m_size; ++i) { | |
| 649 | + m_data[i] = ptr->m_data[i]; | |
| 650 | + } | |
| 651 | + } | |
| 652 | + | |
| 653 | + // Copy NULL value | |
| 654 | + alloc_nulval(ptr->m_nulval); | |
| 655 | + | |
| 656 | + // Return | |
| 657 | + return; | |
| 658 | +} | |
| 659 | + | |
| 660 | + | |
| 661 | +/***********************************************************************//** | |
| 617 | 662 | * @brief Release column data |
| 618 | 663 | ***************************************************************************/ |
| 619 | 664 | void GFitsTableFloatCol::release_data(void) | ... | ... |
src/fits/GFitsTableLongCol.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * GFitsTableLongCol.cpp - FITS table long integer column class * | |
| 2 | + * GFitsTableLongCol.cpp - FITS table long integer column class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | 4 | * copyright (C) 2010-2013 by Juergen Knoedlseder * |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| ... | ... | @@ -526,8 +526,10 @@ void GFitsTableLongCol::copy_members(const GFitsTableLongCol& column) |
| 526 | 526 | } |
| 527 | 527 | |
| 528 | 528 | // Copy attributes |
| 529 | - m_type = column.m_type; | |
| 530 | - m_size = column.m_size; | |
| 529 | + m_type = column.m_type; | |
| 530 | + m_size = column.m_size; | |
| 531 | + m_varlen = column.m_varlen; | |
| 532 | + m_rowstart = column.m_rowstart; | |
| 531 | 533 | |
| 532 | 534 | // Copy column data |
| 533 | 535 | if (column.m_data != NULL && m_size > 0) { |
| ... | ... | @@ -614,6 +616,49 @@ void GFitsTableLongCol::alloc_data(void) |
| 614 | 616 | |
| 615 | 617 | |
| 616 | 618 | /***********************************************************************//** |
| 619 | + * @brief Fetch column data | |
| 620 | + ***************************************************************************/ | |
| 621 | +void GFitsTableLongCol::fetch_data(void) const | |
| 622 | +{ | |
| 623 | + // Save column (circumvent const correctness) | |
| 624 | + const_cast<GFitsTableLongCol*>(this)->load_column(); | |
| 625 | + | |
| 626 | + // Return | |
| 627 | + return; | |
| 628 | +} | |
| 629 | + | |
| 630 | + | |
| 631 | +/***********************************************************************//** | |
| 632 | + * @brief Copy column data | |
| 633 | + * | |
| 634 | + * @param[in] column Column. | |
| 635 | + * | |
| 636 | + * Copies all data from a column. This method is called from the base class | |
| 637 | + * copy constructor. | |
| 638 | + ***************************************************************************/ | |
| 639 | +void GFitsTableLongCol::copy_data(const GFitsTableCol& column) | |
| 640 | +{ | |
| 641 | + // Type-cast to the correct column type | |
| 642 | + const GFitsTableLongCol* ptr = static_cast<const GFitsTableLongCol*>(&column); | |
| 643 | + | |
| 644 | + // Copy column data (only if column contains data) | |
| 645 | + if (ptr->m_data != NULL && ptr->m_size > 0) { | |
| 646 | + m_size = ptr->m_size; | |
| 647 | + alloc_data(); | |
| 648 | + for (int i = 0; i < ptr->m_size; ++i) { | |
| 649 | + m_data[i] = ptr->m_data[i]; | |
| 650 | + } | |
| 651 | + } | |
| 652 | + | |
| 653 | + // Copy NULL value | |
| 654 | + alloc_nulval(ptr->m_nulval); | |
| 655 | + | |
| 656 | + // Return | |
| 657 | + return; | |
| 658 | +} | |
| 659 | + | |
| 660 | + | |
| 661 | +/***********************************************************************//** | |
| 617 | 662 | * @brief Release column data |
| 618 | 663 | ***************************************************************************/ |
| 619 | 664 | void GFitsTableLongCol::release_data(void) | ... | ... |
src/fits/GFitsTableLongLongCol.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * GFitsTableLongLongCol.cpp - FITS table long long integer column class * | |
| 2 | + * GFitsTableLongLongCol.cpp - FITS table long long integer column class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | 4 | * copyright (C) 2010-2013 by Juergen Knoedlseder * |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| ... | ... | @@ -526,8 +526,10 @@ void GFitsTableLongLongCol::copy_members(const GFitsTableLongLongCol& column) |
| 526 | 526 | } |
| 527 | 527 | |
| 528 | 528 | // Copy attributes |
| 529 | - m_type = column.m_type; | |
| 530 | - m_size = column.m_size; | |
| 529 | + m_type = column.m_type; | |
| 530 | + m_size = column.m_size; | |
| 531 | + m_varlen = column.m_varlen; | |
| 532 | + m_rowstart = column.m_rowstart; | |
| 531 | 533 | |
| 532 | 534 | // Copy column data |
| 533 | 535 | if (column.m_data != NULL && m_size > 0) { |
| ... | ... | @@ -614,6 +616,49 @@ void GFitsTableLongLongCol::alloc_data(void) |
| 614 | 616 | |
| 615 | 617 | |
| 616 | 618 | /***********************************************************************//** |
| 619 | + * @brief Fetch column data | |
| 620 | + ***************************************************************************/ | |
| 621 | +void GFitsTableLongLongCol::fetch_data(void) const | |
| 622 | +{ | |
| 623 | + // Save column (circumvent const correctness) | |
| 624 | + const_cast<GFitsTableLongLongCol*>(this)->load_column(); | |
| 625 | + | |
| 626 | + // Return | |
| 627 | + return; | |
| 628 | +} | |
| 629 | + | |
| 630 | + | |
| 631 | +/***********************************************************************//** | |
| 632 | + * @brief Copy column data | |
| 633 | + * | |
| 634 | + * @param[in] column Column. | |
| 635 | + * | |
| 636 | + * Copies all data from a column. This method is called from the base class | |
| 637 | + * copy constructor. | |
| 638 | + ***************************************************************************/ | |
| 639 | +void GFitsTableLongLongCol::copy_data(const GFitsTableCol& column) | |
| 640 | +{ | |
| 641 | + // Type-cast to the correct column type | |
| 642 | + const GFitsTableLongLongCol* ptr = static_cast<const GFitsTableLongLongCol*>(&column); | |
| 643 | + | |
| 644 | + // Copy column data (only if column contains data) | |
| 645 | + if (ptr->m_data != NULL && ptr->m_size > 0) { | |
| 646 | + m_size = ptr->m_size; | |
| 647 | + alloc_data(); | |
| 648 | + for (int i = 0; i < ptr->m_size; ++i) { | |
| 649 | + m_data[i] = ptr->m_data[i]; | |
| 650 | + } | |
| 651 | + } | |
| 652 | + | |
| 653 | + // Copy NULL value | |
| 654 | + alloc_nulval(ptr->m_nulval); | |
| 655 | + | |
| 656 | + // Return | |
| 657 | + return; | |
| 658 | +} | |
| 659 | + | |
| 660 | + | |
| 661 | +/***********************************************************************//** | |
| 617 | 662 | * @brief Release column data |
| 618 | 663 | ***************************************************************************/ |
| 619 | 664 | void GFitsTableLongLongCol::release_data(void) | ... | ... |
src/fits/GFitsTableShortCol.cpp
| ... | ... | @@ -526,8 +526,10 @@ void GFitsTableShortCol::copy_members(const GFitsTableShortCol& column) |
| 526 | 526 | } |
| 527 | 527 | |
| 528 | 528 | // Copy attributes |
| 529 | - m_type = column.m_type; | |
| 530 | - m_size = column.m_size; | |
| 529 | + m_type = column.m_type; | |
| 530 | + m_size = column.m_size; | |
| 531 | + m_varlen = column.m_varlen; | |
| 532 | + m_rowstart = column.m_rowstart; | |
| 531 | 533 | |
| 532 | 534 | // Copy column data |
| 533 | 535 | if (column.m_data != NULL && m_size > 0) { |
| ... | ... | @@ -614,6 +616,49 @@ void GFitsTableShortCol::alloc_data(void) |
| 614 | 616 | |
| 615 | 617 | |
| 616 | 618 | /***********************************************************************//** |
| 619 | + * @brief Fetch column data | |
| 620 | + ***************************************************************************/ | |
| 621 | +void GFitsTableShortCol::fetch_data(void) const | |
| 622 | +{ | |
| 623 | + // Save column (circumvent const correctness) | |
| 624 | + const_cast<GFitsTableShortCol*>(this)->load_column(); | |
| 625 | + | |
| 626 | + // Return | |
| 627 | + return; | |
| 628 | +} | |
| 629 | + | |
| 630 | + | |
| 631 | +/***********************************************************************//** | |
| 632 | + * @brief Copy column data | |
| 633 | + * | |
| 634 | + * @param[in] column Column. | |
| 635 | + * | |
| 636 | + * Copies all data from a column. This method is called from the base class | |
| 637 | + * copy constructor. | |
| 638 | + ***************************************************************************/ | |
| 639 | +void GFitsTableShortCol::copy_data(const GFitsTableCol& column) | |
| 640 | +{ | |
| 641 | + // Type-cast to the correct column type | |
| 642 | + const GFitsTableShortCol* ptr = static_cast<const GFitsTableShortCol*>(&column); | |
| 643 | + | |
| 644 | + // Copy column data (only if column contains data) | |
| 645 | + if (ptr->m_data != NULL && ptr->m_size > 0) { | |
| 646 | + m_size = ptr->m_size; | |
| 647 | + alloc_data(); | |
| 648 | + for (int i = 0; i < ptr->m_size; ++i) { | |
| 649 | + m_data[i] = ptr->m_data[i]; | |
| 650 | + } | |
| 651 | + } | |
| 652 | + | |
| 653 | + // Copy NULL value | |
| 654 | + alloc_nulval(ptr->m_nulval); | |
| 655 | + | |
| 656 | + // Return | |
| 657 | + return; | |
| 658 | +} | |
| 659 | + | |
| 660 | + | |
| 661 | +/***********************************************************************//** | |
| 617 | 662 | * @brief Release column data |
| 618 | 663 | ***************************************************************************/ |
| 619 | 664 | void GFitsTableShortCol::release_data(void) | ... | ... |
src/fits/GFitsTableStringCol.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * GFitsTableStringCol.cpp - FITS table string column class * | |
| 2 | + * GFitsTableStringCol.cpp - FITS table string column class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | 4 | * copyright (C) 2010-2013 by Juergen Knoedlseder * |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| ... | ... | @@ -532,8 +532,10 @@ void GFitsTableStringCol::copy_members(const GFitsTableStringCol& column) |
| 532 | 532 | } |
| 533 | 533 | |
| 534 | 534 | // Copy attributes |
| 535 | - m_type = column.m_type; | |
| 536 | - m_size = column.m_size; | |
| 535 | + m_type = column.m_type; | |
| 536 | + m_size = column.m_size; | |
| 537 | + m_varlen = column.m_varlen; | |
| 538 | + m_rowstart = column.m_rowstart; | |
| 537 | 539 | |
| 538 | 540 | // Copy column data |
| 539 | 541 | if (column.m_data != NULL && m_size > 0) { |
| ... | ... | @@ -666,6 +668,78 @@ void GFitsTableStringCol::alloc_data(void) |
| 666 | 668 | |
| 667 | 669 | |
| 668 | 670 | /***********************************************************************//** |
| 671 | + * @brief Fetch column data | |
| 672 | + * | |
| 673 | + * If a FITS file is attached to the column the data are loaded into memory | |
| 674 | + * from the FITS file. If no FITS file is attached, memory is allocated | |
| 675 | + * to hold the column data and all cells are set to 0. | |
| 676 | + * | |
| 677 | + * Refer to GFitsTableCol::load_column for more information. | |
| 678 | + ***************************************************************************/ | |
| 679 | +void GFitsTableStringCol::fetch_data(void) const | |
| 680 | +{ | |
| 681 | + // Calculate size of memory | |
| 682 | + m_size = m_number * m_length; | |
| 683 | + | |
| 684 | + // Free old buffer memory | |
| 685 | + free_buffer(); | |
| 686 | + | |
| 687 | + // Allocate buffer memory | |
| 688 | + alloc_buffer(); | |
| 689 | + | |
| 690 | + // Load column | |
| 691 | + const_cast<GFitsTableStringCol*>(this)->load_column(); | |
| 692 | + | |
| 693 | + // Extract string from buffer | |
| 694 | + for (int i = 0; i < m_size; ++i) { | |
| 695 | + if (m_buffer[i] != NULL) { | |
| 696 | + m_data[i].assign(m_buffer[i]); | |
| 697 | + } | |
| 698 | + } | |
| 699 | + | |
| 700 | + // Free buffer memory | |
| 701 | + free_buffer(); | |
| 702 | + | |
| 703 | + // Return | |
| 704 | + return; | |
| 705 | +} | |
| 706 | + | |
| 707 | + | |
| 708 | +/***********************************************************************//** | |
| 709 | + * @brief Copy column data | |
| 710 | + * | |
| 711 | + * @param[in] column Column. | |
| 712 | + * | |
| 713 | + * Copies all data from a column. This method is called from the base class | |
| 714 | + * copy constructor. | |
| 715 | + ***************************************************************************/ | |
| 716 | +void GFitsTableStringCol::copy_data(const GFitsTableCol& column) | |
| 717 | +{ | |
| 718 | + // Type-cast to the correct column type | |
| 719 | + const GFitsTableStringCol* ptr = static_cast<const GFitsTableStringCol*>(&column); | |
| 720 | + | |
| 721 | + // Copy column data (only if column contains data) | |
| 722 | + if (ptr->m_data != NULL && ptr->m_size > 0) { | |
| 723 | + m_size = ptr->m_size; | |
| 724 | + alloc_data(); | |
| 725 | + for (int i = 0; i < ptr->m_size; ++i) { | |
| 726 | + m_data[i] = ptr->m_data[i]; | |
| 727 | + } | |
| 728 | + } | |
| 729 | + | |
| 730 | + // Copy NULL value | |
| 731 | + if (ptr->m_nulval != NULL) { | |
| 732 | + if (m_nulval != NULL) delete [] m_nulval; | |
| 733 | + m_nulval = new char[m_width+1]; | |
| 734 | + std::strncpy(m_nulval, ptr->m_nulval, m_width); | |
| 735 | + } | |
| 736 | + | |
| 737 | + // Return | |
| 738 | + return; | |
| 739 | +} | |
| 740 | + | |
| 741 | + | |
| 742 | +/***********************************************************************//** | |
| 669 | 743 | * @brief Release column data |
| 670 | 744 | ***************************************************************************/ |
| 671 | 745 | void GFitsTableStringCol::release_data(void) |
| ... | ... | @@ -727,44 +801,6 @@ void GFitsTableStringCol::init_data(void) |
| 727 | 801 | |
| 728 | 802 | |
| 729 | 803 | /***********************************************************************//** |
| 730 | - * @brief Fetch column data | |
| 731 | - * | |
| 732 | - * If a FITS file is attached to the column the data are loaded into memory | |
| 733 | - * from the FITS file. If no FITS file is attached, memory is allocated | |
| 734 | - * to hold the column data and all cells are set to 0. | |
| 735 | - * | |
| 736 | - * Refer to GFitsTableCol::load_column for more information. | |
| 737 | - ***************************************************************************/ | |
| 738 | -void GFitsTableStringCol::fetch_data(void) const | |
| 739 | -{ | |
| 740 | - // Calculate size of memory | |
| 741 | - m_size = m_number * m_length; | |
| 742 | - | |
| 743 | - // Free old buffer memory | |
| 744 | - free_buffer(); | |
| 745 | - | |
| 746 | - // Allocate buffer memory | |
| 747 | - alloc_buffer(); | |
| 748 | - | |
| 749 | - // Load column | |
| 750 | - const_cast<GFitsTableStringCol*>(this)->load_column(); | |
| 751 | - | |
| 752 | - // Extract string from buffer | |
| 753 | - for (int i = 0; i < m_size; ++i) { | |
| 754 | - if (m_buffer[i] != NULL) { | |
| 755 | - m_data[i].assign(m_buffer[i]); | |
| 756 | - } | |
| 757 | - } | |
| 758 | - | |
| 759 | - // Free buffer memory | |
| 760 | - free_buffer(); | |
| 761 | - | |
| 762 | - // Return | |
| 763 | - return; | |
| 764 | -} | |
| 765 | - | |
| 766 | - | |
| 767 | -/***********************************************************************//** | |
| 768 | 804 | * @brief Allocate CFITSIO transfer buffer |
| 769 | 805 | * |
| 770 | 806 | * The CFITSIO transfer buffer allows transparent conversion from the CFITSIO | ... | ... |
src/fits/GFitsTableULongCol.cpp
| ... | ... | @@ -526,8 +526,10 @@ void GFitsTableULongCol::copy_members(const GFitsTableULongCol& column) |
| 526 | 526 | } |
| 527 | 527 | |
| 528 | 528 | // Copy attributes |
| 529 | - m_type = column.m_type; | |
| 530 | - m_size = column.m_size; | |
| 529 | + m_type = column.m_type; | |
| 530 | + m_size = column.m_size; | |
| 531 | + m_varlen = column.m_varlen; | |
| 532 | + m_rowstart = column.m_rowstart; | |
| 531 | 533 | |
| 532 | 534 | // Copy column data |
| 533 | 535 | if (column.m_data != NULL && m_size > 0) { |
| ... | ... | @@ -611,6 +613,49 @@ void GFitsTableULongCol::alloc_data(void) |
| 611 | 613 | |
| 612 | 614 | |
| 613 | 615 | /***********************************************************************//** |
| 616 | + * @brief Fetch column data | |
| 617 | + ***************************************************************************/ | |
| 618 | +void GFitsTableULongCol::fetch_data(void) const | |
| 619 | +{ | |
| 620 | + // Save column (circumvent const correctness) | |
| 621 | + const_cast<GFitsTableULongCol*>(this)->load_column(); | |
| 622 | + | |
| 623 | + // Return | |
| 624 | + return; | |
| 625 | +} | |
| 626 | + | |
| 627 | + | |
| 628 | +/***********************************************************************//** | |
| 629 | + * @brief Copy column data | |
| 630 | + * | |
| 631 | + * @param[in] column Column. | |
| 632 | + * | |
| 633 | + * Copies all data from a column. This method is called from the base class | |
| 634 | + * copy constructor. | |
| 635 | + ***************************************************************************/ | |
| 636 | +void GFitsTableULongCol::copy_data(const GFitsTableCol& column) | |
| 637 | +{ | |
| 638 | + // Type-cast to the correct column type | |
| 639 | + const GFitsTableULongCol* ptr = static_cast<const GFitsTableULongCol*>(&column); | |
| 640 | + | |
| 641 | + // Copy column data (only if column contains data) | |
| 642 | + if (ptr->m_data != NULL && ptr->m_size > 0) { | |
| 643 | + m_size = ptr->m_size; | |
| 644 | + alloc_data(); | |
| 645 | + for (int i = 0; i < ptr->m_size; ++i) { | |
| 646 | + m_data[i] = ptr->m_data[i]; | |
| 647 | + } | |
| 648 | + } | |
| 649 | + | |
| 650 | + // Copy NULL value | |
| 651 | + alloc_nulval(ptr->m_nulval); | |
| 652 | + | |
| 653 | + // Return | |
| 654 | + return; | |
| 655 | +} | |
| 656 | + | |
| 657 | + | |
| 658 | +/***********************************************************************//** | |
| 614 | 659 | * @brief Release column data |
| 615 | 660 | ***************************************************************************/ |
| 616 | 661 | void GFitsTableULongCol::release_data(void) | ... | ... |
src/fits/GFitsTableUShortCol.cpp
| ... | ... | @@ -526,8 +526,10 @@ void GFitsTableUShortCol::copy_members(const GFitsTableUShortCol& column) |
| 526 | 526 | } |
| 527 | 527 | |
| 528 | 528 | // Copy attributes |
| 529 | - m_type = column.m_type; | |
| 530 | - m_size = column.m_size; | |
| 529 | + m_type = column.m_type; | |
| 530 | + m_size = column.m_size; | |
| 531 | + m_varlen = column.m_varlen; | |
| 532 | + m_rowstart = column.m_rowstart; | |
| 531 | 533 | |
| 532 | 534 | // Copy column data |
| 533 | 535 | if (column.m_data != NULL && m_size > 0) { |
| ... | ... | @@ -611,6 +613,49 @@ void GFitsTableUShortCol::alloc_data(void) |
| 611 | 613 | |
| 612 | 614 | |
| 613 | 615 | /***********************************************************************//** |
| 616 | + * @brief Fetch column data | |
| 617 | + ***************************************************************************/ | |
| 618 | +void GFitsTableUShortCol::fetch_data(void) const | |
| 619 | +{ | |
| 620 | + // Save column (circumvent const correctness) | |
| 621 | + const_cast<GFitsTableUShortCol*>(this)->load_column(); | |
| 622 | + | |
| 623 | + // Return | |
| 624 | + return; | |
| 625 | +} | |
| 626 | + | |
| 627 | + | |
| 628 | +/***********************************************************************//** | |
| 629 | + * @brief Copy column data | |
| 630 | + * | |
| 631 | + * @param[in] column Column. | |
| 632 | + * | |
| 633 | + * Copies all data from a column. This method is called from the base class | |
| 634 | + * copy constructor. | |
| 635 | + ***************************************************************************/ | |
| 636 | +void GFitsTableUShortCol::copy_data(const GFitsTableCol& column) | |
| 637 | +{ | |
| 638 | + // Type-cast to the correct column type | |
| 639 | + const GFitsTableUShortCol* ptr = static_cast<const GFitsTableUShortCol*>(&column); | |
| 640 | + | |
| 641 | + // Copy column data (only if column contains data) | |
| 642 | + if (ptr->m_data != NULL && ptr->m_size > 0) { | |
| 643 | + m_size = ptr->m_size; | |
| 644 | + alloc_data(); | |
| 645 | + for (int i = 0; i < ptr->m_size; ++i) { | |
| 646 | + m_data[i] = ptr->m_data[i]; | |
| 647 | + } | |
| 648 | + } | |
| 649 | + | |
| 650 | + // Copy NULL value | |
| 651 | + alloc_nulval(ptr->m_nulval); | |
| 652 | + | |
| 653 | + // Return | |
| 654 | + return; | |
| 655 | +} | |
| 656 | + | |
| 657 | + | |
| 658 | +/***********************************************************************//** | |
| 614 | 659 | * @brief Release column data |
| 615 | 660 | ***************************************************************************/ |
| 616 | 661 | void GFitsTableUShortCol::release_data(void) | ... | ... |