From 6bed2c93bb179fa09ce5b23dfd90090c46d78245 Mon Sep 17 00:00:00 2001 From: knodlseder <> Date: Sun, 14 Nov 2010 23:04:28 +0000 Subject: [PATCH] use new FITS table column classes --- include/GFitsTableBitCol.hpp | 13 +++++++------ include/GFitsTableBoolCol.hpp | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/GFitsTableCol.hpp | 15 ++++++++------- include/GFitsTableDblCol.hpp | 78 ------------------------------------------------------------------------------ include/GFitsTableDoubleCol.hpp | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/GFitsTableFloatCol.hpp | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/GFitsTableFltCol.hpp | 78 ------------------------------------------------------------------------------ include/GFitsTableLlgCol.hpp | 81 --------------------------------------------------------------------------------- include/GFitsTableLngCol.hpp | 78 ------------------------------------------------------------------------------ include/GFitsTableLogCol.hpp | 79 ------------------------------------------------------------------------------- include/GFitsTableLongCol.hpp | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/GFitsTableLongLongCol.hpp | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/GFitsTableShortCol.hpp | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/GFitsTableShtCol.hpp | 78 ------------------------------------------------------------------------------ include/GFitsTableStrCol.hpp | 81 --------------------------------------------------------------------------------- include/GFitsTableStringCol.hpp | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/GFitsTableULgCol.hpp | 78 ------------------------------------------------------------------------------ include/GFitsTableULongCol.hpp | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/GFitsTableUShortCol.hpp | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/GFitsTableUStCol.hpp | 78 ------------------------------------------------------------------------------ pyext/GFitsTableBitCol.i | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ pyext/GFitsTableBoolCol.i | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ pyext/GFitsTableDblCol.i | 75 --------------------------------------------------------------------------- pyext/GFitsTableDoubleCol.i | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ pyext/GFitsTableFloatCol.i | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ pyext/GFitsTableFltCol.i | 75 --------------------------------------------------------------------------- pyext/GFitsTableLngCol.i | 75 --------------------------------------------------------------------------- pyext/GFitsTableLogCol.i | 75 --------------------------------------------------------------------------- pyext/GFitsTableLongCol.i | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ pyext/GFitsTableLongLongCol.i | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ pyext/GFitsTableShortCol.i | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ pyext/GFitsTableShtCol.i | 75 --------------------------------------------------------------------------- pyext/GFitsTableStrCol.i | 75 --------------------------------------------------------------------------- pyext/GFitsTableStringCol.i | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ pyext/GFitsTableULongCol.i | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ pyext/GFitsTableUShortCol.i | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ pyext/gammalib.i | 16 ++++++++++------ src/fits/GFitsTableBitCol.cpp | 217 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------------------------------------------------------ src/fits/GFitsTableBoolCol.cpp | 601 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/fits/GFitsTableCol.cpp | 205 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------- src/fits/GFitsTableDoubleCol.cpp | 498 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/fits/GFitsTableFloatCol.cpp | 498 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/fits/GFitsTableLongCol.cpp | 498 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/fits/GFitsTableLongLongCol.cpp | 498 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/fits/GFitsTableShortCol.cpp | 498 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/fits/GFitsTableStrCol.cpp | 647 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- src/fits/GFitsTableStringCol.cpp | 617 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/fits/GFitsTableULongCol.cpp | 495 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/fits/GFitsTableUShortCol.cpp | 495 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/fits/Makefile.am | 18 +++++++++--------- src/obs/GEbounds.cpp | 6 +++--- src/obs/GGti.cpp | 6 +++--- src/sky/GSkymap.cpp | 4 ++-- test/test_GFits.cpp | 1140 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 54 files changed, 7017 insertions(+), 2611 deletions(-) create mode 100644 include/GFitsTableBoolCol.hpp delete mode 100644 include/GFitsTableDblCol.hpp create mode 100644 include/GFitsTableDoubleCol.hpp create mode 100644 include/GFitsTableFloatCol.hpp delete mode 100644 include/GFitsTableFltCol.hpp delete mode 100644 include/GFitsTableLlgCol.hpp delete mode 100644 include/GFitsTableLngCol.hpp delete mode 100644 include/GFitsTableLogCol.hpp create mode 100644 include/GFitsTableLongCol.hpp create mode 100644 include/GFitsTableLongLongCol.hpp create mode 100644 include/GFitsTableShortCol.hpp delete mode 100644 include/GFitsTableShtCol.hpp delete mode 100644 include/GFitsTableStrCol.hpp create mode 100644 include/GFitsTableStringCol.hpp delete mode 100644 include/GFitsTableULgCol.hpp create mode 100644 include/GFitsTableULongCol.hpp create mode 100644 include/GFitsTableUShortCol.hpp delete mode 100644 include/GFitsTableUStCol.hpp create mode 100644 pyext/GFitsTableBitCol.i create mode 100644 pyext/GFitsTableBoolCol.i delete mode 100644 pyext/GFitsTableDblCol.i create mode 100644 pyext/GFitsTableDoubleCol.i create mode 100644 pyext/GFitsTableFloatCol.i delete mode 100644 pyext/GFitsTableFltCol.i delete mode 100644 pyext/GFitsTableLngCol.i delete mode 100644 pyext/GFitsTableLogCol.i create mode 100644 pyext/GFitsTableLongCol.i create mode 100644 pyext/GFitsTableLongLongCol.i create mode 100644 pyext/GFitsTableShortCol.i delete mode 100644 pyext/GFitsTableShtCol.i delete mode 100644 pyext/GFitsTableStrCol.i create mode 100644 pyext/GFitsTableStringCol.i create mode 100644 pyext/GFitsTableULongCol.i create mode 100644 pyext/GFitsTableUShortCol.i create mode 100644 src/fits/GFitsTableBoolCol.cpp create mode 100644 src/fits/GFitsTableDoubleCol.cpp create mode 100644 src/fits/GFitsTableFloatCol.cpp create mode 100644 src/fits/GFitsTableLongCol.cpp create mode 100644 src/fits/GFitsTableLongLongCol.cpp create mode 100644 src/fits/GFitsTableShortCol.cpp delete mode 100644 src/fits/GFitsTableStrCol.cpp create mode 100644 src/fits/GFitsTableStringCol.cpp create mode 100644 src/fits/GFitsTableULongCol.cpp create mode 100644 src/fits/GFitsTableUShortCol.cpp diff --git a/include/GFitsTableBitCol.hpp b/include/GFitsTableBitCol.hpp index 350ff2c..15d3c20 100644 --- a/include/GFitsTableBitCol.hpp +++ b/include/GFitsTableBitCol.hpp @@ -30,8 +30,8 @@ * * This class implements a FITS table Bit column. * - * TODO: Each Bit is actually stored in one Byte. To save memory a more - * compact storage scheme should be implemented. + * @todo Each Bit is actually stored in one Byte. To save memory a more + * compact storage scheme could be implemented. ***************************************************************************/ class GFitsTableBitCol : public GFitsTableCol { @@ -55,21 +55,22 @@ public: std::string string(const int& row, const int& col = 0); double real(const int& row, const int& col = 0); int integer(const int& row, const int& col = 0); - char* data(void); - void set_nullval(const char* value); + char* data(void) { return m_data; } + void nullval(const char* value); + char* nullval(void) { return m_nulval; } private: // Private methods void init_members(void); void copy_members(const GFitsTableBitCol& column); void free_members(void); - void save(void); GFitsTableBitCol* clone(void) const; std::string ascii_format(void) const; std::string binary_format(void) const; void alloc_data(void); + void release_data(void); + void alloc_nulval(const char* value); void init_data(void); - void fetch_data(void); void* ptr_data(void) { return m_data; } void* ptr_nulval(void) { return m_nulval; } diff --git a/include/GFitsTableBoolCol.hpp b/include/GFitsTableBoolCol.hpp new file mode 100644 index 0000000..2b66544 --- /dev/null +++ b/include/GFitsTableBoolCol.hpp @@ -0,0 +1,87 @@ +/*************************************************************************** + * GFitsTableBoolCol.hpp - FITS table boolean column class * + * ----------------------------------------------------------------------- * + * copyright (C) 2010 by Jurgen Knodlseder * + * ----------------------------------------------------------------------- * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +/** + * @file GFitsTableBoolCol.hpp + * @brief GFitsTableBoolCol class definition. + * @author J. Knodlseder + */ + +#ifndef GFITSTABLEBOOLCOL_HPP +#define GFITSTABLEBOOLCOL_HPP + +/* __ Includes ___________________________________________________________ */ +#include "GFitsTableCol.hpp" + + +/***********************************************************************//** + * @class GFitsTableBoolCol + * + * @brief Interface for FITS table Boolean column + * + * This class implements a FITS table Boolean column. + * + * @todo Each Bit is actually stored in one Byte. To save memory a more + * compact storage scheme should be implemented. + ***************************************************************************/ +class GFitsTableBoolCol : public GFitsTableCol { + + // I/O friends + friend std::ostream& operator<< (std::ostream& os, const GFitsTableBoolCol& column); + +public: + // Constructors and destructors + GFitsTableBoolCol(void); + GFitsTableBoolCol(const std::string& name, const int& length, + const int& size = 1); + GFitsTableBoolCol(const GFitsTableBoolCol& column); + virtual ~GFitsTableBoolCol(void); + + // Operators + GFitsTableBoolCol& operator= (const GFitsTableBoolCol& column); + bool& operator() (const int& row, const int& inx = 0); + const bool& operator() (const int& row, const int& inx = 0) const; + + // Methods + std::string string(const int& row, const int& col = 0); + double real(const int& row, const int& col = 0); + int integer(const int& row, const int& col = 0); + bool* data(void) { return m_data; } + void nullval(const bool* value); + bool* nullval(void) { return m_nulval; } + +private: + // Private methods + void init_members(void); + void copy_members(const GFitsTableBoolCol& column); + void free_members(void); + void save(void); + GFitsTableBoolCol* clone(void) const; + std::string ascii_format(void) const; + std::string binary_format(void) const; + void alloc_data(void); + void release_data(void); + void alloc_nulval(const bool* value); + void init_data(void); + void fetch_data(void); + void alloc_buffer(void); + void free_buffer(void); + void* ptr_data(void) { return m_buffer; } + void* ptr_nulval(void) { return m_nulval; } + + // Private data area + bool* m_data; //!< Data area + char* m_buffer; //!< Data area for CFITSIO transfer + bool* m_nulval; //!< NULL value +}; + +#endif /* GFITSTABLEBOOLCOL_HPP */ diff --git a/include/GFitsTableCol.hpp b/include/GFitsTableCol.hpp index 41aa5f3..0c86178 100644 --- a/include/GFitsTableCol.hpp +++ b/include/GFitsTableCol.hpp @@ -37,11 +37,11 @@ class GFitsTableCol { public: // Constructors and destructors - GFitsTableCol(); + GFitsTableCol(void); GFitsTableCol(const std::string& name, const int& length, const int& number, const int& width); GFitsTableCol(const GFitsTableCol& column); - virtual ~GFitsTableCol(); + virtual ~GFitsTableCol(void); // Operators GFitsTableCol& operator= (const GFitsTableCol& column); @@ -81,20 +81,21 @@ protected: __fitsfile m_fitsfile; //!< FITS file associated with column // Protected virtual methods - virtual void save(void) = 0; virtual GFitsTableCol* clone(void) const = 0; virtual std::string ascii_format(void) const = 0; virtual std::string binary_format(void) const = 0; virtual void alloc_data(void) = 0; virtual void init_data(void) = 0; - virtual void fetch_data(void) = 0; virtual void* ptr_data(void) = 0; virtual void* ptr_nulval(void) = 0; // Protected methods - void load_column(void); - void save_column(void); - void dump_column(std::ostream& os, void* data) const; + virtual void save(void); + virtual void fetch_data(void); + virtual void load_column(void); + virtual void save_column(void); + virtual void dump_column(std::ostream& os, void* data) const; + virtual int offset(const int& row, const int& inx) const; private: // Private methods diff --git a/include/GFitsTableDblCol.hpp b/include/GFitsTableDblCol.hpp deleted file mode 100644 index c317ae2..0000000 --- a/include/GFitsTableDblCol.hpp +++ /dev/null @@ -1,78 +0,0 @@ -/*************************************************************************** - * GFitsTableDblCol.hpp - FITS table double column class * - * ----------------------------------------------------------------------- * - * copyright (C) 2008 by Jurgen Knodlseder * - * ----------------------------------------------------------------------- * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ -/** - * @file GFitsTableDblCol.hpp - * @brief GFitsTableDblCol class definition. - * @author J. Knodlseder - */ - -#ifndef GFITSTABLEDBLCOL_HPP -#define GFITSTABLEDBLCOL_HPP - -/* __ Includes ___________________________________________________________ */ -#include "GFitsTableCol.hpp" - - -/***********************************************************************//** - * @class GFitsTableDblCol - * - * @brief Interface for FITS table double precision column - * - * This class implements a FITS table double precision column. - ***************************************************************************/ -class GFitsTableDblCol : public GFitsTableCol { - - // I/O friends - friend std::ostream& operator<< (std::ostream& os, const GFitsTableDblCol& column); - -public: - // Constructors and destructors - GFitsTableDblCol(); - GFitsTableDblCol(const std::string& name, const int& length, - const int& size = 1); - GFitsTableDblCol(const GFitsTableDblCol& column); - virtual ~GFitsTableDblCol(); - - // Operators - GFitsTableDblCol& operator= (const GFitsTableDblCol& column); - double& operator() (const int& row, const int& inx = 0); - const double& operator() (const int& row, const int& inx = 0) const; - - // Methods - std::string string(const int& row, const int& inx = 0); - double real(const int& row, const int& inx = 0); - int integer(const int& row, const int& inx = 0); - double* data(void); - void set_nullval(const double* value); - -private: - // Private methods - void init_members(void); - void copy_members(const GFitsTableDblCol& column); - void free_members(void); - void save(void); - GFitsTableDblCol* clone(void) const; - std::string ascii_format(void) const; - std::string binary_format(void) const; - void alloc_data(void); - void init_data(void); - void fetch_data(void); - void* ptr_data(void) { return m_data; } - void* ptr_nulval(void) { return m_nulval; } - - // Private data area - double* m_data; //!< Data area - double* m_nulval; //!< NULL value -}; - -#endif /* GFITSTABLEDBLCOL_HPP */ diff --git a/include/GFitsTableDoubleCol.hpp b/include/GFitsTableDoubleCol.hpp new file mode 100644 index 0000000..f19a81a --- /dev/null +++ b/include/GFitsTableDoubleCol.hpp @@ -0,0 +1,79 @@ +/*************************************************************************** + * GFitsTableDoubleCol.hpp - FITS table double column class * + * ----------------------------------------------------------------------- * + * copyright (C) 2010 by Jurgen Knodlseder * + * ----------------------------------------------------------------------- * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +/** + * @file GFitsTableDoubleCol.hpp + * @brief GFitsTableDoubleCol class definition. + * @author J. Knodlseder + */ + +#ifndef GFITSTABLEDOUBLECOL_HPP +#define GFITSTABLEDOUBLECOL_HPP + +/* __ Includes ___________________________________________________________ */ +#include "GFitsTableCol.hpp" + + +/***********************************************************************//** + * @class GFitsTableDoubleCol + * + * @brief Interface for FITS table double column + * + * This class implements a FITS table double column. + ***************************************************************************/ +class GFitsTableDoubleCol : public GFitsTableCol { + + // I/O friends + friend std::ostream& operator<< (std::ostream& os, const GFitsTableDoubleCol& column); + +public: + // Constructors and destructors + GFitsTableDoubleCol(void); + GFitsTableDoubleCol(const std::string& name, const int& length, + const int& size = 1); + GFitsTableDoubleCol(const GFitsTableDoubleCol& column); + virtual ~GFitsTableDoubleCol(void); + + // Operators + GFitsTableDoubleCol& operator= (const GFitsTableDoubleCol& column); + double& operator() (const int& row, const int& inx = 0); + const double& operator() (const int& row, const int& inx = 0) const; + + // Methods + std::string string(const int& row, const int& col = 0); + double real(const int& row, const int& col = 0); + int integer(const int& row, const int& col = 0); + double* data(void) { return m_data; } + void nullval(const double* value); + double* nullval(void) { return m_nulval; } + +private: + // Private methods + void init_members(void); + void copy_members(const GFitsTableDoubleCol& column); + void free_members(void); + GFitsTableDoubleCol* clone(void) const; + std::string ascii_format(void) const; + std::string binary_format(void) const; + void alloc_data(void); + void release_data(void); + void alloc_nulval(const double* value); + void init_data(void); + void* ptr_data(void) { return m_data; } + void* ptr_nulval(void) { return m_nulval; } + + // Private data area + double* m_data; //!< Data vector + double* m_nulval; //!< NULL value +}; + +#endif /* GFITSTABLEDOUBLECOL_HPP */ diff --git a/include/GFitsTableFloatCol.hpp b/include/GFitsTableFloatCol.hpp new file mode 100644 index 0000000..0618eb6 --- /dev/null +++ b/include/GFitsTableFloatCol.hpp @@ -0,0 +1,79 @@ +/*************************************************************************** + * GFitsTableFloatCol.hpp - FITS table float column class * + * ----------------------------------------------------------------------- * + * copyright (C) 2010 by Jurgen Knodlseder * + * ----------------------------------------------------------------------- * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +/** + * @file GFitsTableFloatCol.hpp + * @brief GFitsTableFloatCol class definition. + * @author J. Knodlseder + */ + +#ifndef GFITSTABLEFLOATCOL_HPP +#define GFITSTABLEFLOATCOL_HPP + +/* __ Includes ___________________________________________________________ */ +#include "GFitsTableCol.hpp" + + +/***********************************************************************//** + * @class GFitsTableFloatCol + * + * @brief Interface for FITS table float column + * + * This class implements a FITS table float column. + ***************************************************************************/ +class GFitsTableFloatCol : public GFitsTableCol { + + // I/O friends + friend std::ostream& operator<< (std::ostream& os, const GFitsTableFloatCol& column); + +public: + // Constructors and destructors + GFitsTableFloatCol(void); + GFitsTableFloatCol(const std::string& name, const int& length, + const int& size = 1); + GFitsTableFloatCol(const GFitsTableFloatCol& column); + virtual ~GFitsTableFloatCol(void); + + // Operators + GFitsTableFloatCol& operator= (const GFitsTableFloatCol& column); + float& operator() (const int& row, const int& inx = 0); + const float& operator() (const int& row, const int& inx = 0) const; + + // Methods + std::string string(const int& row, const int& col = 0); + double real(const int& row, const int& col = 0); + int integer(const int& row, const int& col = 0); + float* data(void) { return m_data; } + void nullval(const float* value); + float* nullval(void) { return m_nulval; } + +private: + // Private methods + void init_members(void); + void copy_members(const GFitsTableFloatCol& column); + void free_members(void); + GFitsTableFloatCol* clone(void) const; + std::string ascii_format(void) const; + std::string binary_format(void) const; + void alloc_data(void); + void release_data(void); + void alloc_nulval(const float* value); + void init_data(void); + void* ptr_data(void) { return m_data; } + void* ptr_nulval(void) { return m_nulval; } + + // Private data area + float* m_data; //!< Data vector + float* m_nulval; //!< NULL value +}; + +#endif /* GFITSTABLEFLOATCOL_HPP */ diff --git a/include/GFitsTableFltCol.hpp b/include/GFitsTableFltCol.hpp deleted file mode 100644 index 86ec79d..0000000 --- a/include/GFitsTableFltCol.hpp +++ /dev/null @@ -1,78 +0,0 @@ -/*************************************************************************** - * GFitsTableFltCol.hpp - FITS table float column class * - * ----------------------------------------------------------------------- * - * copyright (C) 2008 by Jurgen Knodlseder * - * ----------------------------------------------------------------------- * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ -/** - * @file GFitsTableFltCol.hpp - * @brief GFitsTableFltCol class definition. - * @author J. Knodlseder - */ - -#ifndef GFITSTABLEFLTCOL_HPP -#define GFITSTABLEFLTCOL_HPP - -/* __ Includes ___________________________________________________________ */ -#include "GFitsTableCol.hpp" - - -/***********************************************************************//** - * @class GFitsTableFltCol - * - * @brief Interface for FITS table floating point column - * - * This class implements a FITS table floating point column. - ***************************************************************************/ -class GFitsTableFltCol : public GFitsTableCol { - - // I/O friends - friend std::ostream& operator<< (std::ostream& os, const GFitsTableFltCol& column); - -public: - // Constructors and destructors - GFitsTableFltCol(); - GFitsTableFltCol(const std::string& name, const int& length, - const int& size = 1); - GFitsTableFltCol(const GFitsTableFltCol& column); - virtual ~GFitsTableFltCol(); - - // Operators - GFitsTableFltCol& operator= (const GFitsTableFltCol& column); - float& operator() (const int& row, const int& inx = 0); - const float& operator() (const int& row, const int& inx = 0) const; - - // Methods - std::string string(const int& row, const int& col = 0); - double real(const int& row, const int& col = 0); - int integer(const int& row, const int& col = 0); - float* data(void); - void set_nullval(const float* value); - -private: - // Private methods - void init_members(void); - void copy_members(const GFitsTableFltCol& column); - void free_members(void); - void save(void); - GFitsTableFltCol* clone(void) const; - std::string ascii_format(void) const; - std::string binary_format(void) const; - void alloc_data(void); - void init_data(void); - void fetch_data(void); - void* ptr_data(void) { return m_data; } - void* ptr_nulval(void) { return m_nulval; } - - // Private data area - float* m_data; //!< Data area - float* m_nulval; //!< NULL value -}; - -#endif /* GFITSTABLEFLTCOL_HPP */ diff --git a/include/GFitsTableLlgCol.hpp b/include/GFitsTableLlgCol.hpp deleted file mode 100644 index 18b6acc..0000000 --- a/include/GFitsTableLlgCol.hpp +++ /dev/null @@ -1,81 +0,0 @@ -/*************************************************************************** - * GFitsTableLlgCol.hpp - FITS table long long column class * - * ----------------------------------------------------------------------- * - * copyright (C) 2010 by Jurgen Knodlseder * - * ----------------------------------------------------------------------- * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ -/** - * @file GFitsTableLlgCol.hpp - * @brief GFitsTableLlgCol class definition. - * @author J. Knodlseder - */ - -#ifndef GFITSTABLELLGCOL_HPP -#define GFITSTABLELLGCOL_HPP - -/* __ Includes ___________________________________________________________ */ -#include "GFitsTableCol.hpp" - - -/***********************************************************************//** - * @class GFitsTableLlgCol - * - * @brief Interface for FITS table long long integer column - * - * This class implements a FITS table long long integer column. - * - * TODO: integer() method returns actually a int which may lead to an - * overflow. Better return long long. - ***************************************************************************/ -class GFitsTableLlgCol : public GFitsTableCol { - - // I/O friends - friend std::ostream& operator<< (std::ostream& os, const GFitsTableLlgCol& column); - -public: - // Constructors and destructors - GFitsTableLlgCol(void); - GFitsTableLlgCol(const std::string& name, const int& length, - const int& size = 1); - GFitsTableLlgCol(const GFitsTableLlgCol& column); - virtual ~GFitsTableLlgCol(void); - - // Operators - GFitsTableLlgCol& operator= (const GFitsTableLlgCol& column); - long long& operator() (const int& row, const int& inx = 0); - const long long& operator() (const int& row, const int& inx = 0) const; - - // Methods - std::string string(const int& row, const int& col = 0); - double real(const int& row, const int& col = 0); - int integer(const int& row, const int& col = 0); - long long* data(void); - void set_nullval(const long long* value); - -private: - // Private methods - void init_members(void); - void copy_members(const GFitsTableLlgCol& column); - void free_members(void); - void save(void); - GFitsTableLlgCol* clone(void) const; - std::string ascii_format(void) const; - std::string binary_format(void) const; - void alloc_data(void); - void init_data(void); - void fetch_data(void); - void* ptr_data(void) { return m_data; } - void* ptr_nulval(void) { return m_nulval; } - - // Private data area - long long* m_data; //!< Data area - long long* m_nulval; //!< NULL value -}; - -#endif /* GFITSTABLELLGCOL_HPP */ diff --git a/include/GFitsTableLngCol.hpp b/include/GFitsTableLngCol.hpp deleted file mode 100644 index 3ad94d1..0000000 --- a/include/GFitsTableLngCol.hpp +++ /dev/null @@ -1,78 +0,0 @@ -/*************************************************************************** - * GFitsTableLngCol.hpp - FITS table long column class * - * ----------------------------------------------------------------------- * - * copyright (C) 2008 by Jurgen Knodlseder * - * ----------------------------------------------------------------------- * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ -/** - * @file GFitsTableLngCol.hpp - * @brief GFitsTableLngCol class definition. - * @author J. Knodlseder - */ - -#ifndef GFITSTABLELNGCOL_HPP -#define GFITSTABLELNGCOL_HPP - -/* __ Includes ___________________________________________________________ */ -#include "GFitsTableCol.hpp" - - -/***********************************************************************//** - * @class GFitsTableLngCol - * - * @brief Interface for FITS table long integer column - * - * This class implements a FITS table long integer column. - ***************************************************************************/ -class GFitsTableLngCol : public GFitsTableCol { - - // I/O friends - friend std::ostream& operator<< (std::ostream& os, const GFitsTableLngCol& column); - -public: - // Constructors and destructors - GFitsTableLngCol(); - GFitsTableLngCol(const std::string& name, const int& length, - const int& size = 1); - GFitsTableLngCol(const GFitsTableLngCol& column); - virtual ~GFitsTableLngCol(); - - // Operators - GFitsTableLngCol& operator= (const GFitsTableLngCol& column); - long& operator() (const int& row, const int& inx = 0); - const long& operator() (const int& row, const int& inx = 0) const; - - // Methods - std::string string(const int& row, const int& col = 0); - double real(const int& row, const int& col = 0); - int integer(const int& row, const int& col = 0); - long* data(void); - void set_nullval(const long* value); - -private: - // Private methods - void init_members(void); - void copy_members(const GFitsTableLngCol& column); - void free_members(void); - void save(void); - GFitsTableLngCol* clone(void) const; - std::string ascii_format(void) const; - std::string binary_format(void) const; - void alloc_data(void); - void init_data(void); - void fetch_data(void); - void* ptr_data(void) { return m_data; } - void* ptr_nulval(void) { return m_nulval; } - - // Private data area - long* m_data; //!< Data area - long* m_nulval; //!< NULL value -}; - -#endif /* GFITSTABLELNGCOL_HPP */ diff --git a/include/GFitsTableLogCol.hpp b/include/GFitsTableLogCol.hpp deleted file mode 100644 index 7379b33..0000000 --- a/include/GFitsTableLogCol.hpp +++ /dev/null @@ -1,79 +0,0 @@ -/*************************************************************************** - * GFitsTableLogCol.hpp - FITS table logical column class * - * ----------------------------------------------------------------------- * - * copyright (C) 2008 by Jurgen Knodlseder * - * ----------------------------------------------------------------------- * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ -/** - * @file GFitsTableLogCol.hpp - * @brief GFitsTableLogCol class definition. - * @author J. Knodlseder - */ - -#ifndef GFITSTABLELOGCOL_HPP -#define GFITSTABLELOGCOL_HPP - -/* __ Includes ___________________________________________________________ */ -//#include "GFitsCfitsio.hpp" -#include "GFitsTableCol.hpp" - - -/***********************************************************************//** - * @class GFitsTableLogCol - * - * @brief Interface for FITS table logical column - * - * This class implements a FITS table logical column. - ***************************************************************************/ -class GFitsTableLogCol : public GFitsTableCol { - - // I/O friends - friend std::ostream& operator<< (std::ostream& os, const GFitsTableLogCol& column); - -public: - // Constructors and destructors - GFitsTableLogCol(); - GFitsTableLogCol(const std::string& name, const int& length, - const int& size = 1); - GFitsTableLogCol(const GFitsTableLogCol& column); - virtual ~GFitsTableLogCol(); - - // Operators - GFitsTableLogCol& operator= (const GFitsTableLogCol& column); - char& operator() (const int& row, const int& inx = 0); - const char& operator() (const int& row, const int& inx = 0) const; - - // Methods - std::string string(const int& row, const int& col = 0); - double real(const int& row, const int& col = 0); - int integer(const int& row, const int& col = 0); - char* data(void); - void set_nullval(const char* value); - -private: - // Private methods - void init_members(void); - void copy_members(const GFitsTableLogCol& column); - void free_members(void); - void save(void); - GFitsTableLogCol* clone(void) const; - std::string ascii_format(void) const; - std::string binary_format(void) const; - void alloc_data(void); - void init_data(void); - void fetch_data(void); - void* ptr_data(void) { return m_data; } - void* ptr_nulval(void) { return m_nulval; } - - // Private data area - char* m_data; //!< Data area - char* m_nulval; //!< NULL value -}; - -#endif /* GFITSTABLELOGCOL_HPP */ diff --git a/include/GFitsTableLongCol.hpp b/include/GFitsTableLongCol.hpp new file mode 100644 index 0000000..c2d4637 --- /dev/null +++ b/include/GFitsTableLongCol.hpp @@ -0,0 +1,79 @@ +/*************************************************************************** + * GFitsTableLongCol.hpp - FITS table long column class * + * ----------------------------------------------------------------------- * + * copyright (C) 2010 by Jurgen Knodlseder * + * ----------------------------------------------------------------------- * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +/** + * @file GFitsTableLongCol.hpp + * @brief GFitsTableLongCol class definition. + * @author J. Knodlseder + */ + +#ifndef GFITSTABLELONGCOL_HPP +#define GFITSTABLELONGCOL_HPP + +/* __ Includes ___________________________________________________________ */ +#include "GFitsTableCol.hpp" + + +/***********************************************************************//** + * @class GFitsTableLongCol + * + * @brief Interface for FITS table long integer column + * + * This class implements a FITS table long integer column. + ***************************************************************************/ +class GFitsTableLongCol : public GFitsTableCol { + + // I/O friends + friend std::ostream& operator<< (std::ostream& os, const GFitsTableLongCol& column); + +public: + // Constructors and destructors + GFitsTableLongCol(void); + GFitsTableLongCol(const std::string& name, const int& length, + const int& size = 1); + GFitsTableLongCol(const GFitsTableLongCol& column); + virtual ~GFitsTableLongCol(void); + + // Operators + GFitsTableLongCol& operator= (const GFitsTableLongCol& column); + long& operator() (const int& row, const int& inx = 0); + const long& operator() (const int& row, const int& inx = 0) const; + + // Methods + std::string string(const int& row, const int& col = 0); + double real(const int& row, const int& col = 0); + int integer(const int& row, const int& col = 0); + long* data(void) { return m_data; } + void nullval(const long* value); + long* nullval(void) { return m_nulval; } + +private: + // Private methods + void init_members(void); + void copy_members(const GFitsTableLongCol& column); + void free_members(void); + GFitsTableLongCol* clone(void) const; + std::string ascii_format(void) const; + std::string binary_format(void) const; + void alloc_data(void); + void release_data(void); + void alloc_nulval(const long* value); + void init_data(void); + void* ptr_data(void) { return m_data; } + void* ptr_nulval(void) { return m_nulval; } + + // Private data area + long* m_data; //!< Data vector + long* m_nulval; //!< NULL value +}; + +#endif /* GFITSTABLELONGCOL_HPP */ diff --git a/include/GFitsTableLongLongCol.hpp b/include/GFitsTableLongLongCol.hpp new file mode 100644 index 0000000..b22f960 --- /dev/null +++ b/include/GFitsTableLongLongCol.hpp @@ -0,0 +1,79 @@ +/*************************************************************************** + * GFitsTableLongLongCol.hpp - FITS table long long column class * + * ----------------------------------------------------------------------- * + * copyright (C) 2010 by Jurgen Knodlseder * + * ----------------------------------------------------------------------- * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +/** + * @file GFitsTableLongLongCol.hpp + * @brief GFitsTableLongLongCol class definition. + * @author J. Knodlseder + */ + +#ifndef GFITSTABLELONGLONGCOL_HPP +#define GFITSTABLELONGLONGCOL_HPP + +/* __ Includes ___________________________________________________________ */ +#include "GFitsTableCol.hpp" + + +/***********************************************************************//** + * @class GFitsTableLongLongCol + * + * @brief Interface for FITS table long integer column + * + * This class implements a FITS table long integer column. + ***************************************************************************/ +class GFitsTableLongLongCol : public GFitsTableCol { + + // I/O friends + friend std::ostream& operator<< (std::ostream& os, const GFitsTableLongLongCol& column); + +public: + // Constructors and destructors + GFitsTableLongLongCol(void); + GFitsTableLongLongCol(const std::string& name, const int& length, + const int& size = 1); + GFitsTableLongLongCol(const GFitsTableLongLongCol& column); + virtual ~GFitsTableLongLongCol(void); + + // Operators + GFitsTableLongLongCol& operator= (const GFitsTableLongLongCol& column); + long long& operator() (const int& row, const int& inx = 0); + const long long& operator() (const int& row, const int& inx = 0) const; + + // Methods + std::string string(const int& row, const int& col = 0); + double real(const int& row, const int& col = 0); + int integer(const int& row, const int& col = 0); + long long* data(void) { return m_data; } + void nullval(const long long* value); + long long* nullval(void) { return m_nulval; } + +private: + // Private methods + void init_members(void); + void copy_members(const GFitsTableLongLongCol& column); + void free_members(void); + GFitsTableLongLongCol* clone(void) const; + std::string ascii_format(void) const; + std::string binary_format(void) const; + void alloc_data(void); + void release_data(void); + void alloc_nulval(const long long* value); + void init_data(void); + void* ptr_data(void) { return m_data; } + void* ptr_nulval(void) { return m_nulval; } + + // Private data area + long long* m_data; //!< Data vector + long long* m_nulval; //!< NULL value +}; + +#endif /* GFITSTABLELONGLONGCOL_HPP */ diff --git a/include/GFitsTableShortCol.hpp b/include/GFitsTableShortCol.hpp new file mode 100644 index 0000000..0132f3b --- /dev/null +++ b/include/GFitsTableShortCol.hpp @@ -0,0 +1,79 @@ +/*************************************************************************** + * GFitsTableShortCol.hpp - FITS table short column class * + * ----------------------------------------------------------------------- * + * copyright (C) 2010 by Jurgen Knodlseder * + * ----------------------------------------------------------------------- * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +/** + * @file GFitsTableShortCol.hpp + * @brief GFitsTableShortCol class definition. + * @author J. Knodlseder + */ + +#ifndef GFITSTABLESHORTCOL_HPP +#define GFITSTABLESHORTCOL_HPP + +/* __ Includes ___________________________________________________________ */ +#include "GFitsTableCol.hpp" + + +/***********************************************************************//** + * @class GFitsTableShortCol + * + * @brief Interface for FITS table short integer column + * + * This class implements a FITS table short integer column. + ***************************************************************************/ +class GFitsTableShortCol : public GFitsTableCol { + + // I/O friends + friend std::ostream& operator<< (std::ostream& os, const GFitsTableShortCol& column); + +public: + // Constructors and destructors + GFitsTableShortCol(void); + GFitsTableShortCol(const std::string& name, const int& length, + const int& size = 1); + GFitsTableShortCol(const GFitsTableShortCol& column); + virtual ~GFitsTableShortCol(void); + + // Operators + GFitsTableShortCol& operator= (const GFitsTableShortCol& column); + short& operator() (const int& row, const int& inx = 0); + const short& operator() (const int& row, const int& inx = 0) const; + + // Methods + std::string string(const int& row, const int& col = 0); + double real(const int& row, const int& col = 0); + int integer(const int& row, const int& col = 0); + short* data(void) { return m_data; } + void nullval(const short* value); + short* nullval(void) { return m_nulval; } + +private: + // Private methods + void init_members(void); + void copy_members(const GFitsTableShortCol& column); + void free_members(void); + GFitsTableShortCol* clone(void) const; + std::string ascii_format(void) const; + std::string binary_format(void) const; + void alloc_data(void); + void release_data(void); + void alloc_nulval(const short* value); + void init_data(void); + void* ptr_data(void) { return m_data; } + void* ptr_nulval(void) { return m_nulval; } + + // Private data area + short* m_data; //!< Data vector + short* m_nulval; //!< NULL value +}; + +#endif /* GFITSTABLESHORTCOL_HPP */ diff --git a/include/GFitsTableShtCol.hpp b/include/GFitsTableShtCol.hpp deleted file mode 100644 index 96d30d3..0000000 --- a/include/GFitsTableShtCol.hpp +++ /dev/null @@ -1,78 +0,0 @@ -/*************************************************************************** - * GFitsTableShtCol.hpp - FITS table short column class * - * ----------------------------------------------------------------------- * - * copyright (C) 2008 by Jurgen Knodlseder * - * ----------------------------------------------------------------------- * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ -/** - * @file GFitsTableShtCol.hpp - * @brief GFitsTableShtCol class definition. - * @author J. Knodlseder - */ - -#ifndef GFITSTABLESHTCOL_HPP -#define GFITSTABLESHTCOL_HPP - -/* __ Includes ___________________________________________________________ */ -#include "GFitsTableCol.hpp" - - -/***********************************************************************//** - * @class GFitsTableShtCol - * - * @brief Interface for FITS table short integer column - * - * This class implements a FITS table short integer column. - ***************************************************************************/ -class GFitsTableShtCol : public GFitsTableCol { - - // I/O friends - friend std::ostream& operator<< (std::ostream& os, const GFitsTableShtCol& column); - -public: - // Constructors and destructors - GFitsTableShtCol(); - GFitsTableShtCol(const std::string& name, const int& length, - const int& size = 1); - GFitsTableShtCol(const GFitsTableShtCol& column); - virtual ~GFitsTableShtCol(); - - // Operators - GFitsTableShtCol& operator= (const GFitsTableShtCol& column); - short& operator() (const int& row, const int& inx = 0); - const short& operator() (const int& row, const int& inx = 0) const; - - // Methods - std::string string(const int& row, const int& col = 0); - double real(const int& row, const int& col = 0); - int integer(const int& row, const int& col = 0); - short* data(void); - void set_nullval(const short* value); - -private: - // Private methods - void init_members(void); - void copy_members(const GFitsTableShtCol& column); - void free_members(void); - void save(void); - GFitsTableShtCol* clone(void) const; - std::string ascii_format(void) const; - std::string binary_format(void) const; - void alloc_data(void); - void init_data(void); - void fetch_data(void); - void* ptr_data(void) { return m_data; } - void* ptr_nulval(void) { return m_nulval; } - - // Private data area - short* m_data; //!< Data area - short* m_nulval; //!< NULL value -}; - -#endif /* GFITSTABLESHTCOL_HPP */ diff --git a/include/GFitsTableStrCol.hpp b/include/GFitsTableStrCol.hpp deleted file mode 100644 index f815666..0000000 --- a/include/GFitsTableStrCol.hpp +++ /dev/null @@ -1,81 +0,0 @@ -/*************************************************************************** - * GFitsTableStrCol.hpp - FITS table string column class * - * ----------------------------------------------------------------------- * - * copyright (C) 2008-2010 by Jurgen Knodlseder * - * ----------------------------------------------------------------------- * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ -/** - * @file GFitsTableStrCol.hpp - * @brief GFitsTableStrCol class definition. - * @author J. Knodlseder - */ - -#ifndef GFITSTABLESTRCOL_HPP -#define GFITSTABLESTRCOL_HPP - -/* __ Includes ___________________________________________________________ */ -#include "GFitsTableCol.hpp" - - -/***********************************************************************//** - * @class GFitsTableStrCol - * - * @brief Interface for FITS table string column - * - * This class implements a FITS table string column. - ***************************************************************************/ -class GFitsTableStrCol : public GFitsTableCol { - - // I/O friends - friend std::ostream& operator<< (std::ostream& os, const GFitsTableStrCol& column); - -public: - // Constructors and destructors - GFitsTableStrCol(); - GFitsTableStrCol(const std::string& name, const int& length, - const int& width, const int& size = 1); - GFitsTableStrCol(const GFitsTableStrCol& column); - ~GFitsTableStrCol(); - - // Operators - GFitsTableStrCol& operator= (const GFitsTableStrCol& column); - std::string& operator() (const int& row, const int& inx = 0); - const std::string& operator() (const int& row, const int& inx = 0) const; - - // Methods - std::string string(const int& row, const int& col = 0); - double real(const int& row, const int& col = 0); - int integer(const int& row, const int& col = 0); - std::string* data(void); - void set_nullval(const std::string& string); - -private: - // Private methods - void init_members(void); - void copy_members(const GFitsTableStrCol& column); - void free_members(void); - void save(void); - GFitsTableStrCol* clone(void) const; - std::string ascii_format(void) const; - std::string binary_format(void) const; - void alloc_data(void); - void init_data(void); - void fetch_data(void); - void* ptr_data(void) { return m_buffer; } - void* ptr_nulval(void) { return m_nulval; } - void alloc_buffer(void); - void free_buffer(void); - - // Private data area - std::string* m_data; //!< Data area - char** m_buffer; //!< Data area for CFITSIO transfer - char* m_nulval; //!< NULL string -}; - -#endif /* GFITSTABLESTRCOL_HPP */ diff --git a/include/GFitsTableStringCol.hpp b/include/GFitsTableStringCol.hpp new file mode 100644 index 0000000..0eee01b --- /dev/null +++ b/include/GFitsTableStringCol.hpp @@ -0,0 +1,84 @@ +/*************************************************************************** + * GFitsTableStringCol.hpp - FITS table string column class * + * ----------------------------------------------------------------------- * + * copyright (C) 2008-2010 by Jurgen Knodlseder * + * ----------------------------------------------------------------------- * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +/** + * @file GFitsTableStringCol.hpp + * @brief GFitsTableStringCol class definition. + * @author J. Knodlseder + */ + +#ifndef GFITSTABLESTRINGCOL_HPP +#define GFITSTABLESTRINGCOL_HPP + +/* __ Includes ___________________________________________________________ */ +#include "GFitsTableCol.hpp" + + +/***********************************************************************//** + * @class GFitsTableStringCol + * + * @brief Interface for FITS table string column + * + * This class implements a FITS table string column. + ***************************************************************************/ +class GFitsTableStringCol : public GFitsTableCol { + + // I/O friends + friend std::ostream& operator<< (std::ostream& os, const GFitsTableStringCol& column); + +public: + // Constructors and destructors + GFitsTableStringCol(void); + GFitsTableStringCol(const std::string& name, const int& length, + const int& width, const int& size = 1); + GFitsTableStringCol(const GFitsTableStringCol& column); + virtual ~GFitsTableStringCol(void); + + // Operators + GFitsTableStringCol& operator= (const GFitsTableStringCol& column); + std::string& operator() (const int& row, const int& inx = 0); + const std::string& operator() (const int& row, const int& inx = 0) const; + + // Methods + std::string string(const int& row, const int& col = 0); + double real(const int& row, const int& col = 0); + int integer(const int& row, const int& col = 0); + std::string* data(void) { return m_data; } + void nullval(const std::string& value); + char* nullval(void) { return m_nulval; } + +private: + // Private methods + void init_members(void); + void copy_members(const GFitsTableStringCol& column); + void free_members(void); + void save(void); + GFitsTableStringCol* clone(void) const; + std::string ascii_format(void) const; + std::string binary_format(void) const; + void alloc_data(void); + void release_data(void); + void alloc_nulval(const std::string& value); + void init_data(void); + void fetch_data(void); + void alloc_buffer(void); + void free_buffer(void); + void* ptr_data(void) { return m_buffer; } + void* ptr_nulval(void) { return m_nulval; } + + // Private data area + std::string* m_data; //!< Data area + char** m_buffer; //!< Data area for CFITSIO transfer + char* m_nulval; //!< NULL string +}; + +#endif /* GFITSTABLESTRINGCOL_HPP */ diff --git a/include/GFitsTableULgCol.hpp b/include/GFitsTableULgCol.hpp deleted file mode 100644 index f2b4819..0000000 --- a/include/GFitsTableULgCol.hpp +++ /dev/null @@ -1,78 +0,0 @@ -/*************************************************************************** - * GFitsTableULgCol.hpp - FITS table unsigned long column class * - * ----------------------------------------------------------------------- * - * copyright (C) 2010 by Jurgen Knodlseder * - * ----------------------------------------------------------------------- * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ -/** - * @file GFitsTableULgCol.hpp - * @brief GFitsTableULgCol class definition. - * @author J. Knodlseder - */ - -#ifndef GFITSTABLEULGCOL_HPP -#define GFITSTABLEULGCOL_HPP - -/* __ Includes ___________________________________________________________ */ -#include "GFitsTableCol.hpp" - - -/***********************************************************************//** - * @class GFitsTableULgCol - * - * @brief Interface for FITS table unsigned long integer column - * - * This class implements a FITS table unsigned long integer column. - ***************************************************************************/ -class GFitsTableULgCol : public GFitsTableCol { - - // I/O friends - friend std::ostream& operator<< (std::ostream& os, const GFitsTableULgCol& column); - -public: - // Constructors and destructors - GFitsTableULgCol(); - GFitsTableULgCol(const std::string& name, const int& length, - const int& size = 1); - GFitsTableULgCol(const GFitsTableULgCol& column); - virtual ~GFitsTableULgCol(); - - // Operators - GFitsTableULgCol& operator= (const GFitsTableULgCol& column); - unsigned long& operator() (const int& row, const int& inx = 0); - const unsigned long& operator() (const int& row, const int& inx = 0) const; - - // Methods - std::string string(const int& row, const int& col = 0); - double real(const int& row, const int& col = 0); - int integer(const int& row, const int& col = 0); - unsigned long* data(void); - void set_nullval(const unsigned long* value); - -private: - // Private methods - void init_members(void); - void copy_members(const GFitsTableULgCol& column); - void free_members(void); - void save(void); - GFitsTableULgCol* clone(void) const; - std::string ascii_format(void) const; - std::string binary_format(void) const; - void alloc_data(void); - void init_data(void); - void fetch_data(void); - void* ptr_data(void) { return m_data; } - void* ptr_nulval(void) { return m_nulval; } - - // Private data area - unsigned long* m_data; //!< Data area - unsigned long* m_nulval; //!< NULL value -}; - -#endif /* GFITSTABLEULGCOL_HPP */ diff --git a/include/GFitsTableULongCol.hpp b/include/GFitsTableULongCol.hpp new file mode 100644 index 0000000..d60550e --- /dev/null +++ b/include/GFitsTableULongCol.hpp @@ -0,0 +1,79 @@ +/*************************************************************************** + * GFitsTableULongCol.hpp - FITS table unsigned long column class * + * ----------------------------------------------------------------------- * + * copyright (C) 2010 by Jurgen Knodlseder * + * ----------------------------------------------------------------------- * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +/** + * @file GFitsTableULongCol.hpp + * @brief GFitsTableULongCol class definition. + * @author J. Knodlseder + */ + +#ifndef GFITSTABLEULONGCOL_HPP +#define GFITSTABLEULONGCOL_HPP + +/* __ Includes ___________________________________________________________ */ +#include "GFitsTableCol.hpp" + + +/***********************************************************************//** + * @class GFitsTableULongCol + * + * @brief Interface for FITS table unsigned long integer column + * + * This class implements a FITS table unsigned long integer column. + ***************************************************************************/ +class GFitsTableULongCol : public GFitsTableCol { + + // I/O friends + friend std::ostream& operator<< (std::ostream& os, const GFitsTableULongCol& column); + +public: + // Constructors and destructors + GFitsTableULongCol(void); + GFitsTableULongCol(const std::string& name, const int& length, + const int& size = 1); + GFitsTableULongCol(const GFitsTableULongCol& column); + virtual ~GFitsTableULongCol(void); + + // Operators + GFitsTableULongCol& operator= (const GFitsTableULongCol& column); + unsigned long& operator() (const int& row, const int& inx = 0); + const unsigned long& operator() (const int& row, const int& inx = 0) const; + + // Methods + std::string string(const int& row, const int& col = 0); + double real(const int& row, const int& col = 0); + int integer(const int& row, const int& col = 0); + unsigned long* data(void) { return m_data; } + void nullval(const unsigned long* value); + unsigned long* nullval(void) { return m_nulval; } + +private: + // Private methods + void init_members(void); + void copy_members(const GFitsTableULongCol& column); + void free_members(void); + GFitsTableULongCol* clone(void) const; + std::string ascii_format(void) const; + std::string binary_format(void) const; + void alloc_data(void); + void release_data(void); + void alloc_nulval(const unsigned long* value); + void init_data(void); + void* ptr_data(void) { return m_data; } + void* ptr_nulval(void) { return m_nulval; } + + // Private data area + unsigned long* m_data; //!< Data vector + unsigned long* m_nulval; //!< NULL value +}; + +#endif /* GFITSTABLEULONGCOL_HPP */ diff --git a/include/GFitsTableUShortCol.hpp b/include/GFitsTableUShortCol.hpp new file mode 100644 index 0000000..9f281b6 --- /dev/null +++ b/include/GFitsTableUShortCol.hpp @@ -0,0 +1,79 @@ +/*************************************************************************** + * GFitsTableUShortCol.hpp - FITS table unsigned short column class * + * ----------------------------------------------------------------------- * + * copyright (C) 2010 by Jurgen Knodlseder * + * ----------------------------------------------------------------------- * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +/** + * @file GFitsTableUShortCol.hpp + * @brief GFitsTableUShortCol class definition. + * @author J. Knodlseder + */ + +#ifndef GFITSTABLEUSHORTCOL_HPP +#define GFITSTABLEUSHORTCOL_HPP + +/* __ Includes ___________________________________________________________ */ +#include "GFitsTableCol.hpp" + + +/***********************************************************************//** + * @class GFitsTableUShortCol + * + * @brief Interface for FITS table unsigned short integer column + * + * This class implements a FITS table unsigned short integer column. + ***************************************************************************/ +class GFitsTableUShortCol : public GFitsTableCol { + + // I/O friends + friend std::ostream& operator<< (std::ostream& os, const GFitsTableUShortCol& column); + +public: + // Constructors and destructors + GFitsTableUShortCol(void); + GFitsTableUShortCol(const std::string& name, const int& length, + const int& size = 1); + GFitsTableUShortCol(const GFitsTableUShortCol& column); + virtual ~GFitsTableUShortCol(void); + + // Operators + GFitsTableUShortCol& operator= (const GFitsTableUShortCol& column); + unsigned short& operator() (const int& row, const int& inx = 0); + const unsigned short& operator() (const int& row, const int& inx = 0) const; + + // Methods + std::string string(const int& row, const int& col = 0); + double real(const int& row, const int& col = 0); + int integer(const int& row, const int& col = 0); + unsigned short* data(void) { return m_data; } + void nullval(const unsigned short* value); + unsigned short* nullval(void) { return m_nulval; } + +private: + // Private methods + void init_members(void); + void copy_members(const GFitsTableUShortCol& column); + void free_members(void); + GFitsTableUShortCol* clone(void) const; + std::string ascii_format(void) const; + std::string binary_format(void) const; + void alloc_data(void); + void release_data(void); + void alloc_nulval(const unsigned short* value); + void init_data(void); + void* ptr_data(void) { return m_data; } + void* ptr_nulval(void) { return m_nulval; } + + // Private data area + unsigned short* m_data; //!< Data vector + unsigned short* m_nulval; //!< NULL value +}; + +#endif /* GFITSTABLEUSHORTCOL_HPP */ diff --git a/include/GFitsTableUStCol.hpp b/include/GFitsTableUStCol.hpp deleted file mode 100644 index 5dacecf..0000000 --- a/include/GFitsTableUStCol.hpp +++ /dev/null @@ -1,78 +0,0 @@ -/*************************************************************************** - * GFitsTableUStCol.hpp - FITS table unsigned short column class * - * ----------------------------------------------------------------------- * - * copyright (C) 2010 by Jurgen Knodlseder * - * ----------------------------------------------------------------------- * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ -/** - * @file GFitsTableUStCol.hpp - * @brief GFitsTableUStCol class definition. - * @author J. Knodlseder - */ - -#ifndef GFITSTABLEUSTCOL_HPP -#define GFITSTABLEUSTCOL_HPP - -/* __ Includes ___________________________________________________________ */ -#include "GFitsTableCol.hpp" - - -/***********************************************************************//** - * @class GFitsTableUStCol - * - * @brief Interface for FITS table unsigned long integer column - * - * This class implements a FITS table unsigned long integer column. - ***************************************************************************/ -class GFitsTableUStCol : public GFitsTableCol { - - // I/O friends - friend std::ostream& operator<< (std::ostream& os, const GFitsTableUStCol& column); - -public: - // Constructors and destructors - GFitsTableUStCol(); - GFitsTableUStCol(const std::string& name, const int& length, - const int& size = 1); - GFitsTableUStCol(const GFitsTableUStCol& column); - virtual ~GFitsTableUStCol(); - - // Operators - GFitsTableUStCol& operator= (const GFitsTableUStCol& column); - unsigned short& operator() (const int& row, const int& inx = 0); - const unsigned short& operator() (const int& row, const int& inx = 0) const; - - // Methods - std::string string(const int& row, const int& col = 0); - double real(const int& row, const int& col = 0); - int integer(const int& row, const int& col = 0); - unsigned short* data(void); - void set_nullval(const unsigned short* value); - -private: - // Private methods - void init_members(void); - void copy_members(const GFitsTableUStCol& column); - void free_members(void); - void save(void); - GFitsTableUStCol* clone(void) const; - std::string ascii_format(void) const; - std::string binary_format(void) const; - void alloc_data(void); - void init_data(void); - void fetch_data(void); - void* ptr_data(void) { return m_data; } - void* ptr_nulval(void) { return m_nulval; } - - // Private data area - unsigned short* m_data; //!< Data area - unsigned short* m_nulval; //!< NULL value -}; - -#endif /* GFITSTABLEUSTCOL_HPP */ diff --git a/pyext/GFitsTableBitCol.i b/pyext/GFitsTableBitCol.i new file mode 100644 index 0000000..680c086 --- /dev/null +++ b/pyext/GFitsTableBitCol.i @@ -0,0 +1,76 @@ +/*************************************************************************** + * GFitsTableBitCol.i - FITS table bit column class SWIG definition * + * ----------------------------------------------------------------------- * + * copyright : (C) 2010 by Jurgen Knodlseder * + * ----------------------------------------------------------------------- * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +/** + * @file GFitsTableBitCol.i + * @brief GFitsTableBitCol class SWIG file. + * @author J. Knodlseder + */ +%{ +/* Put headers and other declarations here that are needed for compilation */ +#include "GFitsTableBitCol.hpp" +%} + + +/***********************************************************************//** + * @class GFitsTableBitCol + * + * @brief SWIG interface for FITS table logical column + ***************************************************************************/ +class GFitsTableBitCol : public GFitsTableCol { +public: + // Constructors and destructors + GFitsTableBitCol(void); + GFitsTableBitCol(const std::string& name, const int& length, + const int& size = 1); + GFitsTableBitCol(const GFitsTableBitCol& column); + virtual ~GFitsTableBitCol(void); + + // Methods + std::string string(const int& row, const int& col = 0); + double real(const int& row, const int& col = 0); + int integer(const int& row, const int& col = 0); + char* data(void) { return m_data; } + void nullval(const char* value); + char* nullval(void) { return m_nulval; } +}; + + +/***********************************************************************//** + * @brief GFitsTableBitCol class extension + ***************************************************************************/ +%extend GFitsTableBitCol { + char *__str__() { + static char str_buffer[1001]; + std::ostringstream buffer; + buffer << *self; + std::string str = buffer.str(); + strncpy(str_buffer, (char*)str.c_str(), 1001); + str_buffer[1000] = '\0'; + return str_buffer; + } + char get(const int& row) { + return (*self)(row); + } + char get(const int& row, const int& col) { + return (*self)(row, col); + } + void set(const int& row, const char& value) { + (*self)(row) = value; + } + void set(const int& row, const int& col, const char& value) { + (*self)(row, col) = value; + } + GFitsTableBitCol copy() { + return (*self); + } +}; diff --git a/pyext/GFitsTableBoolCol.i b/pyext/GFitsTableBoolCol.i new file mode 100644 index 0000000..2bbb215 --- /dev/null +++ b/pyext/GFitsTableBoolCol.i @@ -0,0 +1,76 @@ +/*************************************************************************** + * GFitsTableBoolCol.i - FITS table boolean column class SWIG definition * + * ----------------------------------------------------------------------- * + * copyright : (C) 2008-2010 by Jurgen Knodlseder * + * ----------------------------------------------------------------------- * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +/** + * @file GFitsTableBoolCol.i + * @brief GFitsTableBoolCol class SWIG file. + * @author J. Knodlseder + */ +%{ +/* Put headers and other declarations here that are needed for compilation */ +#include "GFitsTableBoolCol.hpp" +%} + + +/***********************************************************************//** + * @class GFitsTableBoolCol + * + * @brief SWIG interface for FITS table logical column + ***************************************************************************/ +class GFitsTableBoolCol : public GFitsTableCol { +public: + // Constructors and destructors + GFitsTableBoolCol(void); + GFitsTableBoolCol(const std::string& name, const int& length, + const int& size = 1); + GFitsTableBoolCol(const GFitsTableBoolCol& column); + virtual ~GFitsTableBoolCol(void); + + // Methods + std::string string(const int& row, const int& col = 0); + double real(const int& row, const int& col = 0); + int integer(const int& row, const int& col = 0); + bool* data(void) { return m_data; } + void nullval(const bool* value); + bool* nullval(void) { return m_nulval; } +}; + + +/***********************************************************************//** + * @brief GFitsTableBoolCol class extension + ***************************************************************************/ +%extend GFitsTableBoolCol { + char *__str__() { + static char str_buffer[1001]; + std::ostringstream buffer; + buffer << *self; + std::string str = buffer.str(); + strncpy(str_buffer, (char*)str.c_str(), 1001); + str_buffer[1000] = '\0'; + return str_buffer; + } + bool get(const int& row) { + return (*self)(row); + } + bool get(const int& row, const int& col) { + return (*self)(row, col); + } + void set(const int& row, const bool& value) { + (*self)(row) = value; + } + void set(const int& row, const int& col, const bool& value) { + (*self)(row, col) = value; + } + GFitsTableBoolCol copy() { + return (*self); + } +}; diff --git a/pyext/GFitsTableDblCol.i b/pyext/GFitsTableDblCol.i deleted file mode 100644 index d41e6a6..0000000 --- a/pyext/GFitsTableDblCol.i +++ /dev/null @@ -1,75 +0,0 @@ -/*************************************************************************** - * GFitsTableDblCol.i - FITS table double column class SWIG definiton * - * ----------------------------------------------------------------------- * - * copyright : (C) 2008 by Jurgen Knodlseder * - * ----------------------------------------------------------------------- * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ -/** - * @file GFitsTableDblCol.i - * @brief GFitsTableDblCol class SWIG file. - * @author J. Knodlseder - */ -%{ -/* Put headers and other declarations here that are needed for compilation */ -#include "GFitsTableDblCol.hpp" -%} - - -/***********************************************************************//** - * @class GFitsTableDblCol - * - * @brief SWIG interface for FITS table double precision column - ***************************************************************************/ -class GFitsTableDblCol : public GFitsTableCol { -public: - // Constructors and destructors - GFitsTableDblCol(); - GFitsTableDblCol(const std::string& name, const int& length, - const int& size = 1); - GFitsTableDblCol(const GFitsTableDblCol& column); - virtual ~GFitsTableDblCol(); - - // Methods - std::string string(const int& row, const int& inx = 0); - double real(const int& row, const int& inx = 0); - int integer(const int& row, const int& inx = 0); - double* data(void); - void set_nullval(const double* value); -}; - - -/***********************************************************************//** - * @brief GFitsTableDblCol class extension - ***************************************************************************/ -%extend GFitsTableDblCol { - char *__str__() { - static char str_buffer[1001]; - std::ostringstream buffer; - buffer << *self; - std::string str = buffer.str(); - strncpy(str_buffer, (char*)str.c_str(), 1001); - str_buffer[1000] = '\0'; - return str_buffer; - } - double get(const int& row) { - return (*self)(row); - } - double get(const int& row, const int& col) { - return (*self)(row, col); - } - void set(const int& row, const double& value) { - (*self)(row) = value; - } - void set(const int& row, const int& col, const double& value) { - (*self)(row, col) = value; - } - GFitsTableDblCol copy() { - return (*self); - } -}; diff --git a/pyext/GFitsTableDoubleCol.i b/pyext/GFitsTableDoubleCol.i new file mode 100644 index 0000000..cca02f4 --- /dev/null +++ b/pyext/GFitsTableDoubleCol.i @@ -0,0 +1,76 @@ +/*************************************************************************** + * GFitsTableDoubleCol.i - FITS table double column class SWIG definiton * + * ----------------------------------------------------------------------- * + * copyright (C) 2008-2010 by Jurgen Knodlseder * + * ----------------------------------------------------------------------- * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +/** + * @file GFitsTableDoubleCol.i + * @brief GFitsTableDoubleCol class SWIG file. + * @author J. Knodlseder + */ +%{ +/* Put headers and other declarations here that are needed for compilation */ +#include "GFitsTableDoubleCol.hpp" +%} + + +/***********************************************************************//** + * @class GFitsTableDoubleCol + * + * @brief SWIG interface for FITS table double precision column + ***************************************************************************/ +class GFitsTableDoubleCol : public GFitsTableCol { +public: + // Constructors and destructors + GFitsTableDoubleCol(void); + GFitsTableDoubleCol(const std::string& name, const int& length, + const int& size = 1); + GFitsTableDoubleCol(const GFitsTableDoubleCol& column); + virtual ~GFitsTableDoubleCol(void); + + // Methods + std::string string(const int& row, const int& inx = 0); + double real(const int& row, const int& inx = 0); + int integer(const int& row, const int& inx = 0); + double* data(void) { return m_data; } + void nullval(const double* value); + double* nullval(void) { return m_nulval; } +}; + + +/***********************************************************************//** + * @brief GFitsTableDoubleCol class extension + ***************************************************************************/ +%extend GFitsTableDoubleCol { + char *__str__() { + static char str_buffer[1001]; + std::ostringstream buffer; + buffer << *self; + std::string str = buffer.str(); + strncpy(str_buffer, (char*)str.c_str(), 1001); + str_buffer[1000] = '\0'; + return str_buffer; + } + double get(const int& row) { + return (*self)(row); + } + double get(const int& row, const int& col) { + return (*self)(row, col); + } + void set(const int& row, const double& value) { + (*self)(row) = value; + } + void set(const int& row, const int& col, const double& value) { + (*self)(row, col) = value; + } + GFitsTableDoubleCol copy() { + return (*self); + } +}; diff --git a/pyext/GFitsTableFloatCol.i b/pyext/GFitsTableFloatCol.i new file mode 100644 index 0000000..2ff5378 --- /dev/null +++ b/pyext/GFitsTableFloatCol.i @@ -0,0 +1,76 @@ +/*************************************************************************** + * GFitsTableFloatCol.i - FITS table float column class SWIG definition * + * ----------------------------------------------------------------------- * + * copyright (C) 2008-2010 by Jurgen Knodlseder * + * ----------------------------------------------------------------------- * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +/** + * @file GFitsTableFloatCol.i + * @brief GFitsTableFloatCol class SWIG file. + * @author J. Knodlseder + */ +%{ +/* Put headers and other declarations here that are needed for compilation */ +#include "GFitsTableFloatCol.hpp" +%} + + +/***********************************************************************//** + * @class GFitsTableFloatCol + * + * @brief SWIG interface for FITS table floating point column + ***************************************************************************/ +class GFitsTableFloatCol : public GFitsTableCol { +public: + // Constructors and destructors + GFitsTableFloatCol(void); + GFitsTableFloatCol(const std::string& name, const int& length, + const int& size = 1); + GFitsTableFloatCol(const GFitsTableFloatCol& column); + virtual ~GFitsTableFloatCol(void); + + // Methods + std::string string(const int& row, const int& col = 0); + double real(const int& row, const int& col = 0); + int integer(const int& row, const int& col = 0); + float* data(void) { return m_data; } + void nullval(const float* value); + float* nullval(void) { return m_nulval; } +}; + + +/***********************************************************************//** + * @brief GFitsTableFloatCol class extension + ***************************************************************************/ +%extend GFitsTableFloatCol { + char *__str__() { + static char str_buffer[1001]; + std::ostringstream buffer; + buffer << *self; + std::string str = buffer.str(); + strncpy(str_buffer, (char*)str.c_str(), 1001); + str_buffer[1000] = '\0'; + return str_buffer; + } + float get(const int& row) { + return (*self)(row); + } + float get(const int& row, const int& col) { + return (*self)(row, col); + } + void set(const int& row, const float& value) { + (*self)(row) = value; + } + void set(const int& row, const int& col, const float& value) { + (*self)(row, col) = value; + } + GFitsTableFloatCol copy() { + return (*self); + } +}; diff --git a/pyext/GFitsTableFltCol.i b/pyext/GFitsTableFltCol.i deleted file mode 100644 index 2120bcc..0000000 --- a/pyext/GFitsTableFltCol.i +++ /dev/null @@ -1,75 +0,0 @@ -/*************************************************************************** - * GFitsTableFltCol.i - FITS table float column class SWIG definition * - * ----------------------------------------------------------------------- * - * copyright : (C) 2008 by Jurgen Knodlseder * - * ----------------------------------------------------------------------- * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ -/** - * @file GFitsTableFltCol.i - * @brief GFitsTableFltCol class SWIG file. - * @author J. Knodlseder - */ -%{ -/* Put headers and other declarations here that are needed for compilation */ -#include "GFitsTableFltCol.hpp" -%} - - -/***********************************************************************//** - * @class GFitsTableFltCol - * - * @brief SWIG interface for FITS table floating point column - ***************************************************************************/ -class GFitsTableFltCol : public GFitsTableCol { -public: - // Constructors and destructors - GFitsTableFltCol(); - GFitsTableFltCol(const std::string& name, const int& length, - const int& size = 1); - GFitsTableFltCol(const GFitsTableFltCol& column); - virtual ~GFitsTableFltCol(); - - // Methods - std::string string(const int& row, const int& col = 0); - double real(const int& row, const int& col = 0); - int integer(const int& row, const int& col = 0); - float* data(void); - void set_nullval(const float* value); -}; - - -/***********************************************************************//** - * @brief GFitsTableFltCol class extension - ***************************************************************************/ -%extend GFitsTableFltCol { - char *__str__() { - static char str_buffer[1001]; - std::ostringstream buffer; - buffer << *self; - std::string str = buffer.str(); - strncpy(str_buffer, (char*)str.c_str(), 1001); - str_buffer[1000] = '\0'; - return str_buffer; - } - float get(const int& row) { - return (*self)(row); - } - float get(const int& row, const int& col) { - return (*self)(row, col); - } - void set(const int& row, const float& value) { - (*self)(row) = value; - } - void set(const int& row, const int& col, const float& value) { - (*self)(row, col) = value; - } - GFitsTableFltCol copy() { - return (*self); - } -}; diff --git a/pyext/GFitsTableLngCol.i b/pyext/GFitsTableLngCol.i deleted file mode 100644 index 92704b1..0000000 --- a/pyext/GFitsTableLngCol.i +++ /dev/null @@ -1,75 +0,0 @@ -/*************************************************************************** - * GFitsTableLngCol.i - FITS table long column class SWIG definiton * - * ----------------------------------------------------------------------- * - * copyright : (C) 2008 by Jurgen Knodlseder * - * ----------------------------------------------------------------------- * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ -/** - * @file GFitsTableLngCol.i - * @brief GFitsTableLngCol class SWIG file. - * @author J. Knodlseder - */ -%{ -/* Put headers and other declarations here that are needed for compilation */ -#include "GFitsTableLngCol.hpp" -%} - - -/***********************************************************************//** - * @class GFitsTableLngCol - * - * @brief SWIG interface for FITS table long integer column - ***************************************************************************/ -class GFitsTableLngCol : public GFitsTableCol { -public: - // Constructors and destructors - GFitsTableLngCol(); - GFitsTableLngCol(const std::string& name, const int& length, - const int& size = 1); - GFitsTableLngCol(const GFitsTableLngCol& column); - virtual ~GFitsTableLngCol(); - - // Methods - std::string string(const int& row, const int& col = 0); - double real(const int& row, const int& col = 0); - int integer(const int& row, const int& col = 0); - long* data(void); - void set_nullval(const long* value); -}; - - -/***********************************************************************//** - * @brief GFitsTableLngCol class extension - ***************************************************************************/ -%extend GFitsTableLngCol { - char *__str__() { - static char str_buffer[1001]; - std::ostringstream buffer; - buffer << *self; - std::string str = buffer.str(); - strncpy(str_buffer, (char*)str.c_str(), 1001); - str_buffer[1000] = '\0'; - return str_buffer; - } - long get(const int& row) { - return (*self)(row); - } - long get(const int& row, const int& col) { - return (*self)(row, col); - } - void set(const int& row, const long& value) { - (*self)(row) = value; - } - void set(const int& row, const int& col, const long& value) { - (*self)(row, col) = value; - } - GFitsTableLngCol copy() { - return (*self); - } -}; diff --git a/pyext/GFitsTableLogCol.i b/pyext/GFitsTableLogCol.i deleted file mode 100644 index 5b212ea..0000000 --- a/pyext/GFitsTableLogCol.i +++ /dev/null @@ -1,75 +0,0 @@ -/*************************************************************************** - * GFitsTableLogCol.i - FITS table logical column class SWIG definition * - * ----------------------------------------------------------------------- * - * copyright : (C) 2008 by Jurgen Knodlseder * - * ----------------------------------------------------------------------- * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ -/** - * @file GFitsTableLogCol.i - * @brief GFitsTableLogCol class SWIG file. - * @author J. Knodlseder - */ -%{ -/* Put headers and other declarations here that are needed for compilation */ -#include "GFitsTableLogCol.hpp" -%} - - -/***********************************************************************//** - * @class GFitsTableLogCol - * - * @brief SWIG interface for FITS table logical column - ***************************************************************************/ -class GFitsTableLogCol : public GFitsTableCol { -public: - // Constructors and destructors - GFitsTableLogCol(); - GFitsTableLogCol(const std::string& name, const int& length, - const int& size = 1); - GFitsTableLogCol(const GFitsTableLogCol& column); - virtual ~GFitsTableLogCol(); - - // Methods - std::string string(const int& row, const int& col = 0); - double real(const int& row, const int& col = 0); - int integer(const int& row, const int& col = 0); - char* data(void); - void set_nullval(const char* value); -}; - - -/***********************************************************************//** - * @brief GFitsTableLogCol class extension - ***************************************************************************/ -%extend GFitsTableLogCol { - char *__str__() { - static char str_buffer[1001]; - std::ostringstream buffer; - buffer << *self; - std::string str = buffer.str(); - strncpy(str_buffer, (char*)str.c_str(), 1001); - str_buffer[1000] = '\0'; - return str_buffer; - } - char get(const int& row) { - return (*self)(row); - } - char get(const int& row, const int& col) { - return (*self)(row, col); - } - void set(const int& row, const char& value) { - (*self)(row) = value; - } - void set(const int& row, const int& col, const char& value) { - (*self)(row, col) = value; - } - GFitsTableLogCol copy() { - return (*self); - } -}; diff --git a/pyext/GFitsTableLongCol.i b/pyext/GFitsTableLongCol.i new file mode 100644 index 0000000..c6196bb --- /dev/null +++ b/pyext/GFitsTableLongCol.i @@ -0,0 +1,76 @@ +/*************************************************************************** + * GFitsTableLongCol.i - FITS table long column class SWIG definiton * + * ----------------------------------------------------------------------- * + * copyright : (C) 2008-2010 by Jurgen Knodlseder * + * ----------------------------------------------------------------------- * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +/** + * @file GFitsTableLongCol.i + * @brief GFitsTableLongCol class SWIG file. + * @author J. Knodlseder + */ +%{ +/* Put headers and other declarations here that are needed for compilation */ +#include "GFitsTableLongCol.hpp" +%} + + +/***********************************************************************//** + * @class GFitsTableLongCol + * + * @brief SWIG interface for FITS table long integer column + ***************************************************************************/ +class GFitsTableLongCol : public GFitsTableCol { +public: + // Constructors and destructors + GFitsTableLongCol(void); + GFitsTableLongCol(const std::string& name, const int& length, + const int& size = 1); + GFitsTableLongCol(const GFitsTableLongCol& column); + virtual ~GFitsTableLongCol(void); + + // Methods + std::string string(const int& row, const int& col = 0); + double real(const int& row, const int& col = 0); + int integer(const int& row, const int& col = 0); + long* data(void) { return m_data; } + void nullval(const long* value); + long* nullval(void) { return m_nulval; } +}; + + +/***********************************************************************//** + * @brief GFitsTableLongCol class extension + ***************************************************************************/ +%extend GFitsTableLongCol { + char *__str__() { + static char str_buffer[1001]; + std::ostringstream buffer; + buffer << *self; + std::string str = buffer.str(); + strncpy(str_buffer, (char*)str.c_str(), 1001); + str_buffer[1000] = '\0'; + return str_buffer; + } + long get(const int& row) { + return (*self)(row); + } + long get(const int& row, const int& col) { + return (*self)(row, col); + } + void set(const int& row, const long& value) { + (*self)(row) = value; + } + void set(const int& row, const int& col, const long& value) { + (*self)(row, col) = value; + } + GFitsTableLongCol copy() { + return (*self); + } +}; diff --git a/pyext/GFitsTableLongLongCol.i b/pyext/GFitsTableLongLongCol.i new file mode 100644 index 0000000..5bb16b7 --- /dev/null +++ b/pyext/GFitsTableLongLongCol.i @@ -0,0 +1,76 @@ +/*************************************************************************** + * GFitsTableLongLongCol.i - FITS table long long column class SWIG def. * + * ----------------------------------------------------------------------- * + * copyright : (C) 2008-2010 by Jurgen Knodlseder * + * ----------------------------------------------------------------------- * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +/** + * @file GFitsTableLongLongCol.i + * @brief GFitsTableLongLongCol class SWIG file. + * @author J. Knodlseder + */ +%{ +/* Put headers and other declarations here that are needed for compilation */ +#include "GFitsTableLongLongCol.hpp" +%} + + +/***********************************************************************//** + * @class GFitsTableLongLongCol + * + * @brief SWIG interface for FITS table long integer column + ***************************************************************************/ +class GFitsTableLongLongCol : public GFitsTableCol { +public: + // Constructors and destructors + GFitsTableLongLongCol(void); + GFitsTableLongLongCol(const std::string& name, const int& length, + const int& size = 1); + GFitsTableLongLongCol(const GFitsTableLongLongCol& column); + virtual ~GFitsTableLongLongCol(void); + + // Methods + std::string string(const int& row, const int& col = 0); + double real(const int& row, const int& col = 0); + int integer(const int& row, const int& col = 0); + long long* data(void) { return m_data; } + void nullval(const long long* value); + long long* nullval(void) { return m_nulval; } +}; + + +/***********************************************************************//** + * @brief GFitsTableLongLongCol class extension + ***************************************************************************/ +%extend GFitsTableLongLongCol { + char *__str__() { + static char str_buffer[1001]; + std::ostringstream buffer; + buffer << *self; + std::string str = buffer.str(); + strncpy(str_buffer, (char*)str.c_str(), 1001); + str_buffer[1000] = '\0'; + return str_buffer; + } + long long get(const int& row) { + return (*self)(row); + } + long long get(const int& row, const int& col) { + return (*self)(row, col); + } + void set(const int& row, const long long& value) { + (*self)(row) = value; + } + void set(const int& row, const int& col, const long long& value) { + (*self)(row, col) = value; + } + GFitsTableLongLongCol copy() { + return (*self); + } +}; diff --git a/pyext/GFitsTableShortCol.i b/pyext/GFitsTableShortCol.i new file mode 100644 index 0000000..87108e3 --- /dev/null +++ b/pyext/GFitsTableShortCol.i @@ -0,0 +1,76 @@ +/*************************************************************************** + * GFitsTableShortCol.i - FITS table short column class SWIG definition * + * ----------------------------------------------------------------------- * + * copyright : (C) 2008-2010 by Jurgen Knodlseder * + * ----------------------------------------------------------------------- * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +/** + * @file GFitsTableShortCol.i + * @brief GFitsTableShortCol class SWIG file. + * @author J. Knodlseder + */ +%{ +/* Put headers and other declarations here that are needed for compilation */ +#include "GFitsTableShortCol.hpp" +%} + + +/***********************************************************************//** + * @class GFitsTableShortCol + * + * @brief SWIG interface for FITS table short integer column + ***************************************************************************/ +class GFitsTableShortCol : public GFitsTableCol { +public: + // Constructors and destructors + GFitsTableShortCol(void); + GFitsTableShortCol(const std::string& name, const int& length, + const int& size = 1); + GFitsTableShortCol(const GFitsTableShortCol& column); + virtual ~GFitsTableShortCol(void); + + // Methods + std::string string(const int& row, const int& col = 0); + double real(const int& row, const int& col = 0); + int integer(const int& row, const int& col = 0); + short* data(void) { return m_data; } + void nullval(const short* value); + short* nullval(void) { return m_nulval; } +}; + + +/***********************************************************************//** + * @brief GFitsTableShortCol class extension + ***************************************************************************/ +%extend GFitsTableShortCol { + char *__str__() { + static char str_buffer[1001]; + std::ostringstream buffer; + buffer << *self; + std::string str = buffer.str(); + strncpy(str_buffer, (char*)str.c_str(), 1001); + str_buffer[1000] = '\0'; + return str_buffer; + } + short get(const int& row) { + return (*self)(row); + } + short get(const int& row, const int& col) { + return (*self)(row, col); + } + void set(const int& row, const short& value) { + (*self)(row) = value; + } + void set(const int& row, const int& col, const short& value) { + (*self)(row, col) = value; + } + GFitsTableShortCol copy() { + return (*self); + } +}; diff --git a/pyext/GFitsTableShtCol.i b/pyext/GFitsTableShtCol.i deleted file mode 100644 index bffa797..0000000 --- a/pyext/GFitsTableShtCol.i +++ /dev/null @@ -1,75 +0,0 @@ -/*************************************************************************** - * GFitsTableShtCol.i - FITS table short column class SWIG definition * - * ----------------------------------------------------------------------- * - * copyright : (C) 2008 by Jurgen Knodlseder * - * ----------------------------------------------------------------------- * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ -/** - * @file GFitsTableShtCol.i - * @brief GFitsTableShtCol class SWIG file. - * @author J. Knodlseder - */ -%{ -/* Put headers and other declarations here that are needed for compilation */ -#include "GFitsTableShtCol.hpp" -%} - - -/***********************************************************************//** - * @class GFitsTableShtCol - * - * @brief SWIG interface for FITS table short integer column - ***************************************************************************/ -class GFitsTableShtCol : public GFitsTableCol { -public: - // Constructors and destructors - GFitsTableShtCol(); - GFitsTableShtCol(const std::string& name, const int& length, - const int& size = 1); - GFitsTableShtCol(const GFitsTableShtCol& column); - virtual ~GFitsTableShtCol(); - - // Methods - std::string string(const int& row, const int& col = 0); - double real(const int& row, const int& col = 0); - int integer(const int& row, const int& col = 0); - short* data(void); - void set_nullval(const short* value); -}; - - -/***********************************************************************//** - * @brief GFitsTableShtCol class extension - ***************************************************************************/ -%extend GFitsTableShtCol { - char *__str__() { - static char str_buffer[1001]; - std::ostringstream buffer; - buffer << *self; - std::string str = buffer.str(); - strncpy(str_buffer, (char*)str.c_str(), 1001); - str_buffer[1000] = '\0'; - return str_buffer; - } - short get(const int& row) { - return (*self)(row); - } - short get(const int& row, const int& col) { - return (*self)(row, col); - } - void set(const int& row, const short& value) { - (*self)(row) = value; - } - void set(const int& row, const int& col, const short& value) { - (*self)(row, col) = value; - } - GFitsTableShtCol copy() { - return (*self); - } -}; diff --git a/pyext/GFitsTableStrCol.i b/pyext/GFitsTableStrCol.i deleted file mode 100644 index 72f3e27..0000000 --- a/pyext/GFitsTableStrCol.i +++ /dev/null @@ -1,75 +0,0 @@ -/*************************************************************************** - * GFitsTableStrCol.i - FITS table string column class SWIG definition * - * ----------------------------------------------------------------------- * - * copyright : (C) 2008 by Jurgen Knodlseder * - * ----------------------------------------------------------------------- * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ -/** - * @file GFitsTableStrCol.i - * @brief GFitsTableStrCol class SWIG file. - * @author J. Knodlseder - */ -%{ -/* Put headers and other declarations here that are needed for compilation */ -#include "GFitsTableStrCol.hpp" -%} - - -/***********************************************************************//** - * @class GFitsTableStrCol - * - * @brief SWIG interface for FITS table string column - ***************************************************************************/ -class GFitsTableStrCol : public GFitsTableCol { -public: - // Constructors and destructors - GFitsTableStrCol(); - GFitsTableStrCol(const std::string& name, const int& length, - const int& width, const int& size = 1); - GFitsTableStrCol(const GFitsTableStrCol& column); - ~GFitsTableStrCol(); - - // Methods - std::string string(const int& row, const int& col = 0); - double real(const int& row, const int& col = 0); - int integer(const int& row, const int& col = 0); - std::string* data(void); - void set_nullval(const std::string string); -}; - - -/***********************************************************************//** - * @brief GFitsTableStrCol class extension - ***************************************************************************/ -%extend GFitsTableStrCol { - char *__str__() { - static char str_buffer[1001]; - std::ostringstream buffer; - buffer << *self; - std::string str = buffer.str(); - strncpy(str_buffer, (char*)str.c_str(), 1001); - str_buffer[1000] = '\0'; - return str_buffer; - } - std::string get(const int& row) { - return (*self)(row); - } - std::string get(const int& row, const int& col) { - return (*self)(row, col); - } - void set(const int& row, const std::string& value) { - (*self)(row) = value; - } - void set(const int& row, const int& col, const std::string& value) { - (*self)(row, col) = value; - } - GFitsTableStrCol copy() { - return (*self); - } -}; diff --git a/pyext/GFitsTableStringCol.i b/pyext/GFitsTableStringCol.i new file mode 100644 index 0000000..29e485e --- /dev/null +++ b/pyext/GFitsTableStringCol.i @@ -0,0 +1,76 @@ +/*************************************************************************** + * GFitsTableStringCol.i - FITS table string column class SWIG definition * + * ----------------------------------------------------------------------- * + * copyright : (C) 2008-2010 by Jurgen Knodlseder * + * ----------------------------------------------------------------------- * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +/** + * @file GFitsTableStringCol.i + * @brief GFitsTableStringCol class SWIG file. + * @author J. Knodlseder + */ +%{ +/* Put headers and other declarations here that are needed for compilation */ +#include "GFitsTableStringCol.hpp" +%} + + +/***********************************************************************//** + * @class GFitsTableStringCol + * + * @brief SWIG interface for FITS table string column + ***************************************************************************/ +class GFitsTableStringCol : public GFitsTableCol { +public: + // Constructors and destructors + GFitsTableStringCol(void); + GFitsTableStringCol(const std::string& name, const int& length, + const int& width, const int& size = 1); + GFitsTableStringCol(const GFitsTableStringCol& column); + virtual ~GFitsTableStringCol(void); + + // Methods + std::string string(const int& row, const int& col = 0); + double real(const int& row, const int& col = 0); + int integer(const int& row, const int& col = 0); + std::string* data(void) { return m_data; } + void nullval(const std::string value); + char* nullval(void) { return m_nulval; } +}; + + +/***********************************************************************//** + * @brief GFitsTableStringCol class extension + ***************************************************************************/ +%extend GFitsTableStringCol { + char *__str__() { + static char str_buffer[1001]; + std::ostringstream buffer; + buffer << *self; + std::string str = buffer.str(); + strncpy(str_buffer, (char*)str.c_str(), 1001); + str_buffer[1000] = '\0'; + return str_buffer; + } + std::string get(const int& row) { + return (*self)(row); + } + std::string get(const int& row, const int& col) { + return (*self)(row, col); + } + void set(const int& row, const std::string& value) { + (*self)(row) = value; + } + void set(const int& row, const int& col, const std::string& value) { + (*self)(row, col) = value; + } + GFitsTableStringCol copy() { + return (*self); + } +}; diff --git a/pyext/GFitsTableULongCol.i b/pyext/GFitsTableULongCol.i new file mode 100644 index 0000000..daaac7e --- /dev/null +++ b/pyext/GFitsTableULongCol.i @@ -0,0 +1,76 @@ +/*************************************************************************** + * GFitsTableULongCol.i - FITS table unsigned long column class SWIG def. * + * ----------------------------------------------------------------------- * + * copyright : (C) 2010 by Jurgen Knodlseder * + * ----------------------------------------------------------------------- * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +/** + * @file GFitsTableULongCol.i + * @brief GFitsTableULongCol class SWIG file. + * @author J. Knodlseder + */ +%{ +/* Put headers and other declarations here that are needed for compilation */ +#include "GFitsTableULongCol.hpp" +%} + + +/***********************************************************************//** + * @class GFitsTableULongCol + * + * @brief SWIG interface for FITS table long integer column + ***************************************************************************/ +class GFitsTableULongCol : public GFitsTableCol { +public: + // Constructors and destructors + GFitsTableULongCol(void); + GFitsTableULongCol(const std::string& name, const int& length, + const int& size = 1); + GFitsTableULongCol(const GFitsTableULongCol& column); + virtual ~GFitsTableULongCol(void); + + // Methods + std::string string(const int& row, const int& col = 0); + double real(const int& row, const int& col = 0); + int integer(const int& row, const int& col = 0); + unsigned long* data(void) { return m_data; } + void nullval(const unsigned long* value); + unsigned long* nullval(void) { return m_nulval; } +}; + + +/***********************************************************************//** + * @brief GFitsTableULongCol class extension + ***************************************************************************/ +%extend GFitsTableULongCol { + char *__str__() { + static char str_buffer[1001]; + std::ostringstream buffer; + buffer << *self; + std::string str = buffer.str(); + strncpy(str_buffer, (char*)str.c_str(), 1001); + str_buffer[1000] = '\0'; + return str_buffer; + } + unsigned long get(const int& row) { + return (*self)(row); + } + unsigned long get(const int& row, const int& col) { + return (*self)(row, col); + } + void set(const int& row, const unsigned long& value) { + (*self)(row) = value; + } + void set(const int& row, const int& col, const unsigned long& value) { + (*self)(row, col) = value; + } + GFitsTableULongCol copy() { + return (*self); + } +}; diff --git a/pyext/GFitsTableUShortCol.i b/pyext/GFitsTableUShortCol.i new file mode 100644 index 0000000..061a82d --- /dev/null +++ b/pyext/GFitsTableUShortCol.i @@ -0,0 +1,76 @@ +/*************************************************************************** + * GFitsTableUShortCol.i - FITS table unsigned short column class SWIG def* + * ----------------------------------------------------------------------- * + * copyright : (C) 2008-2010 by Jurgen Knodlseder * + * ----------------------------------------------------------------------- * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +/** + * @file GFitsTableUShortCol.i + * @brief GFitsTableUShortCol class SWIG file. + * @author J. Knodlseder + */ +%{ +/* Put headers and other declarations here that are needed for compilation */ +#include "GFitsTableUShortCol.hpp" +%} + + +/***********************************************************************//** + * @class GFitsTableUShortCol + * + * @brief SWIG interface for FITS table short integer column + ***************************************************************************/ +class GFitsTableUShortCol : public GFitsTableCol { +public: + // Constructors and destructors + GFitsTableUShortCol(void); + GFitsTableUShortCol(const std::string& name, const int& length, + const int& size = 1); + GFitsTableUShortCol(const GFitsTableUShortCol& column); + virtual ~GFitsTableUShortCol(void); + + // Methods + std::string string(const int& row, const int& col = 0); + double real(const int& row, const int& col = 0); + int integer(const int& row, const int& col = 0); + unsigned short* data(void) { return m_data; } + void nullval(const unsigned short* value); + unsigned short* nullval(void) { return m_nulval; } +}; + + +/***********************************************************************//** + * @brief GFitsTableUShortCol class extension + ***************************************************************************/ +%extend GFitsTableUShortCol { + char *__str__() { + static char str_buffer[1001]; + std::ostringstream buffer; + buffer << *self; + std::string str = buffer.str(); + strncpy(str_buffer, (char*)str.c_str(), 1001); + str_buffer[1000] = '\0'; + return str_buffer; + } + unsigned short get(const int& row) { + return (*self)(row); + } + unsigned short get(const int& row, const int& col) { + return (*self)(row, col); + } + void set(const int& row, const unsigned short& value) { + (*self)(row) = value; + } + void set(const int& row, const int& col, const unsigned short& value) { + (*self)(row, col) = value; + } + GFitsTableUShortCol copy() { + return (*self); + } +}; diff --git a/pyext/gammalib.i b/pyext/gammalib.i index b8aa772..0bcc740 100755 --- a/pyext/gammalib.i +++ b/pyext/gammalib.i @@ -41,12 +41,16 @@ #include "GFitsAsciiTable.i" #include "GFitsBinTable.i" #include "GFitsTableCol.i" -#include "GFitsTableLogCol.i" -#include "GFitsTableDblCol.i" -#include "GFitsTableFltCol.i" -#include "GFitsTableLngCol.i" -#include "GFitsTableShtCol.i" -#include "GFitsTableStrCol.i" +#include "GFitsTableBitCol.i" +#include "GFitsTableBoolCol.i" +#include "GFitsTableDoubleCol.i" +#include "GFitsTableFloatCol.i" +#include "GFitsTableULongCol.i" +#include "GFitsTableLongCol.i" +#include "GFitsTableUShortCol.i" +#include "GFitsTableLongLongCol.i" +#include "GFitsTableShortCol.i" +#include "GFitsTableStringCol.i" /* __ Application module _________________________________________________ */ #include "GApplication.i" diff --git a/src/fits/GFitsTableBitCol.cpp b/src/fits/GFitsTableBitCol.cpp index 4eac98b..b54d0a9 100644 --- a/src/fits/GFitsTableBitCol.cpp +++ b/src/fits/GFitsTableBitCol.cpp @@ -21,9 +21,6 @@ #include "GFitsTableBitCol.hpp" /* __ Method name definitions ____________________________________________ */ -#define G_STRING "GFitsTableBitCol::string(const int&, const int&)" -#define G_REAL "GFitsTableBitCol::real(const int&, const int&)" -#define G_INTEGER "GFitsTableBitCol::integer(const int&, const int&)" /* __ Macros _____________________________________________________________ */ @@ -144,23 +141,15 @@ GFitsTableBitCol& GFitsTableBitCol::operator= (const GFitsTableBitCol& column) * @param[in] row Row of column to access. * @param[in] inx Vector index in column row to access * - * Provides access to data in a column. No range checking is performed. - * Use one of - * GFitsTableBitCol::string(ix,iy), - * GFitsTableBitCol::real(ix,iy) or - * GFitsTableBitCol::integer(ix,iy) - * if range checking is required. + * Provides access to data in a column. ***************************************************************************/ char& GFitsTableBitCol::operator() (const int& row, const int& inx) { // If data are not available then load them now if (m_data == NULL) fetch_data(); - // Calculate pixel offset - int offset = row * m_number + inx; - // Return data bin - return m_data[offset]; + return m_data[offset(row, inx)]; } @@ -170,24 +159,15 @@ char& GFitsTableBitCol::operator() (const int& row, const int& inx) * @param[in] row Row of column to access. * @param[in] inx Vector index in column row to access * - * Provides access to data in a column. No range checking is performed. - * Use one of - * GFitsTableBitCol::string(ix,iy), - * GFitsTableBitCol::real(ix,iy) or - * GFitsTableBitCol::integer(ix,iy) - * if range checking is required. + * Provides access to data in a column. ***************************************************************************/ -const char& GFitsTableBitCol::operator() (const int& row, const int& inx) - const +const char& GFitsTableBitCol::operator() (const int& row, const int& inx) const { // If data are not available then load them now if (m_data == NULL) ((GFitsTableBitCol*)this)->fetch_data(); - // Calculate pixel offset - int offset = row * m_number + inx; - // Return data bin - return m_data[offset]; + return m_data[offset(row, inx)]; } @@ -203,9 +183,6 @@ const char& GFitsTableBitCol::operator() (const int& row, const int& inx) * @param[in] row Table row. * @param[in] inx Table column vector index. * - * @exception GException::out_of_range - * Table row or vector index are out of valid range. - * * Returns value of specified row and vector index as string. ***************************************************************************/ std::string GFitsTableBitCol::string(const int& row, const int& inx) @@ -213,19 +190,8 @@ std::string GFitsTableBitCol::string(const int& row, const int& inx) // If data are not available then load them now if (m_data == NULL) fetch_data(); - // Check row value - if (row < 0 || row >= m_length) - throw GException::out_of_range(G_STRING, row, 0, m_length-1); - - // Check inx value - if (inx < 0 || inx >= m_number) - throw GException::out_of_range(G_STRING, inx, 0, m_number-1); - - // Get index - int offset = row * m_number + inx; - - // Convert Bit into string - std::string result = (m_data[offset]) ? "1" : "0"; + // Convert bit into string + std::string result = (m_data[offset(row,inx)]) ? "1" : "0"; // Return value return result; @@ -238,9 +204,6 @@ std::string GFitsTableBitCol::string(const int& row, const int& inx) * @param[in] row Table row. * @param[in] inx Table column vector index. * - * @exception GException::out_of_range - * Table row or vector index are out of valid range. - * * Returns value of specified row and vector index as double precision. ***************************************************************************/ double GFitsTableBitCol::real(const int& row, const int& inx) @@ -248,19 +211,8 @@ double GFitsTableBitCol::real(const int& row, const int& inx) // If data are not available then load them now if (m_data == NULL) fetch_data(); - // Check row value - if (row < 0 || row >= m_length) - throw GException::out_of_range(G_REAL, row, 0, m_length-1); - - // Check inx value - if (inx < 0 || inx >= m_number) - throw GException::out_of_range(G_REAL, inx, 0, m_number-1); - - // Get index - int offset = row * m_number + inx; - - // Convert Bit into double - double value = (double)m_data[offset]; + // Convert bit into double + double value = (double)m_data[offset(row,inx)]; // Return value return value; @@ -273,9 +225,6 @@ double GFitsTableBitCol::real(const int& row, const int& inx) * @param[in] row Table row. * @param[in] inx Table column vector index. * - * @exception GException::out_of_range - * Table row or vector index are out of valid range. - * * Returns value of specified row and vector index as integer. ***************************************************************************/ int GFitsTableBitCol::integer(const int& row, const int& inx) @@ -283,19 +232,8 @@ int GFitsTableBitCol::integer(const int& row, const int& inx) // If data are not available then load them now if (m_data == NULL) fetch_data(); - // Check row value - if (row < 0 || row >= m_length) - throw GException::out_of_range(G_INTEGER, row, 0, m_length-1); - - // Check col value - if (inx < 0 || inx >= m_number) - throw GException::out_of_range(G_INTEGER, inx, 0, m_number-1); - - // Get index - int offset = row * m_number + inx; - - // Convert Bit into int - int value = (int)m_data[offset]; + // Convert bit into int + int value = (int)m_data[offset(row,inx)]; // Return value return value; @@ -303,44 +241,30 @@ int GFitsTableBitCol::integer(const int& row, const int& inx) /***********************************************************************//** - * @brief Return pointer to column - ***************************************************************************/ -char* GFitsTableBitCol::data(void) -{ - return m_data; -} - - -/***********************************************************************//** * @brief Set NULL value * * @param[in] value Pointer on NULL value * * Allows the specification of the FITS table NULL value. If value=NULL the * data will not be screened for NULL values. + * + * @todo To correctly reflect the NULL value in the data, the column should + * be reloaded. However, the column may have been changed, so in principle + * saving is needed. However, we may not want to store the data, hence saving + * is also not desired. We thus have to develop a method to update the + * column information for a new NULL value in place ... ***************************************************************************/ -void GFitsTableBitCol::set_nullval(const char* value) +void GFitsTableBitCol::nullval(const char* value) { - // If NULL value is empty then reset the NULL value - if (value == NULL) { - if (m_nulval != NULL) delete m_nulval; - m_nulval = NULL; - } + // Allocate nul value + alloc_nulval(value); - // ... otherwise copy value into NULL value - else { - if (m_nulval != NULL) delete m_nulval; - m_nulval = new char; - *m_nulval = *value; - } + // Update column +// if (m_data != NULL) { +// save(); +// load(); +// } - // Re-load column -/* - if (m_data != NULL) { - save(); - load(); - } -*/ // Return return; } @@ -376,8 +300,8 @@ void GFitsTableBitCol::copy_members(const GFitsTableBitCol& column) { // Fetch column data if not yet fetched. The casting circumvents the // const correctness - if (column.m_data == NULL) - ((GFitsTableBitCol*)(&column))->fetch_data(); + bool not_loaded = (column.m_data == NULL); + if (not_loaded) ((GFitsTableBitCol*)(&column))->fetch_data(); // Copy attributes m_type = column.m_type; @@ -391,11 +315,12 @@ void GFitsTableBitCol::copy_members(const GFitsTableBitCol& column) } // Copy NULL value - if (column.m_nulval != NULL) { - if (m_nulval != NULL) delete m_nulval; - m_nulval = new char; - *m_nulval = *column.m_nulval; - } + alloc_nulval(column.m_nulval); + + // Small memory option: release column if it was fetch above + #if defined(G_SMALL_MEMORY) + if (not_loaded) ((GFitsTableBitCol*)(&column))->release_data(); + #endif // Return return; @@ -415,24 +340,8 @@ void GFitsTableBitCol::free_members(void) m_data = NULL; m_nulval = NULL; - // Return - return; -} - - -/***********************************************************************//** - * @brief Save table column into FITS file - * - * The table column is only saved if it is linked to a FITS file and if the - * data are indeed present in the class instance. This avoids saving of data - * that have not been modified. - * - * Refer to GFitsTableCol::save_column() for more information. - ***************************************************************************/ -void GFitsTableBitCol::save(void) -{ - // Save column - save_column(); + // Reset load flag + m_size = 0; // Return return; @@ -507,14 +416,37 @@ void GFitsTableBitCol::alloc_data(void) /***********************************************************************//** - * @brief Initialise column data + * @brief Release column data ***************************************************************************/ -void GFitsTableBitCol::init_data(void) +void GFitsTableBitCol::release_data(void) { - // Initialise data if they exist - if (m_data != NULL) { - for (int i = 0; i < m_size; ++i) - m_data[i] = 0; + // Free any existing memory + if (m_data != NULL) delete [] m_data; + + // Mark pointer as free and reset loaded vector size + m_data = NULL; + m_size = 0; + + // Return + return; +} + + +/***********************************************************************//** + * @brief Allocates null value + ***************************************************************************/ +void GFitsTableBitCol::alloc_nulval(const char* value) +{ + // Free any existing memory + if (m_nulval != NULL) delete m_nulval; + + // Mark pointer as free + m_nulval = NULL; + + // If we have valid value, allocate and set nul value + if (value != NULL) { + m_nulval = new char; + *m_nulval = *value; } // Return @@ -523,18 +455,15 @@ void GFitsTableBitCol::init_data(void) /***********************************************************************//** - * @brief Fetch column data - * - * If a FITS file is attached to the column the data are loaded into memory - * from the FITS file. If no FITS file is attached, memory is allocated - * to hold the column data and all cells are set to 0. - * - * Refer to GFitsTableCol::load_column for more information. + * @brief Initialise column data ***************************************************************************/ -void GFitsTableBitCol::fetch_data(void) +void GFitsTableBitCol::init_data(void) { - // Save column - load_column(); + // Initialise data if they exist + if (m_data != NULL) { + for (int i = 0; i < m_size; ++i) + m_data[i] = 0; + } // Return return; @@ -550,8 +479,8 @@ void GFitsTableBitCol::fetch_data(void) /***********************************************************************//** * @brief Output operator * - * @param[in] os Output stream - * @param[in] column Column to put in output stream + * @param[in] os Output stream. + * @param[in] column Column to put in output stream. ***************************************************************************/ std::ostream& operator<< (std::ostream& os, const GFitsTableBitCol& column) { diff --git a/src/fits/GFitsTableBoolCol.cpp b/src/fits/GFitsTableBoolCol.cpp new file mode 100644 index 0000000..cb6c8b5 --- /dev/null +++ b/src/fits/GFitsTableBoolCol.cpp @@ -0,0 +1,601 @@ +/*************************************************************************** + * GFitsTableBoolCol.cpp - FITS table Boolean column class * + * ----------------------------------------------------------------------- * + * copyright (C) 2010 by Jurgen Knodlseder * + * ----------------------------------------------------------------------- * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +/* __ Includes ___________________________________________________________ */ +#ifdef HAVE_CONFIG_H +#include +#endif +#include +#include "GException.hpp" +#include "GTools.hpp" +#include "GFitsTableBoolCol.hpp" + +/* __ Method name definitions ____________________________________________ */ + +/* __ Macros _____________________________________________________________ */ + +/* __ Coding definitions _________________________________________________ */ + +/* __ Debug definitions __________________________________________________ */ + + +/*========================================================================== + = = + = Constructors/destructors = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Constructor + ***************************************************************************/ +GFitsTableBoolCol::GFitsTableBoolCol(void) : GFitsTableCol() +{ + // Initialise class members for clean destruction + init_members(); + + // Return + return; +} + + +/***********************************************************************//** + * @brief Constructor + * + * @param[in] name Name of column. + * @param[in] length Length of column. + * @param[in] size Vector size of column. + ***************************************************************************/ +GFitsTableBoolCol::GFitsTableBoolCol(const std::string& name, + const int& length, + const int& size) + : GFitsTableCol(name, length, size, 2) +{ + // Initialise class members for clean destruction + init_members(); + + // Return + return; +} + + +/***********************************************************************//** + * @brief Copy constructor + * + * @param[in] column Column from which class instance should be built. + ***************************************************************************/ +GFitsTableBoolCol::GFitsTableBoolCol(const GFitsTableBoolCol& column) + : GFitsTableCol(column) +{ + // Initialise class members for clean destruction + init_members(); + + // Copy members + copy_members(column); + + // Return + return; +} + + +/***********************************************************************//** + * @brief Destructor + ***************************************************************************/ +GFitsTableBoolCol::~GFitsTableBoolCol(void) +{ + // Free members + free_members(); + + // Return + return; +} + + +/*========================================================================== + = = + = Operators = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Assignment operator + * + * @param[in] column Column which should be assigned + ***************************************************************************/ +GFitsTableBoolCol& GFitsTableBoolCol::operator= (const GFitsTableBoolCol& column) +{ + // Execute only if object is not identical + if (this != &column) { + + // Copy base class members + this->GFitsTableCol::operator=(column); + + // Free members + free_members(); + + // Initialise private members for clean destruction + init_members(); + + // Copy members + copy_members(column); + + } // endif: object was not identical + + // Return this object + return *this; +} + + +/***********************************************************************//** + * @brief Column data access operator + * + * @param[in] row Row of column to access. + * @param[in] inx Vector index in column row to access + * + * Provides access to data in a column. + ***************************************************************************/ +bool& GFitsTableBoolCol::operator() (const int& row, const int& inx) +{ + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Return data bin + return m_data[offset(row, inx)]; +} + + +/***********************************************************************//** + * @brief Column data access operator (const variant) + * + * @param[in] row Row of column to access. + * @param[in] inx Vector index in column row to access + * + * Provides access to data in a column. + ***************************************************************************/ +const bool& GFitsTableBoolCol::operator() (const int& row, const int& inx) const +{ + // If data are not available then load them now + if (m_data == NULL) ((GFitsTableBoolCol*)this)->fetch_data(); + + // Return data bin + return m_data[offset(row, inx)]; +} + + +/*========================================================================== + = = + = Public methods = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Get string value + * + * @param[in] row Table row. + * @param[in] inx Table column vector index. + * + * Returns value of specified row and vector index as string. + ***************************************************************************/ +std::string GFitsTableBoolCol::string(const int& row, const int& inx) +{ + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Convert bool into string + std::string result = (m_data[offset(row,inx)]) ? "T" : "F"; + + // Return value + return result; +} + + +/***********************************************************************//** + * @brief Get double precision value + * + * @param[in] row Table row. + * @param[in] inx Table column vector index. + * + * Returns value of specified row and vector index as double precision. + ***************************************************************************/ +double GFitsTableBoolCol::real(const int& row, const int& inx) +{ + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Convert bool into double + double value = (double)m_data[offset(row,inx)]; + + // Return value + return value; +} + + +/***********************************************************************//** + * @brief Get integer value + * + * @param[in] row Table row. + * @param[in] inx Table column vector index. + * + * Returns value of specified row and vector index as integer. + ***************************************************************************/ +int GFitsTableBoolCol::integer(const int& row, const int& inx) +{ + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Convert bool into int + int value = (int)m_data[offset(row,inx)]; + + // Return value + return value; +} + + +/***********************************************************************//** + * @brief Set NULL value + * + * @param[in] value Pointer on NULL value + * + * Allows the specification of the FITS table NULL value. If value=NULL the + * data will not be screened for NULL values. + * + * @todo To correctly reflect the NULL value in the data, the column should + * be reloaded. However, the column may have been changed, so in principle + * saving is needed. However, we may not want to store the data, hence saving + * is also not desired. We thus have to develop a method to update the + * column information for a new NULL value in place ... + ***************************************************************************/ +void GFitsTableBoolCol::nullval(const bool* value) +{ + // Allocate nul value + alloc_nulval(value); + + // Update column +// if (m_data != NULL) { +// save(); +// load(); +// } + + // Return + return; +} + + +/*========================================================================== + = = + = Private methods = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Initialise class members + ***************************************************************************/ +void GFitsTableBoolCol::init_members(void) +{ + // Initialise members + m_type = __TLOGICAL; + m_data = NULL; + m_buffer = NULL; + m_nulval = NULL; + + // Return + return; +} + + +/***********************************************************************//** + * @brief Copy class members + * + * @param[in] column Column for which members should be copied. + ***************************************************************************/ +void GFitsTableBoolCol::copy_members(const GFitsTableBoolCol& column) +{ + // Fetch column data if not yet fetched. The casting circumvents the + // const correctness + bool not_loaded = (column.m_data == NULL); + if (not_loaded) ((GFitsTableBoolCol*)(&column))->fetch_data(); + + // Copy attributes + m_type = column.m_type; + m_size = column.m_size; + + // Copy column data + if (column.m_data != NULL && m_size > 0) { + alloc_data(); + for (int i = 0; i < m_size; ++i) + m_data[i] = column.m_data[i]; + } + + // Copy NULL value + alloc_nulval(column.m_nulval); + + // Small memory option: release column if it was fetch above + #if defined(G_SMALL_MEMORY) + if (not_loaded) ((GFitsTableBoolCol*)(&column))->release_data(); + #endif + + // Return + return; +} + + +/***********************************************************************//** + * @brief Delete class members + ***************************************************************************/ +void GFitsTableBoolCol::free_members(void) +{ + // Free memory + if (m_data != NULL) delete [] m_data; + if (m_nulval != NULL) delete m_nulval; + + // Mark memory as freed + m_data = NULL; + m_nulval = NULL; + + // Reset load flag + m_size = 0; + + // Free buffer + free_buffer(); + + // Return + return; +} + + +/***********************************************************************//** + * @brief Save table column into FITS file + * + * The table column is only saved if it is linked to a FITS file and if the + * data are indeed present in the class instance. This avoids saving of data + * that have not been modified. + * + * Refer to GFitsTableCol::save_column() for more information. + ***************************************************************************/ +void GFitsTableBoolCol::save(void) +{ + // Free buffer + free_buffer(); + + // Allocate buffer + alloc_buffer(); + + // Transfer string into buffer + for (int i = 0; i < m_size; ++i) + m_buffer[i] = (char)m_data[i]; + + // Save column + save_column(); + + // Free buffer + free_buffer(); + + // Return + return; +} + + +/***********************************************************************//** + * @brief Clone column + ***************************************************************************/ +GFitsTableBoolCol* GFitsTableBoolCol::clone(void) const +{ + return new GFitsTableBoolCol(*this); +} + + +/***********************************************************************//** + * @brief Returns format string of ASCII table + ***************************************************************************/ +std::string GFitsTableBoolCol::ascii_format(void) const +{ + // Initialize format string + std::string format; + + // Set type code + format.append("L"); + + // Set width + format.append(str(m_width)); + + // Return format + return format; +} + + +/***********************************************************************//** + * @brief Returns format string of binary table + ***************************************************************************/ +std::string GFitsTableBoolCol::binary_format(void) const +{ + // Initialize format string + std::string format; + + // Set number of elements + format.append(str(m_number)); + + // Set type code + format.append("L"); + + // Return format + return format; +} + + +/***********************************************************************//** + * @brief Allocates column data + ***************************************************************************/ +void GFitsTableBoolCol::alloc_data(void) +{ + // Free any existing memory + if (m_data != NULL) delete [] m_data; + + // Mark pointer as free + m_data = NULL; + + // Allocate new data + if (m_size > 0) + m_data = new bool[m_size]; + + // Return + return; +} + + +/***********************************************************************//** + * @brief Release column data + ***************************************************************************/ +void GFitsTableBoolCol::release_data(void) +{ + // Free any existing memory + if (m_data != NULL) delete [] m_data; + + // Mark pointer as free and reset loaded vector size + m_data = NULL; + m_size = 0; + + // Return + return; +} + + +/***********************************************************************//** + * @brief Allocate null value + ***************************************************************************/ +void GFitsTableBoolCol::alloc_nulval(const bool* value) +{ + // Free any existing memory + if (m_nulval != NULL) delete m_nulval; + + // Mark pointer as free + m_nulval = NULL; + + // If we have valid value, allocate and set null value + if (value != NULL) { + m_nulval = new bool; + *m_nulval = *value; + } + + // Return + return; +} + + +/***********************************************************************//** + * @brief Initialise column data + ***************************************************************************/ +void GFitsTableBoolCol::init_data(void) +{ + // Initialise data if they exist + if (m_data != NULL) { + for (int i = 0; i < m_size; ++i) + m_data[i] = false; + } + + // Return + return; +} + + +/***********************************************************************//** + * @brief Fetch column data + * + * If a FITS file is attached to the column the data are loaded into memory + * from the FITS file. If no FITS file is attached, memory is allocated + * to hold the column data and all cells are set to 0. + * + * Refer to GFitsTableCol::load_column for more information. + ***************************************************************************/ +void GFitsTableBoolCol::fetch_data(void) +{ + // Calculate size of memory + m_size = m_number * m_length; + + // Free old buffer memory + free_buffer(); + + // Allocate buffer memory + alloc_buffer(); + + // Save column + load_column(); + + // Extract values from buffer + for (int i = 0; i < m_size; ++i) + m_data[i] = (bool)m_buffer[i]; + + // Free buffer memory + free_buffer(); + + // Return + return; +} + + +/***********************************************************************//** + * @brief Allocate CFITSIO transfer buffer + * + * The CFITSIO transfer buffer allows transparent conversion from the CFITSIO + * storage format to a vector of bool values. + ***************************************************************************/ +void GFitsTableBoolCol::alloc_buffer(void) +{ + // Allocate and initialise buffer memory + if (m_size > 0) { + m_buffer = new char[m_size]; + for (int i = 0; i < m_size; ++i) + m_buffer[i] = 0; + } + + // Return + return; +} + + +/***********************************************************************//** + * @brief Free CFITSIO transfer buffer + * + * Release memory that has been allocated for the CFITSIO transfer buffer. + ***************************************************************************/ +void GFitsTableBoolCol::free_buffer(void) +{ + // Free buffer + if (m_buffer != NULL) delete [] m_buffer; + + // Mark buffer as free + m_buffer = NULL; + + // Return + return; +} + + +/*========================================================================== + = = + = Friends = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Output operator + * + * @param[in] os Output stream. + * @param[in] column Column to put in output stream. + ***************************************************************************/ +std::ostream& operator<< (std::ostream& os, const GFitsTableBoolCol& column) +{ + // Dump column in output stream + column.dump_column(os, column.m_data); + + // Return output stream + return os; +} diff --git a/src/fits/GFitsTableCol.cpp b/src/fits/GFitsTableCol.cpp index 2f55fb7..e3fee9a 100644 --- a/src/fits/GFitsTableCol.cpp +++ b/src/fits/GFitsTableCol.cpp @@ -22,6 +22,7 @@ /* __ Method name definitions ____________________________________________ */ #define G_LOAD_COLUMN "GFitsTableCol::load_column()" #define G_SAVE_COLUMN "GFitsTableCol::save_column()" +#define G_OFFSET "GFitsTableCol::offset(const int&, const int&)" /* __ Macros _____________________________________________________________ */ @@ -252,53 +253,19 @@ int GFitsTableCol::length(void) /*========================================================================== = = - = Private methods = + = Protected methods = = = ==========================================================================*/ /***********************************************************************//** - * @brief Initialise class members - ***************************************************************************/ -void GFitsTableCol::init_members(void) -{ - // Initialise members - m_name.clear(); - m_unit.clear(); - m_colnum = 0; - m_type = 0; - m_repeat = 0; - m_width = 0; - m_number = 0; - m_length = 0; - m_size = 0; - m_anynul = 0; - m_fitsfile.HDUposition = 0; - m_fitsfile.Fptr = NULL; - - // Return - return; -} - - -/***********************************************************************//** - * @brief Copy class members + * @brief Save table column into FITS file * - * @param[in] column Column to be copied + * Refer to GFitsTableCol::save_column() for more information. ***************************************************************************/ -void GFitsTableCol::copy_members(const GFitsTableCol& column) +void GFitsTableCol::save(void) { - // Copy attributes - m_name = column.m_name; - m_unit = column.m_unit; - m_colnum = column.m_colnum; - m_type = column.m_type; - m_repeat = column.m_repeat; - m_width = column.m_width; - m_number = column.m_number; - m_length = column.m_length; - m_size = column.m_size; - m_anynul = column.m_anynul; - m_fitsfile = column.m_fitsfile; + // Save column + save_column(); // Return return; @@ -306,29 +273,18 @@ void GFitsTableCol::copy_members(const GFitsTableCol& column) /***********************************************************************//** - * @brief Delete class members - ***************************************************************************/ -void GFitsTableCol::free_members(void) -{ - // Free memory - - // Mark memory as freed - - // Return - return; -} - - -/***********************************************************************//** - * @brief Connect table column to FITS file + * @brief Fetch column data * - * @param[in] fptr FITS file pointer to which the table column should be - * connected + * If a FITS file is attached to the column the data are loaded into memory + * from the FITS file. If no FITS file is attached, memory is allocated + * to hold the column data and all cells are set to 0. + * + * Refer to GFitsTableCol::load_column for more information. ***************************************************************************/ -void GFitsTableCol::connect(__fitsfile* fptr) +void GFitsTableCol::fetch_data(void) { - // Connect Image - m_fitsfile = *fptr; + // Save column + load_column(); // Return return; @@ -347,11 +303,11 @@ void GFitsTableCol::connect(__fitsfile* fptr) * from the FITS file. If no FITS file is attached, memory is allocated * to hold the column data and all cells are set to 0. * - * The method make use of the virtual methods - * GFitsTableCol::alloc_data, - * GFitsTableCol::init_data, - * GFitsTableCol::ptr_data, and - * GFitsTableCol::ptr_nulval. + * The method makes use of the virtual methods + * GFitsTableCol::alloc_data, + * GFitsTableCol::init_data, + * GFitsTableCol::ptr_data, and + * GFitsTableCol::ptr_nulval. * These methods are implemented by the derived column classes which * implement a specific storage class (i.e. float, double, short, ...). ***************************************************************************/ @@ -488,6 +444,125 @@ void GFitsTableCol::dump_column(std::ostream& os, void* data) const } +/***********************************************************************//** + * @brief Convert row and vector index into column offset + * + * @param[in] row Row of column. + * @param[in] inx Vector index in column row. + * + * @exception GException::out_of_range + * Table row or vector index are out of valid range. + * + * Converts the row and vector index of a column into a linear offset from + * the column start. + ***************************************************************************/ +int GFitsTableCol::offset(const int& row, const int& inx) const +{ + // Check row value + #if defined(G_RANGE_CHECK) + if (row < 0 || row >= m_length) + throw GException::out_of_range(G_OFFSET, row, 0, m_length-1); + #endif + + // Check inx value + #if defined(G_RANGE_CHECK) + if (inx < 0 || inx >= m_number) + throw GException::out_of_range(G_OFFSET, inx, 0, m_number-1); + #endif + + // Calculate pixel offset + int offset = row * m_number + inx; + + // Return offset + return offset; +} + + +/*========================================================================== + = = + = Private methods = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Initialise class members + ***************************************************************************/ +void GFitsTableCol::init_members(void) +{ + // Initialise members + m_name.clear(); + m_unit.clear(); + m_colnum = 0; + m_type = 0; + m_repeat = 0; + m_width = 0; + m_number = 0; + m_length = 0; + m_size = 0; + m_anynul = 0; + m_fitsfile.HDUposition = 0; + m_fitsfile.Fptr = NULL; + + // Return + return; +} + + +/***********************************************************************//** + * @brief Copy class members + * + * @param[in] column Column to be copied + ***************************************************************************/ +void GFitsTableCol::copy_members(const GFitsTableCol& column) +{ + // Copy attributes + m_name = column.m_name; + m_unit = column.m_unit; + m_colnum = column.m_colnum; + m_type = column.m_type; + m_repeat = column.m_repeat; + m_width = column.m_width; + m_number = column.m_number; + m_length = column.m_length; + m_size = column.m_size; + m_anynul = column.m_anynul; + m_fitsfile = column.m_fitsfile; + + // Return + return; +} + + +/***********************************************************************//** + * @brief Delete class members + ***************************************************************************/ +void GFitsTableCol::free_members(void) +{ + // Free memory + + // Mark memory as freed + + // Return + return; +} + + +/***********************************************************************//** + * @brief Connect table column to FITS file + * + * @param[in] fptr FITS file pointer to which the table column should be + * connected + ***************************************************************************/ +void GFitsTableCol::connect(__fitsfile* fptr) +{ + // Connect Image + m_fitsfile = *fptr; + + // Return + return; +} + + /*========================================================================== = = = GFitsTableCol friends = diff --git a/src/fits/GFitsTableDoubleCol.cpp b/src/fits/GFitsTableDoubleCol.cpp new file mode 100644 index 0000000..4cb5614 --- /dev/null +++ b/src/fits/GFitsTableDoubleCol.cpp @@ -0,0 +1,498 @@ +/*************************************************************************** + * GFitsTableDoubleCol.cpp - FITS table double column class * + * ----------------------------------------------------------------------- * + * copyright (C) 2010 by Jurgen Knodlseder * + * ----------------------------------------------------------------------- * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +/* __ Includes ___________________________________________________________ */ +#ifdef HAVE_CONFIG_H +#include +#endif +#include +#include "GException.hpp" +#include "GTools.hpp" +#include "GFitsTableDoubleCol.hpp" + +/* __ Method name definitions ____________________________________________ */ + +/* __ Macros _____________________________________________________________ */ + +/* __ Coding definitions _________________________________________________ */ + +/* __ Debug definitions __________________________________________________ */ + + +/*========================================================================== + = = + = Constructors/destructors = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Constructor + ***************************************************************************/ +GFitsTableDoubleCol::GFitsTableDoubleCol(void) : GFitsTableCol() +{ + // Initialise class members for clean destruction + init_members(); + + // Return + return; +} + + +/***********************************************************************//** + * @brief Constructor + * + * @param[in] name Name of column. + * @param[in] length Length of column. + * @param[in] size Vector size of column. + ***************************************************************************/ +GFitsTableDoubleCol::GFitsTableDoubleCol(const std::string& name, + const int& length, + const int& size) + : GFitsTableCol(name, length, size, 2) +{ + // Initialise class members for clean destruction + init_members(); + + // Return + return; +} + + +/***********************************************************************//** + * @brief Copy constructor + * + * @param[in] column Column from which class instance should be built. + ***************************************************************************/ +GFitsTableDoubleCol::GFitsTableDoubleCol(const GFitsTableDoubleCol& column) + : GFitsTableCol(column) +{ + // Initialise class members for clean destruction + init_members(); + + // Copy members + copy_members(column); + + // Return + return; +} + + +/***********************************************************************//** + * @brief Destructor + ***************************************************************************/ +GFitsTableDoubleCol::~GFitsTableDoubleCol(void) +{ + // Free members + free_members(); + + // Return + return; +} + + +/*========================================================================== + = = + = Operators = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Assignment operator + * + * @param[in] column Column which should be assigned + ***************************************************************************/ +GFitsTableDoubleCol& GFitsTableDoubleCol::operator= (const GFitsTableDoubleCol& column) +{ + // Execute only if object is not identical + if (this != &column) { + + // Copy base class members + this->GFitsTableCol::operator=(column); + + // Free members + free_members(); + + // Initialise private members for clean destruction + init_members(); + + // Copy members + copy_members(column); + + } // endif: object was not identical + + // Return this object + return *this; +} + + +/***********************************************************************//** + * @brief Column data access operator + * + * @param[in] row Row of column to access. + * @param[in] inx Vector index in column row to access + * + * Provides access to data in a column. + ***************************************************************************/ +double& GFitsTableDoubleCol::operator() (const int& row, const int& inx) +{ + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Return data bin + return m_data[offset(row, inx)]; +} + + +/***********************************************************************//** + * @brief Column data access operator (const variant) + * + * @param[in] row Row of column to access. + * @param[in] inx Vector index in column row to access + * + * Provides access to data in a column. + ***************************************************************************/ +const double& GFitsTableDoubleCol::operator() (const int& row, const int& inx) const +{ + // If data are not available then load them now + if (m_data == NULL) ((GFitsTableDoubleCol*)this)->fetch_data(); + + // Return data bin + return m_data[offset(row, inx)]; +} + + +/*========================================================================== + = = + = Public methods = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Get string value + * + * @param[in] row Table row. + * @param[in] inx Table column vector index. + * + * Returns value of specified row and vector index as string. + ***************************************************************************/ +std::string GFitsTableDoubleCol::string(const int& row, const int& inx) +{ + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Convert double into string + std::ostringstream s_value; + s_value << m_data[offset(row,inx)]; + + // Return value + return s_value.str(); +} + + +/***********************************************************************//** + * @brief Get double precision value + * + * @param[in] row Table row. + * @param[in] inx Table column vector index. + * + * Returns value of specified row and vector index as double precision. + ***************************************************************************/ +double GFitsTableDoubleCol::real(const int& row, const int& inx) +{ + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Convert double into double + double value = (double)m_data[offset(row,inx)]; + + // Return value + return value; +} + + +/***********************************************************************//** + * @brief Get integer value + * + * @param[in] row Table row. + * @param[in] inx Table column vector index. + * + * Returns value of specified row and vector index as integer. + ***************************************************************************/ +int GFitsTableDoubleCol::integer(const int& row, const int& inx) +{ + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Convert double into int + int value = (int)m_data[offset(row,inx)]; + + // Return value + return value; +} + + +/***********************************************************************//** + * @brief Set NULL value + * + * @param[in] value Pointer on NULL value + * + * Allows the specification of the FITS table NULL value. If value=NULL the + * data will not be screened for NULL values. + * + * @todo To correctly reflect the NULL value in the data, the column should + * be reloaded. However, the column may have been changed, so in principle + * saving is needed. However, we may not want to store the data, hence saving + * is also not desired. We thus have to develop a method to update the + * column information for a new NULL value in place ... + ***************************************************************************/ +void GFitsTableDoubleCol::nullval(const double* value) +{ + // Allocate nul value + alloc_nulval(value); + + // Update column +// if (m_data != NULL) { +// save(); +// load(); +// } + + // Return + return; +} + + +/*========================================================================== + = = + = Private methods = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Initialise class members + ***************************************************************************/ +void GFitsTableDoubleCol::init_members(void) +{ + // Initialise members + m_type = __TDOUBLE; + m_data = NULL; + m_nulval = NULL; + + // Return + return; +} + + +/***********************************************************************//** + * @brief Copy class members + * + * @param[in] column Column for which members should be copied. + * + * Sets the content of the vector column by copying from another column. + * If the code is compiled with the small memory option, and if the source + * column has not yet been loaded, then we only load the column temporarily + * for copying purposes and release it again once copying is finished. + ***************************************************************************/ +void GFitsTableDoubleCol::copy_members(const GFitsTableDoubleCol& column) +{ + // Fetch column data if not yet fetched. The casting circumvents the + // const correctness + bool not_loaded = (column.m_data == NULL); + if (not_loaded) ((GFitsTableDoubleCol*)(&column))->fetch_data(); + + // Copy attributes + m_type = column.m_type; + m_size = column.m_size; + + // Copy column data + if (column.m_data != NULL && m_size > 0) { + alloc_data(); + for (int i = 0; i < m_size; ++i) + m_data[i] = column.m_data[i]; + } + + // Copy NULL value + alloc_nulval(column.m_nulval); + + // Small memory option: release column if it was fetch above + #if defined(G_SMALL_MEMORY) + if (not_loaded) ((GFitsTableDoubleCol*)(&column))->release_data(); + #endif + + // Return + return; +} + + +/***********************************************************************//** + * @brief Delete class members + ***************************************************************************/ +void GFitsTableDoubleCol::free_members(void) +{ + // Free memory + if (m_data != NULL) delete [] m_data; + if (m_nulval != NULL) delete m_nulval; + + // Mark memory as freed + m_data = NULL; + m_nulval = NULL; + + // Reset load flag + m_size = 0; + + // Return + return; +} + + +/***********************************************************************//** + * @brief Clone column + ***************************************************************************/ +GFitsTableDoubleCol* GFitsTableDoubleCol::clone(void) const +{ + return new GFitsTableDoubleCol(*this); +} + + +/***********************************************************************//** + * @brief Returns format string of ASCII table + ***************************************************************************/ +std::string GFitsTableDoubleCol::ascii_format(void) const +{ + // Initialize format string + std::string format; + + // Set type code + format.append("F"); + + // Set width + format.append(str(m_width)); + + // Return format + return format; +} + + +/***********************************************************************//** + * @brief Returns format string of binary table + ***************************************************************************/ +std::string GFitsTableDoubleCol::binary_format(void) const +{ + // Initialize format string + std::string format; + + // Set number of elements + format.append(str(m_number)); + + // Set type code + format.append("D"); + + // Return format + return format; +} + + +/***********************************************************************//** + * @brief Allocates column data + ***************************************************************************/ +void GFitsTableDoubleCol::alloc_data(void) +{ + // Free any existing memory + if (m_data != NULL) delete [] m_data; + + // Mark pointer as free + m_data = NULL; + + // Allocate new data + if (m_size > 0) + m_data = new double[m_size]; + + // Return + return; +} + + +/***********************************************************************//** + * @brief Release column data + ***************************************************************************/ +void GFitsTableDoubleCol::release_data(void) +{ + // Free any existing memory + if (m_data != NULL) delete [] m_data; + + // Mark pointer as free and reset loaded vector size + m_data = NULL; + m_size = 0; + + // Return + return; +} + + +/***********************************************************************//** + * @brief Allocates null value + ***************************************************************************/ +void GFitsTableDoubleCol::alloc_nulval(const double* value) +{ + // Free any existing memory + if (m_nulval != NULL) delete m_nulval; + + // Mark pointer as free + m_nulval = NULL; + + // If we have valid value, allocate and set nul value + if (value != NULL) { + m_nulval = new double; + *m_nulval = *value; + } + + // Return + return; +} + + +/***********************************************************************//** + * @brief Initialise column data + ***************************************************************************/ +void GFitsTableDoubleCol::init_data(void) +{ + // Initialise data if they exist + if (m_data != NULL) { + for (int i = 0; i < m_size; ++i) + m_data[i] = 0.0; + } + + // Return + return; +} + + +/*========================================================================== + = = + = Friends = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Output operator + * + * @param[in] os Output stream + * @param[in] column Column to put in output stream + ***************************************************************************/ +std::ostream& operator<< (std::ostream& os, const GFitsTableDoubleCol& column) +{ + // Dump column in output stream + column.dump_column(os, column.m_data); + + // Return output stream + return os; +} diff --git a/src/fits/GFitsTableFloatCol.cpp b/src/fits/GFitsTableFloatCol.cpp new file mode 100644 index 0000000..1566eaa --- /dev/null +++ b/src/fits/GFitsTableFloatCol.cpp @@ -0,0 +1,498 @@ +/*************************************************************************** + * GFitsTableFloatCol.cpp - FITS table float column class * + * ----------------------------------------------------------------------- * + * copyright (C) 2010 by Jurgen Knodlseder * + * ----------------------------------------------------------------------- * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +/* __ Includes ___________________________________________________________ */ +#ifdef HAVE_CONFIG_H +#include +#endif +#include +#include "GException.hpp" +#include "GTools.hpp" +#include "GFitsTableFloatCol.hpp" + +/* __ Method name definitions ____________________________________________ */ + +/* __ Macros _____________________________________________________________ */ + +/* __ Coding definitions _________________________________________________ */ + +/* __ Debug definitions __________________________________________________ */ + + +/*========================================================================== + = = + = Constructors/destructors = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Constructor + ***************************************************************************/ +GFitsTableFloatCol::GFitsTableFloatCol(void) : GFitsTableCol() +{ + // Initialise class members for clean destruction + init_members(); + + // Return + return; +} + + +/***********************************************************************//** + * @brief Constructor + * + * @param[in] name Name of column. + * @param[in] length Length of column. + * @param[in] size Vector size of column. + ***************************************************************************/ +GFitsTableFloatCol::GFitsTableFloatCol(const std::string& name, + const int& length, + const int& size) + : GFitsTableCol(name, length, size, 2) +{ + // Initialise class members for clean destruction + init_members(); + + // Return + return; +} + + +/***********************************************************************//** + * @brief Copy constructor + * + * @param[in] column Column from which class instance should be built. + ***************************************************************************/ +GFitsTableFloatCol::GFitsTableFloatCol(const GFitsTableFloatCol& column) + : GFitsTableCol(column) +{ + // Initialise class members for clean destruction + init_members(); + + // Copy members + copy_members(column); + + // Return + return; +} + + +/***********************************************************************//** + * @brief Destructor + ***************************************************************************/ +GFitsTableFloatCol::~GFitsTableFloatCol(void) +{ + // Free members + free_members(); + + // Return + return; +} + + +/*========================================================================== + = = + = Operators = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Assignment operator + * + * @param[in] column Column which should be assigned + ***************************************************************************/ +GFitsTableFloatCol& GFitsTableFloatCol::operator= (const GFitsTableFloatCol& column) +{ + // Execute only if object is not identical + if (this != &column) { + + // Copy base class members + this->GFitsTableCol::operator=(column); + + // Free members + free_members(); + + // Initialise private members for clean destruction + init_members(); + + // Copy members + copy_members(column); + + } // endif: object was not identical + + // Return this object + return *this; +} + + +/***********************************************************************//** + * @brief Column data access operator + * + * @param[in] row Row of column to access. + * @param[in] inx Vector index in column row to access + * + * Provides access to data in a column. + ***************************************************************************/ +float& GFitsTableFloatCol::operator() (const int& row, const int& inx) +{ + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Return data bin + return m_data[offset(row, inx)]; +} + + +/***********************************************************************//** + * @brief Column data access operator (const variant) + * + * @param[in] row Row of column to access. + * @param[in] inx Vector index in column row to access + * + * Provides access to data in a column. + ***************************************************************************/ +const float& GFitsTableFloatCol::operator() (const int& row, const int& inx) const +{ + // If data are not available then load them now + if (m_data == NULL) ((GFitsTableFloatCol*)this)->fetch_data(); + + // Return data bin + return m_data[offset(row, inx)]; +} + + +/*========================================================================== + = = + = Public methods = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Get string value + * + * @param[in] row Table row. + * @param[in] inx Table column vector index. + * + * Returns value of specified row and vector index as string. + ***************************************************************************/ +std::string GFitsTableFloatCol::string(const int& row, const int& inx) +{ + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Convert float into string + std::ostringstream s_value; + s_value << m_data[offset(row,inx)]; + + // Return value + return s_value.str(); +} + + +/***********************************************************************//** + * @brief Get double precision value + * + * @param[in] row Table row. + * @param[in] inx Table column vector index. + * + * Returns value of specified row and vector index as double precision. + ***************************************************************************/ +double GFitsTableFloatCol::real(const int& row, const int& inx) +{ + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Convert float into double + double value = (double)m_data[offset(row,inx)]; + + // Return value + return value; +} + + +/***********************************************************************//** + * @brief Get integer value + * + * @param[in] row Table row. + * @param[in] inx Table column vector index. + * + * Returns value of specified row and vector index as integer. + ***************************************************************************/ +int GFitsTableFloatCol::integer(const int& row, const int& inx) +{ + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Convert float into int + int value = (int)m_data[offset(row,inx)]; + + // Return value + return value; +} + + +/***********************************************************************//** + * @brief Set NULL value + * + * @param[in] value Pointer on NULL value + * + * Allows the specification of the FITS table NULL value. If value=NULL the + * data will not be screened for NULL values. + * + * @todo To correctly reflect the NULL value in the data, the column should + * be reloaded. However, the column may have been changed, so in principle + * saving is needed. However, we may not want to store the data, hence saving + * is also not desired. We thus have to develop a method to update the + * column information for a new NULL value in place ... + ***************************************************************************/ +void GFitsTableFloatCol::nullval(const float* value) +{ + // Allocate nul value + alloc_nulval(value); + + // Update column +// if (m_data != NULL) { +// save(); +// load(); +// } + + // Return + return; +} + + +/*========================================================================== + = = + = Private methods = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Initialise class members + ***************************************************************************/ +void GFitsTableFloatCol::init_members(void) +{ + // Initialise members + m_type = __TFLOAT; + m_data = NULL; + m_nulval = NULL; + + // Return + return; +} + + +/***********************************************************************//** + * @brief Copy class members + * + * @param[in] column Column for which members should be copied. + * + * Sets the content of the vector column by copying from another column. + * If the code is compiled with the small memory option, and if the source + * column has not yet been loaded, then we only load the column temporarily + * for copying purposes and release it again once copying is finished. + ***************************************************************************/ +void GFitsTableFloatCol::copy_members(const GFitsTableFloatCol& column) +{ + // Fetch column data if not yet fetched. The casting circumvents the + // const correctness + bool not_loaded = (column.m_data == NULL); + if (not_loaded) ((GFitsTableFloatCol*)(&column))->fetch_data(); + + // Copy attributes + m_type = column.m_type; + m_size = column.m_size; + + // Copy column data + if (column.m_data != NULL && m_size > 0) { + alloc_data(); + for (int i = 0; i < m_size; ++i) + m_data[i] = column.m_data[i]; + } + + // Copy NULL value + alloc_nulval(column.m_nulval); + + // Small memory option: release column if it was fetch above + #if defined(G_SMALL_MEMORY) + if (not_loaded) ((GFitsTableFloatCol*)(&column))->release_data(); + #endif + + // Return + return; +} + + +/***********************************************************************//** + * @brief Delete class members + ***************************************************************************/ +void GFitsTableFloatCol::free_members(void) +{ + // Free memory + if (m_data != NULL) delete [] m_data; + if (m_nulval != NULL) delete m_nulval; + + // Mark memory as freed + m_data = NULL; + m_nulval = NULL; + + // Reset load flag + m_size = 0; + + // Return + return; +} + + +/***********************************************************************//** + * @brief Clone column + ***************************************************************************/ +GFitsTableFloatCol* GFitsTableFloatCol::clone(void) const +{ + return new GFitsTableFloatCol(*this); +} + + +/***********************************************************************//** + * @brief Returns format string of ASCII table + ***************************************************************************/ +std::string GFitsTableFloatCol::ascii_format(void) const +{ + // Initialize format string + std::string format; + + // Set type code + format.append("F"); + + // Set width + format.append(str(m_width)); + + // Return format + return format; +} + + +/***********************************************************************//** + * @brief Returns format string of binary table + ***************************************************************************/ +std::string GFitsTableFloatCol::binary_format(void) const +{ + // Initialize format string + std::string format; + + // Set number of elements + format.append(str(m_number)); + + // Set type code + format.append("E"); + + // Return format + return format; +} + + +/***********************************************************************//** + * @brief Allocates column data + ***************************************************************************/ +void GFitsTableFloatCol::alloc_data(void) +{ + // Free any existing memory + if (m_data != NULL) delete [] m_data; + + // Mark pointer as free + m_data = NULL; + + // Allocate new data + if (m_size > 0) + m_data = new float[m_size]; + + // Return + return; +} + + +/***********************************************************************//** + * @brief Release column data + ***************************************************************************/ +void GFitsTableFloatCol::release_data(void) +{ + // Free any existing memory + if (m_data != NULL) delete [] m_data; + + // Mark pointer as free and reset loaded vector size + m_data = NULL; + m_size = 0; + + // Return + return; +} + + +/***********************************************************************//** + * @brief Allocates null value + ***************************************************************************/ +void GFitsTableFloatCol::alloc_nulval(const float* value) +{ + // Free any existing memory + if (m_nulval != NULL) delete m_nulval; + + // Mark pointer as free + m_nulval = NULL; + + // If we have valid value, allocate and set nul value + if (value != NULL) { + m_nulval = new float; + *m_nulval = *value; + } + + // Return + return; +} + + +/***********************************************************************//** + * @brief Initialise column data + ***************************************************************************/ +void GFitsTableFloatCol::init_data(void) +{ + // Initialise data if they exist + if (m_data != NULL) { + for (int i = 0; i < m_size; ++i) + m_data[i] = 0.0; + } + + // Return + return; +} + + +/*========================================================================== + = = + = Friends = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Output operator + * + * @param[in] os Output stream. + * @param[in] column Column to put in output stream. + ***************************************************************************/ +std::ostream& operator<< (std::ostream& os, const GFitsTableFloatCol& column) +{ + // Dump column in output stream + column.dump_column(os, column.m_data); + + // Return output stream + return os; +} diff --git a/src/fits/GFitsTableLongCol.cpp b/src/fits/GFitsTableLongCol.cpp new file mode 100644 index 0000000..6fa4e2d --- /dev/null +++ b/src/fits/GFitsTableLongCol.cpp @@ -0,0 +1,498 @@ +/*************************************************************************** + * GFitsTableLongCol.cpp - FITS table long column class * + * ----------------------------------------------------------------------- * + * copyright (C) 2010 by Jurgen Knodlseder * + * ----------------------------------------------------------------------- * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +/* __ Includes ___________________________________________________________ */ +#ifdef HAVE_CONFIG_H +#include +#endif +#include +#include "GException.hpp" +#include "GTools.hpp" +#include "GFitsTableLongCol.hpp" + +/* __ Method name definitions ____________________________________________ */ + +/* __ Macros _____________________________________________________________ */ + +/* __ Coding definitions _________________________________________________ */ + +/* __ Debug definitions __________________________________________________ */ + + +/*========================================================================== + = = + = Constructors/destructors = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Constructor + ***************************************************************************/ +GFitsTableLongCol::GFitsTableLongCol(void) : GFitsTableCol() +{ + // Initialise class members for clean destruction + init_members(); + + // Return + return; +} + + +/***********************************************************************//** + * @brief Constructor + * + * @param[in] name Name of column. + * @param[in] length Length of column. + * @param[in] size Vector size of column. + ***************************************************************************/ +GFitsTableLongCol::GFitsTableLongCol(const std::string& name, + const int& length, + const int& size) + : GFitsTableCol(name, length, size, 2) +{ + // Initialise class members for clean destruction + init_members(); + + // Return + return; +} + + +/***********************************************************************//** + * @brief Copy constructor + * + * @param[in] column Column from which class instance should be built. + ***************************************************************************/ +GFitsTableLongCol::GFitsTableLongCol(const GFitsTableLongCol& column) + : GFitsTableCol(column) +{ + // Initialise class members for clean destruction + init_members(); + + // Copy members + copy_members(column); + + // Return + return; +} + + +/***********************************************************************//** + * @brief Destructor + ***************************************************************************/ +GFitsTableLongCol::~GFitsTableLongCol(void) +{ + // Free members + free_members(); + + // Return + return; +} + + +/*========================================================================== + = = + = Operators = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Assignment operator + * + * @param[in] column Column which should be assigned + ***************************************************************************/ +GFitsTableLongCol& GFitsTableLongCol::operator= (const GFitsTableLongCol& column) +{ + // Execute only if object is not identical + if (this != &column) { + + // Copy base class members + this->GFitsTableCol::operator=(column); + + // Free members + free_members(); + + // Initialise private members for clean destruction + init_members(); + + // Copy members + copy_members(column); + + } // endif: object was not identical + + // Return this object + return *this; +} + + +/***********************************************************************//** + * @brief Column data access operator + * + * @param[in] row Row of column to access. + * @param[in] inx Vector index in column row to access + * + * Provides access to data in a column. + ***************************************************************************/ +long& GFitsTableLongCol::operator() (const int& row, const int& inx) +{ + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Return data bin + return m_data[offset(row, inx)]; +} + + +/***********************************************************************//** + * @brief Column data access operator (const variant) + * + * @param[in] row Row of column to access. + * @param[in] inx Vector index in column row to access + * + * Provides access to data in a column. + ***************************************************************************/ +const long& GFitsTableLongCol::operator() (const int& row, const int& inx) const +{ + // If data are not available then load them now + if (m_data == NULL) ((GFitsTableLongCol*)this)->fetch_data(); + + // Return data bin + return m_data[offset(row, inx)]; +} + + +/*========================================================================== + = = + = Public methods = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Get string value + * + * @param[in] row Table row. + * @param[in] inx Table column vector index. + * + * Returns value of specified row and vector index as string. + ***************************************************************************/ +std::string GFitsTableLongCol::string(const int& row, const int& inx) +{ + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Convert long into string + std::ostringstream s_value; + s_value << m_data[offset(row,inx)]; + + // Return value + return s_value.str(); +} + + +/***********************************************************************//** + * @brief Get double precision value + * + * @param[in] row Table row. + * @param[in] inx Table column vector index. + * + * Returns value of specified row and vector index as double precision. + ***************************************************************************/ +double GFitsTableLongCol::real(const int& row, const int& inx) +{ + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Convert long into double + double value = (double)m_data[offset(row,inx)]; + + // Return value + return value; +} + + +/***********************************************************************//** + * @brief Get integer value + * + * @param[in] row Table row. + * @param[in] inx Table column vector index. + * + * Returns value of specified row and vector index as integer. + ***************************************************************************/ +int GFitsTableLongCol::integer(const int& row, const int& inx) +{ + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Convert long into int + int value = (int)m_data[offset(row,inx)]; + + // Return value + return value; +} + + +/***********************************************************************//** + * @brief Set NULL value + * + * @param[in] value Pointer on NULL value + * + * Allows the specification of the FITS table NULL value. If value=NULL the + * data will not be screened for NULL values. + * + * @todo To correctly reflect the NULL value in the data, the column should + * be reloaded. However, the column may have been changed, so in principle + * saving is needed. However, we may not want to store the data, hence saving + * is also not desired. We thus have to develop a method to update the + * column information for a new NULL value in place ... + ***************************************************************************/ +void GFitsTableLongCol::nullval(const long* value) +{ + // Allocate nul value + alloc_nulval(value); + + // Update column +// if (m_data != NULL) { +// save(); +// load(); +// } + + // Return + return; +} + + +/*========================================================================== + = = + = Private methods = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Initialise class members + ***************************************************************************/ +void GFitsTableLongCol::init_members(void) +{ + // Initialise members + m_type = __TLONG; + m_data = NULL; + m_nulval = NULL; + + // Return + return; +} + + +/***********************************************************************//** + * @brief Copy class members + * + * @param[in] column Column for which members should be copied. + * + * Sets the content of the vector column by copying from another column. + * If the code is compiled with the small memory option, and if the source + * column has not yet been loaded, then we only load the column temporarily + * for copying purposes and release it again once copying is finished. + ***************************************************************************/ +void GFitsTableLongCol::copy_members(const GFitsTableLongCol& column) +{ + // Fetch column data if not yet fetched. The casting circumvents the + // const correctness + bool not_loaded = (column.m_data == NULL); + if (not_loaded) ((GFitsTableLongCol*)(&column))->fetch_data(); + + // Copy attributes + m_type = column.m_type; + m_size = column.m_size; + + // Copy column data + if (column.m_data != NULL && m_size > 0) { + alloc_data(); + for (int i = 0; i < m_size; ++i) + m_data[i] = column.m_data[i]; + } + + // Copy NULL value + alloc_nulval(column.m_nulval); + + // Small memory option: release column if it was fetch above + #if defined(G_SMALL_MEMORY) + if (not_loaded) ((GFitsTableLongCol*)(&column))->release_data(); + #endif + + // Return + return; +} + + +/***********************************************************************//** + * @brief Delete class members + ***************************************************************************/ +void GFitsTableLongCol::free_members(void) +{ + // Free memory + if (m_data != NULL) delete [] m_data; + if (m_nulval != NULL) delete m_nulval; + + // Mark memory as freed + m_data = NULL; + m_nulval = NULL; + + // Reset load flag + m_size = 0; + + // Return + return; +} + + +/***********************************************************************//** + * @brief Clone column + ***************************************************************************/ +GFitsTableLongCol* GFitsTableLongCol::clone(void) const +{ + return new GFitsTableLongCol(*this); +} + + +/***********************************************************************//** + * @brief Returns format string of ASCII table + ***************************************************************************/ +std::string GFitsTableLongCol::ascii_format(void) const +{ + // Initialize format string + std::string format; + + // Set type code + format.append("J"); + + // Set width + format.append(str(m_width)); + + // Return format + return format; +} + + +/***********************************************************************//** + * @brief Returns format string of binary table + ***************************************************************************/ +std::string GFitsTableLongCol::binary_format(void) const +{ + // Initialize format string + std::string format; + + // Set number of elements + format.append(str(m_number)); + + // Set type code + format.append("J"); + + // Return format + return format; +} + + +/***********************************************************************//** + * @brief Allocates column data + ***************************************************************************/ +void GFitsTableLongCol::alloc_data(void) +{ + // Free any existing memory + if (m_data != NULL) delete [] m_data; + + // Mark pointer as free + m_data = NULL; + + // Allocate new data + if (m_size > 0) + m_data = new long[m_size]; + + // Return + return; +} + + +/***********************************************************************//** + * @brief Release column data + ***************************************************************************/ +void GFitsTableLongCol::release_data(void) +{ + // Free any existing memory + if (m_data != NULL) delete [] m_data; + + // Mark pointer as free and reset loaded vector size + m_data = NULL; + m_size = 0; + + // Return + return; +} + + +/***********************************************************************//** + * @brief Allocates null value + ***************************************************************************/ +void GFitsTableLongCol::alloc_nulval(const long* value) +{ + // Free any existing memory + if (m_nulval != NULL) delete m_nulval; + + // Mark pointer as free + m_nulval = NULL; + + // If we have valid value, allocate and set nul value + if (value != NULL) { + m_nulval = new long; + *m_nulval = *value; + } + + // Return + return; +} + + +/***********************************************************************//** + * @brief Initialise column data + ***************************************************************************/ +void GFitsTableLongCol::init_data(void) +{ + // Initialise data if they exist + if (m_data != NULL) { + for (int i = 0; i < m_size; ++i) + m_data[i] = 0; + } + + // Return + return; +} + + +/*========================================================================== + = = + = Friends = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Output operator + * + * @param[in] os Output stream. + * @param[in] column Column to put in output stream. + ***************************************************************************/ +std::ostream& operator<< (std::ostream& os, const GFitsTableLongCol& column) +{ + // Dump column in output stream + column.dump_column(os, column.m_data); + + // Return output stream + return os; +} diff --git a/src/fits/GFitsTableLongLongCol.cpp b/src/fits/GFitsTableLongLongCol.cpp new file mode 100644 index 0000000..c520ac2 --- /dev/null +++ b/src/fits/GFitsTableLongLongCol.cpp @@ -0,0 +1,498 @@ +/*************************************************************************** + * GFitsTableLongLongCol.cpp - FITS table long long column class * + * ----------------------------------------------------------------------- * + * copyright (C) 2010 by Jurgen Knodlseder * + * ----------------------------------------------------------------------- * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +/* __ Includes ___________________________________________________________ */ +#ifdef HAVE_CONFIG_H +#include +#endif +#include +#include "GException.hpp" +#include "GTools.hpp" +#include "GFitsTableLongLongCol.hpp" + +/* __ Method name definitions ____________________________________________ */ + +/* __ Macros _____________________________________________________________ */ + +/* __ Coding definitions _________________________________________________ */ + +/* __ Debug definitions __________________________________________________ */ + + +/*========================================================================== + = = + = Constructors/destructors = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Constructor + ***************************************************************************/ +GFitsTableLongLongCol::GFitsTableLongLongCol(void) : GFitsTableCol() +{ + // Initialise class members for clean destruction + init_members(); + + // Return + return; +} + + +/***********************************************************************//** + * @brief Constructor + * + * @param[in] name Name of column. + * @param[in] length Length of column. + * @param[in] size Vector size of column. + ***************************************************************************/ +GFitsTableLongLongCol::GFitsTableLongLongCol(const std::string& name, + const int& length, + const int& size) + : GFitsTableCol(name, length, size, 2) +{ + // Initialise class members for clean destruction + init_members(); + + // Return + return; +} + + +/***********************************************************************//** + * @brief Copy constructor + * + * @param[in] column Column from which class instance should be built. + ***************************************************************************/ +GFitsTableLongLongCol::GFitsTableLongLongCol(const GFitsTableLongLongCol& column) + : GFitsTableCol(column) +{ + // Initialise class members for clean destruction + init_members(); + + // Copy members + copy_members(column); + + // Return + return; +} + + +/***********************************************************************//** + * @brief Destructor + ***************************************************************************/ +GFitsTableLongLongCol::~GFitsTableLongLongCol(void) +{ + // Free members + free_members(); + + // Return + return; +} + + +/*========================================================================== + = = + = Operators = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Assignment operator + * + * @param[in] column Column which should be assigned + ***************************************************************************/ +GFitsTableLongLongCol& GFitsTableLongLongCol::operator= (const GFitsTableLongLongCol& column) +{ + // Execute only if object is not identical + if (this != &column) { + + // Copy base class members + this->GFitsTableCol::operator=(column); + + // Free members + free_members(); + + // Initialise private members for clean destruction + init_members(); + + // Copy members + copy_members(column); + + } // endif: object was not identical + + // Return this object + return *this; +} + + +/***********************************************************************//** + * @brief Column data access operator + * + * @param[in] row Row of column to access. + * @param[in] inx Vector index in column row to access + * + * Provides access to data in a column. + ***************************************************************************/ +long long& GFitsTableLongLongCol::operator() (const int& row, const int& inx) +{ + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Return data bin + return m_data[offset(row, inx)]; +} + + +/***********************************************************************//** + * @brief Column data access operator (const variant) + * + * @param[in] row Row of column to access. + * @param[in] inx Vector index in column row to access + * + * Provides access to data in a column. + ***************************************************************************/ +const long long& GFitsTableLongLongCol::operator() (const int& row, const int& inx) const +{ + // If data are not available then load them now + if (m_data == NULL) ((GFitsTableLongLongCol*)this)->fetch_data(); + + // Return data bin + return m_data[offset(row, inx)]; +} + + +/*========================================================================== + = = + = Public methods = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Get string value + * + * @param[in] row Table row. + * @param[in] inx Table column vector index. + * + * Returns value of specified row and vector index as string. + ***************************************************************************/ +std::string GFitsTableLongLongCol::string(const int& row, const int& inx) +{ + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Convert long long into string + std::ostringstream s_value; + s_value << m_data[offset(row,inx)]; + + // Return value + return s_value.str(); +} + + +/***********************************************************************//** + * @brief Get double precision value + * + * @param[in] row Table row. + * @param[in] inx Table column vector index. + * + * Returns value of specified row and vector index as double precision. + ***************************************************************************/ +double GFitsTableLongLongCol::real(const int& row, const int& inx) +{ + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Convert long long into double + double value = (double)m_data[offset(row,inx)]; + + // Return value + return value; +} + + +/***********************************************************************//** + * @brief Get integer value + * + * @param[in] row Table row. + * @param[in] inx Table column vector index. + * + * Returns value of specified row and vector index as integer. + ***************************************************************************/ +int GFitsTableLongLongCol::integer(const int& row, const int& inx) +{ + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Convert long long into int + int value = (int)m_data[offset(row,inx)]; + + // Return value + return value; +} + + +/***********************************************************************//** + * @brief Set NULL value + * + * @param[in] value Pointer on NULL value + * + * Allows the specification of the FITS table NULL value. If value=NULL the + * data will not be screened for NULL values. + * + * @todo To correctly reflect the NULL value in the data, the column should + * be reloaded. However, the column may have been changed, so in principle + * saving is needed. However, we may not want to store the data, hence saving + * is also not desired. We thus have to develop a method to update the + * column information for a new NULL value in place ... + ***************************************************************************/ +void GFitsTableLongLongCol::nullval(const long long* value) +{ + // Allocate nul value + alloc_nulval(value); + + // Update column +// if (m_data != NULL) { +// save(); +// load(); +// } + + // Return + return; +} + + +/*========================================================================== + = = + = Private methods = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Initialise class members + ***************************************************************************/ +void GFitsTableLongLongCol::init_members(void) +{ + // Initialise members + m_type = __TLONGLONG; + m_data = NULL; + m_nulval = NULL; + + // Return + return; +} + + +/***********************************************************************//** + * @brief Copy class members + * + * @param[in] column Column for which members should be copied. + * + * Sets the content of the vector column by copying from another column. + * If the code is compiled with the small memory option, and if the source + * column has not yet been loaded, then we only load the column temporarily + * for copying purposes and release it again once copying is finished. + ***************************************************************************/ +void GFitsTableLongLongCol::copy_members(const GFitsTableLongLongCol& column) +{ + // Fetch column data if not yet fetched. The casting circumvents the + // const correctness + bool not_loaded = (column.m_data == NULL); + if (not_loaded) ((GFitsTableLongLongCol*)(&column))->fetch_data(); + + // Copy attributes + m_type = column.m_type; + m_size = column.m_size; + + // Copy column data + if (column.m_data != NULL && m_size > 0) { + alloc_data(); + for (int i = 0; i < m_size; ++i) + m_data[i] = column.m_data[i]; + } + + // Copy NULL value + alloc_nulval(column.m_nulval); + + // Small memory option: release column if it was fetch above + #if defined(G_SMALL_MEMORY) + if (not_loaded) ((GFitsTableLongLongCol*)(&column))->release_data(); + #endif + + // Return + return; +} + + +/***********************************************************************//** + * @brief Delete class members + ***************************************************************************/ +void GFitsTableLongLongCol::free_members(void) +{ + // Free memory + if (m_data != NULL) delete [] m_data; + if (m_nulval != NULL) delete m_nulval; + + // Mark memory as freed + m_data = NULL; + m_nulval = NULL; + + // Reset load flag + m_size = 0; + + // Return + return; +} + + +/***********************************************************************//** + * @brief Clone column + ***************************************************************************/ +GFitsTableLongLongCol* GFitsTableLongLongCol::clone(void) const +{ + return new GFitsTableLongLongCol(*this); +} + + +/***********************************************************************//** + * @brief Returns format string of ASCII table + ***************************************************************************/ +std::string GFitsTableLongLongCol::ascii_format(void) const +{ + // Initialize format string + std::string format; + + // Set type code + format.append("K"); + + // Set width + format.append(str(m_width)); + + // Return format + return format; +} + + +/***********************************************************************//** + * @brief Returns format string of binary table + ***************************************************************************/ +std::string GFitsTableLongLongCol::binary_format(void) const +{ + // Initialize format string + std::string format; + + // Set number of elements + format.append(str(m_number)); + + // Set type code + format.append("K"); + + // Return format + return format; +} + + +/***********************************************************************//** + * @brief Allocates column data + ***************************************************************************/ +void GFitsTableLongLongCol::alloc_data(void) +{ + // Free any existing memory + if (m_data != NULL) delete [] m_data; + + // Mark pointer as free + m_data = NULL; + + // Allocate new data + if (m_size > 0) + m_data = new long long[m_size]; + + // Return + return; +} + + +/***********************************************************************//** + * @brief Release column data + ***************************************************************************/ +void GFitsTableLongLongCol::release_data(void) +{ + // Free any existing memory + if (m_data != NULL) delete [] m_data; + + // Mark pointer as free and reset loaded vector size + m_data = NULL; + m_size = 0; + + // Return + return; +} + + +/***********************************************************************//** + * @brief Allocates null value + ***************************************************************************/ +void GFitsTableLongLongCol::alloc_nulval(const long long* value) +{ + // Free any existing memory + if (m_nulval != NULL) delete m_nulval; + + // Mark pointer as free + m_nulval = NULL; + + // If we have valid value, allocate and set nul value + if (value != NULL) { + m_nulval = new long long; + *m_nulval = *value; + } + + // Return + return; +} + + +/***********************************************************************//** + * @brief Initialise column data + ***************************************************************************/ +void GFitsTableLongLongCol::init_data(void) +{ + // Initialise data if they exist + if (m_data != NULL) { + for (int i = 0; i < m_size; ++i) + m_data[i] = 0; + } + + // Return + return; +} + + +/*========================================================================== + = = + = Friends = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Output operator + * + * @param[in] os Output stream + * @param[in] column Column to put in output stream + ***************************************************************************/ +std::ostream& operator<< (std::ostream& os, const GFitsTableLongLongCol& column) +{ + // Dump column in output stream + column.dump_column(os, column.m_data); + + // Return output stream + return os; +} diff --git a/src/fits/GFitsTableShortCol.cpp b/src/fits/GFitsTableShortCol.cpp new file mode 100644 index 0000000..e78fcfa --- /dev/null +++ b/src/fits/GFitsTableShortCol.cpp @@ -0,0 +1,498 @@ +/*************************************************************************** + * GFitsTableShortCol.cpp - FITS table short column class * + * ----------------------------------------------------------------------- * + * copyright (C) 2010 by Jurgen Knodlseder * + * ----------------------------------------------------------------------- * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +/* __ Includes ___________________________________________________________ */ +#ifdef HAVE_CONFIG_H +#include +#endif +#include +#include "GException.hpp" +#include "GTools.hpp" +#include "GFitsTableShortCol.hpp" + +/* __ Method name definitions ____________________________________________ */ + +/* __ Macros _____________________________________________________________ */ + +/* __ Coding definitions _________________________________________________ */ + +/* __ Debug definitions __________________________________________________ */ + + +/*========================================================================== + = = + = Constructors/destructors = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Constructor + ***************************************************************************/ +GFitsTableShortCol::GFitsTableShortCol(void) : GFitsTableCol() +{ + // Initialise class members for clean destruction + init_members(); + + // Return + return; +} + + +/***********************************************************************//** + * @brief Constructor + * + * @param[in] name Name of column. + * @param[in] length Length of column. + * @param[in] size Vector size of column. + ***************************************************************************/ +GFitsTableShortCol::GFitsTableShortCol(const std::string& name, + const int& length, + const int& size) + : GFitsTableCol(name, length, size, 2) +{ + // Initialise class members for clean destruction + init_members(); + + // Return + return; +} + + +/***********************************************************************//** + * @brief Copy constructor + * + * @param[in] column Column from which class instance should be built. + ***************************************************************************/ +GFitsTableShortCol::GFitsTableShortCol(const GFitsTableShortCol& column) + : GFitsTableCol(column) +{ + // Initialise class members for clean destruction + init_members(); + + // Copy members + copy_members(column); + + // Return + return; +} + + +/***********************************************************************//** + * @brief Destructor + ***************************************************************************/ +GFitsTableShortCol::~GFitsTableShortCol(void) +{ + // Free members + free_members(); + + // Return + return; +} + + +/*========================================================================== + = = + = Operators = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Assignment operator + * + * @param[in] column Column which should be assigned + ***************************************************************************/ +GFitsTableShortCol& GFitsTableShortCol::operator= (const GFitsTableShortCol& column) +{ + // Execute only if object is not identical + if (this != &column) { + + // Copy base class members + this->GFitsTableCol::operator=(column); + + // Free members + free_members(); + + // Initialise private members for clean destruction + init_members(); + + // Copy members + copy_members(column); + + } // endif: object was not identical + + // Return this object + return *this; +} + + +/***********************************************************************//** + * @brief Column data access operator + * + * @param[in] row Row of column to access. + * @param[in] inx Vector index in column row to access + * + * Provides access to data in a column. + ***************************************************************************/ +short& GFitsTableShortCol::operator() (const int& row, const int& inx) +{ + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Return data bin + return m_data[offset(row, inx)]; +} + + +/***********************************************************************//** + * @brief Column data access operator (const variant) + * + * @param[in] row Row of column to access. + * @param[in] inx Vector index in column row to access + * + * Provides access to data in a column. + ***************************************************************************/ +const short& GFitsTableShortCol::operator() (const int& row, const int& inx) const +{ + // If data are not available then load them now + if (m_data == NULL) ((GFitsTableShortCol*)this)->fetch_data(); + + // Return data bin + return m_data[offset(row, inx)]; +} + + +/*========================================================================== + = = + = Public methods = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Get string value + * + * @param[in] row Table row. + * @param[in] inx Table column vector index. + * + * Returns value of specified row and vector index as string. + ***************************************************************************/ +std::string GFitsTableShortCol::string(const int& row, const int& inx) +{ + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Convert short into string + std::ostringstream s_value; + s_value << m_data[offset(row,inx)]; + + // Return value + return s_value.str(); +} + + +/***********************************************************************//** + * @brief Get double precision value + * + * @param[in] row Table row. + * @param[in] inx Table column vector index. + * + * Returns value of specified row and vector index as double precision. + ***************************************************************************/ +double GFitsTableShortCol::real(const int& row, const int& inx) +{ + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Convert short into double + double value = (double)m_data[offset(row,inx)]; + + // Return value + return value; +} + + +/***********************************************************************//** + * @brief Get integer value + * + * @param[in] row Table row. + * @param[in] inx Table column vector index. + * + * Returns value of specified row and vector index as integer. + ***************************************************************************/ +int GFitsTableShortCol::integer(const int& row, const int& inx) +{ + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Convert short into int + int value = (int)m_data[offset(row,inx)]; + + // Return value + return value; +} + + +/***********************************************************************//** + * @brief Set NULL value + * + * @param[in] value Pointer on NULL value + * + * Allows the specification of the FITS table NULL value. If value=NULL the + * data will not be screened for NULL values. + * + * @todo To correctly reflect the NULL value in the data, the column should + * be reloaded. However, the column may have been changed, so in principle + * saving is needed. However, we may not want to store the data, hence saving + * is also not desired. We thus have to develop a method to update the + * column information for a new NULL value in place ... + ***************************************************************************/ +void GFitsTableShortCol::nullval(const short* value) +{ + // Allocate nul value + alloc_nulval(value); + + // Update column +// if (m_data != NULL) { +// save(); +// load(); +// } + + // Return + return; +} + + +/*========================================================================== + = = + = Private methods = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Initialise class members + ***************************************************************************/ +void GFitsTableShortCol::init_members(void) +{ + // Initialise members + m_type = __TSHORT; + m_data = NULL; + m_nulval = NULL; + + // Return + return; +} + + +/***********************************************************************//** + * @brief Copy class members + * + * @param[in] column Column for which members should be copied. + * + * Sets the content of the vector column by copying from another column. + * If the code is compiled with the small memory option, and if the source + * column has not yet been loaded, then we only load the column temporarily + * for copying purposes and release it again once copying is finished. + ***************************************************************************/ +void GFitsTableShortCol::copy_members(const GFitsTableShortCol& column) +{ + // Fetch column data if not yet fetched. The casting circumvents the + // const correctness + bool not_loaded = (column.m_data == NULL); + if (not_loaded) ((GFitsTableShortCol*)(&column))->fetch_data(); + + // Copy attributes + m_type = column.m_type; + m_size = column.m_size; + + // Copy column data + if (column.m_data != NULL && m_size > 0) { + alloc_data(); + for (int i = 0; i < m_size; ++i) + m_data[i] = column.m_data[i]; + } + + // Copy NULL value + alloc_nulval(column.m_nulval); + + // Small memory option: release column if it was fetch above + #if defined(G_SMALL_MEMORY) + if (not_loaded) ((GFitsTableShortCol*)(&column))->release_data(); + #endif + + // Return + return; +} + + +/***********************************************************************//** + * @brief Delete class members + ***************************************************************************/ +void GFitsTableShortCol::free_members(void) +{ + // Free memory + if (m_data != NULL) delete [] m_data; + if (m_nulval != NULL) delete m_nulval; + + // Mark memory as freed + m_data = NULL; + m_nulval = NULL; + + // Reset load flag + m_size = 0; + + // Return + return; +} + + +/***********************************************************************//** + * @brief Clone column + ***************************************************************************/ +GFitsTableShortCol* GFitsTableShortCol::clone(void) const +{ + return new GFitsTableShortCol(*this); +} + + +/***********************************************************************//** + * @brief Returns format string of ASCII table + ***************************************************************************/ +std::string GFitsTableShortCol::ascii_format(void) const +{ + // Initialize format string + std::string format; + + // Set type code + format.append("I"); + + // Set width + format.append(str(m_width)); + + // Return format + return format; +} + + +/***********************************************************************//** + * @brief Returns format string of binary table + ***************************************************************************/ +std::string GFitsTableShortCol::binary_format(void) const +{ + // Initialize format string + std::string format; + + // Set number of elements + format.append(str(m_number)); + + // Set type code + format.append("I"); + + // Return format + return format; +} + + +/***********************************************************************//** + * @brief Allocates column data + ***************************************************************************/ +void GFitsTableShortCol::alloc_data(void) +{ + // Free any existing memory + if (m_data != NULL) delete [] m_data; + + // Mark pointer as free + m_data = NULL; + + // Allocate new data + if (m_size > 0) + m_data = new short[m_size]; + + // Return + return; +} + + +/***********************************************************************//** + * @brief Release column data + ***************************************************************************/ +void GFitsTableShortCol::release_data(void) +{ + // Free any existing memory + if (m_data != NULL) delete [] m_data; + + // Mark pointer as free and reset loaded vector size + m_data = NULL; + m_size = 0; + + // Return + return; +} + + +/***********************************************************************//** + * @brief Allocates null value + ***************************************************************************/ +void GFitsTableShortCol::alloc_nulval(const short* value) +{ + // Free any existing memory + if (m_nulval != NULL) delete m_nulval; + + // Mark pointer as free + m_nulval = NULL; + + // If we have valid value, allocate and set nul value + if (value != NULL) { + m_nulval = new short; + *m_nulval = *value; + } + + // Return + return; +} + + +/***********************************************************************//** + * @brief Initialise column data + ***************************************************************************/ +void GFitsTableShortCol::init_data(void) +{ + // Initialise data if they exist + if (m_data != NULL) { + for (int i = 0; i < m_size; ++i) + m_data[i] = 0; + } + + // Return + return; +} + + +/*========================================================================== + = = + = Friends = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Output operator + * + * @param[in] os Output stream + * @param[in] column Column to put in output stream + ***************************************************************************/ +std::ostream& operator<< (std::ostream& os, const GFitsTableShortCol& column) +{ + // Dump column in output stream + column.dump_column(os, column.m_data); + + // Return output stream + return os; +} diff --git a/src/fits/GFitsTableStrCol.cpp b/src/fits/GFitsTableStrCol.cpp deleted file mode 100644 index fae9771..0000000 --- a/src/fits/GFitsTableStrCol.cpp +++ /dev/null @@ -1,647 +0,0 @@ -/*************************************************************************** - * GFitsTableStrCol.cpp - FITS table string column class * - * ----------------------------------------------------------------------- * - * copyright (C) 2008-2010 by Jurgen Knodlseder * - * ----------------------------------------------------------------------- * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -/* __ Includes ___________________________________________________________ */ -#ifdef HAVE_CONFIG_H -#include -#endif -#include -#include -#include "GException.hpp" -#include "GTools.hpp" -#include "GFitsTableStrCol.hpp" - -/* __ Method name definitions ____________________________________________ */ -#define G_STRING "GFitsTableStrCol::string(const int&, const int&)" -#define G_REAL "GFitsTableStrCol::real(const int&, const int&)" -#define G_INTEGER "GFitsTableStrCol::integer(const int&, const int&)" - -/* __ Macros _____________________________________________________________ */ - -/* __ Coding definitions _________________________________________________ */ - -/* __ Debug definitions __________________________________________________ */ - - -/*========================================================================== - = = - = Constructors/destructors = - = = - ==========================================================================*/ - -/***********************************************************************//** - * @brief Constructor - ***************************************************************************/ -GFitsTableStrCol::GFitsTableStrCol() : GFitsTableCol() -{ - // Initialise class members for clean destruction - init_members(); - - // Return - return; -} - - -/***********************************************************************//** - * @brief Constructor - * - * @param[in] name Name of column. - * @param[in] length Length of column. - * @param[in] width Length of individual string. - * @param[in] size Number of strings in each column. - ***************************************************************************/ -GFitsTableStrCol::GFitsTableStrCol(const std::string& name, - const int& length, - const int& width, - const int& size) - : GFitsTableCol(name, length, size, width) -{ - // Initialise class members for clean destruction - init_members(); - - // Return - return; -} - - -/***********************************************************************//** - * @brief Copy constructor - * - * @param[in] column Column from which class instance should be built. - ***************************************************************************/ -GFitsTableStrCol::GFitsTableStrCol(const GFitsTableStrCol& column) - : GFitsTableCol(column) -{ - // Initialise class members for clean destruction - init_members(); - - // Copy members - copy_members(column); - - // Return - return; -} - - -/***********************************************************************//** - * @brief Destructor - ***************************************************************************/ -GFitsTableStrCol::~GFitsTableStrCol() -{ - // Free members - free_members(); - - // Return - return; -} - - -/*========================================================================== - = = - = Operators = - = = - ==========================================================================*/ - -/***********************************************************************//** - * @brief Assignment operator - * - * @param[in] column Column which should be assigned - ***************************************************************************/ -GFitsTableStrCol& GFitsTableStrCol::operator= (const GFitsTableStrCol& column) -{ - // Execute only if object is not identical - if (this != &column) { - - // Copy base class members - this->GFitsTableCol::operator=(column); - - // Free members - free_members(); - - // Initialise private members for clean destruction - init_members(); - - // Copy members - copy_members(column); - - } // endif: object was not identical - - // Return this object - return *this; -} - - -/***********************************************************************//** - * @brief Column data access operator - * - * @param[in] row Row of column to access. - * @param[in] inx Vector index in column row to access - * - * Provides access to data in a column. No range checking is performed. - * Use one of - * GFitsTableStrCol::string(ix,iy), - * GFitsTableStrCol::real(ix;iy) or - * GFitsTableStrCol::integer(ix;iy) - * if range checking is required. - ***************************************************************************/ -std::string& GFitsTableStrCol::operator() (const int& row, const int& inx) -{ - // If data are not available then load them now - if (m_data == NULL) fetch_data(); - - // Calculate pixel offset - int offset = row * m_number + inx; - - // Return data bin - return m_data[offset]; -} - - -/***********************************************************************//** - * @brief Column data access operator (const variant) - * - * @param[in] row Row of column to access. - * @param[in] inx Vector index in column row to access - * - * Provides access to data in a column. No range checking is performed. - * Use one of - * GFitsTableStrCol::string(ix,iy), - * GFitsTableStrCol::real(ix;iy) or - * GFitsTableStrCol::integer(ix;iy) - * if range checking is required. - ***************************************************************************/ -const std::string& GFitsTableStrCol::operator() (const int& row, const int& inx) - const -{ - // If data are not available then load them now - if (m_data == NULL) ((GFitsTableStrCol*)this)->fetch_data(); - - // Calculate pixel offset - int offset = row * m_number + inx; - - // Return data bin - return m_data[offset]; -} - - -/*========================================================================== - = = - = Public methods = - = = - ==========================================================================*/ - -/***********************************************************************//** - * @brief Get string value - * - * @param[in] row Table row. - * @param[in] inx Table column vector index. - * - * @exception GException::out_of_range - * Table row or vector index are out of valid range. - * - * Returns value of specified row and vector index as string. - ***************************************************************************/ -std::string GFitsTableStrCol::string(const int& row, const int& inx) -{ - // If data are not available then load them now - if (m_data == NULL) fetch_data(); - - // Check row value - if (row < 0 || row >= m_length) - throw GException::out_of_range(G_STRING, row, 0, m_length-1); - - // Check inx value - if (inx < 0 || inx >= m_number) - throw GException::out_of_range(G_STRING, inx, 0, m_number-1); - - // Get index - int offset = row * m_number + inx; - - // Return value - return m_data[offset]; -} - - -/***********************************************************************//** - * @brief Get double precision value - * - * @param[in] row Table row. - * @param[in] inx Table column vector index. - * - * @exception GException::out_of_range - * Table row or vector index are out of valid range. - * - * Returns value of specified row and vector index as double precision. - ***************************************************************************/ -double GFitsTableStrCol::real(const int& row, const int& inx) -{ - // If data are not available then load them now - if (m_data == NULL) fetch_data(); - - // Check row value - if (row < 0 || row >= m_length) - throw GException::out_of_range(G_REAL, row, 0, m_length-1); - - // Check inx value - if (inx < 0 || inx >= m_number) - throw GException::out_of_range(G_REAL, inx, 0, m_number-1); - - // Get index - int offset = row * m_number + inx; - - // Assign C string to double - double value = atof(m_data[offset].c_str()); - - // Return value - return value; -} - - -/***********************************************************************//** - * @brief Get integer value - * - * @param[in] row Table row. - * @param[in] inx Table column vector index. - * - * @exception GException::out_of_range - * Table row or vector index are out of valid range. - * - * Returns value of specified row and vector index as integer. - ***************************************************************************/ -int GFitsTableStrCol::integer(const int& row, const int& inx) -{ - // If data are not available then load them now - if (m_data == NULL) fetch_data(); - - // Check row value - if (row < 0 || row >= m_length) - throw GException::out_of_range(G_INTEGER, row, 0, m_length-1); - - // Check inx value - if (inx < 0 || inx >= m_number) - throw GException::out_of_range(G_INTEGER, inx, 0, m_number-1); - - // Get index - int offset = row * m_number + inx; - - // Assign C string to int - int value = int(atof(m_data[offset].c_str())); - - // Return value - return value; -} - - -/***********************************************************************//** - * @brief Return pointer to std::string column - ***************************************************************************/ -std::string* GFitsTableStrCol::data(void) -{ - return m_data; -} - - - -/***********************************************************************//** - * @brief Set NULL string - * - * @param[in] value Pointer on NULL string - * - * Allows the specification of the FITS table NULL string. If the string - * is empty the data will not be screened for NULL values. - ***************************************************************************/ -void GFitsTableStrCol::set_nullval(const std::string& string) -{ - // If NULL string is empty then reset the NULL string - if (string.empty()) { - if (m_nulval != NULL) delete [] m_nulval; - m_nulval = NULL; - } - - // ... otherwise copy string into NULL string - else { - if (m_nulval != NULL) delete [] m_nulval; - m_nulval = new char[m_width+1]; - strncpy(m_nulval, string.c_str(), m_width); - } - - // Re-load column -/* - if (m_data != NULL) { - save(); - load(); - } -*/ - - // Return - return; -} - - -/*========================================================================== - = = - = Private methods = - = = - ==========================================================================*/ - -/***********************************************************************//** - * @brief Initialise class members - ***************************************************************************/ -void GFitsTableStrCol::init_members(void) -{ - // Initialise members - m_type = __TSTRING; - m_data = NULL; - m_buffer = NULL; - m_nulval = NULL; - - // Return - return; -} - - -/***********************************************************************//** - * @brief Copy class members - * - * @param[in] column Column for which members should be copied. - ***************************************************************************/ -void GFitsTableStrCol::copy_members(const GFitsTableStrCol& column) -{ - // Fetch column data if not yet fetched. The casting circumvents the - // const correctness - if (column.m_data == NULL) - ((GFitsTableStrCol*)(&column))->fetch_data(); - - // Copy attributes - m_type = column.m_type; - m_size = column.m_size; - - // Copy column data - if (column.m_data != NULL && m_size > 0) { - alloc_data(); - for (int i = 0; i < m_size; ++i) - m_data[i] = column.m_data[i]; - } - - // Copy nulval data - if (column.m_nulval != NULL) { - m_nulval = new char[m_width+1]; - strncpy(m_nulval, column.m_nulval, m_width); - } - - // Return - return; -} - - -/***********************************************************************//** - * @brief Delete class members - ***************************************************************************/ -void GFitsTableStrCol::free_members(void) -{ - // Free memory - if (m_data != NULL) delete [] m_data; - if (m_nulval != NULL) delete m_nulval; - - // Mark memory as freed - m_data = NULL; - m_nulval = NULL; - - // Free buffer - free_buffer(); - - // Return - return; -} - - -/***********************************************************************//** - * @brief Save table column into FITS file - * - * The table column is only saved if it is linked to a FITS file and if the - * data are indeed present in the class instance. This avoids saving of data - * that have not been modified. - * - * Refer to GFitsTableCol::save_column() for more information. - ***************************************************************************/ -void GFitsTableStrCol::save(void) -{ - // Free buffer - free_buffer(); - - // Allocate buffer - alloc_buffer(); - - // Transfer string into buffer - for (int i = 0; i < m_size; ++i) - strncpy(m_buffer[i], m_data[i].c_str(), m_width); - - // Save column - save_column(); - - // Free buffer - free_buffer(); - - // Return - return; -} - - -/***********************************************************************//** - * @brief Clone column - ***************************************************************************/ -GFitsTableStrCol* GFitsTableStrCol::clone(void) const -{ - return new GFitsTableStrCol(*this); -} - - -/***********************************************************************//** - * @brief Returns format string of ASCII table - ***************************************************************************/ -std::string GFitsTableStrCol::ascii_format(void) const -{ - // Initialize format string - std::string format; - - // Set type code - format.append("A"); - - // Set width - format.append(str(m_width)); - - // Return format - return format; -} - - -/***********************************************************************//** - * @brief Returns format string of binary table - ***************************************************************************/ -std::string GFitsTableStrCol::binary_format(void) const -{ - // Initialize format string - std::string format; - - // Set number of elements - format.append(str(m_repeat)); - - // Set type code - format.append("A"); - - // If there are substrings then add width of substring - if (m_repeat > m_width) - format.append(str(m_width)); - - // Return format - return format; -} - - -/***********************************************************************//** - * @brief Allocates column data - ***************************************************************************/ -void GFitsTableStrCol::alloc_data(void) -{ - // Free memory - if (m_data != NULL) delete [] m_data; - - // Mark pointer as free - m_data = NULL; - - // Allocate new data - if (m_size > 0) - m_data = new std::string[m_size]; - - // Return - return; -} - - -/***********************************************************************//** - * @brief Initialise column data - ***************************************************************************/ -void GFitsTableStrCol::init_data(void) -{ - // Initialise data if they exist - if (m_data != NULL) { - for (int i = 0; i < m_size; ++i) - m_data[i].clear(); - } - - // Return - return; -} - - -/***********************************************************************//** - * @brief Fetch column data - * - * If a FITS file is attached to the column the data are loaded into memory - * from the FITS file. If no FITS file is attached, memory is allocated - * to hold the column data and all cells are set to 0. - * - * Refer to GFitsTableCol::load_column for more information. - ***************************************************************************/ -void GFitsTableStrCol::fetch_data(void) -{ - // Calculate size of memory - m_size = m_number * m_length; - - // Free old buffer memory - free_buffer(); - - // Allocate buffer memory - alloc_buffer(); - - // Save column - load_column(); - - // Extract string from buffer - for (int i = 0; i < m_size; ++i) { - if (m_buffer[i] != NULL) - m_data[i].assign(m_buffer[i]); - } - - // Free buffer memory - free_buffer(); - - // Return - return; -} - - -/***********************************************************************//** - * @brief Allocate buffer memory - ***************************************************************************/ -void GFitsTableStrCol::alloc_buffer(void) -{ - // Allocate buffer memory - if (m_size > 0) { - m_buffer = new char*[m_size]; - for (int i = 0; i < m_size; ++i) - m_buffer[i] = new char[m_width+1]; - } - - // Initialise buffer - if (m_buffer != NULL) { - for (int i = 0; i < m_size; ++i) { - for (int j = 0; j <= m_width; ++j) - (m_buffer[i])[j] = '\0'; - } - } - - // Return - return; -} - - -/***********************************************************************//** - * @brief Free buffer memory - ***************************************************************************/ -void GFitsTableStrCol::free_buffer(void) -{ - // If there was a buffer allocated then free it - if (m_buffer != NULL) { - for (int i = 0; i < m_size; ++i) { - if (m_buffer[i] != NULL) delete [] m_buffer[i]; - } - delete [] m_buffer; - m_buffer = NULL; - } - - // Return - return; -} - - -/*========================================================================== - = = - = Friends = - = = - ==========================================================================*/ - -/***********************************************************************//** - * @brief Output operator - * - * @param[in] os Output stream. - * @param[in] column Column to put in output stream. - ***************************************************************************/ -std::ostream& operator<< (std::ostream& os, const GFitsTableStrCol& column) -{ - // Dump column in output stream - column.dump_column(os, column.m_data); - - // Return output stream - return os; -} diff --git a/src/fits/GFitsTableStringCol.cpp b/src/fits/GFitsTableStringCol.cpp new file mode 100644 index 0000000..287ca81 --- /dev/null +++ b/src/fits/GFitsTableStringCol.cpp @@ -0,0 +1,617 @@ +/*************************************************************************** + * GFitsTableStringCol.cpp - FITS table string column class * + * ----------------------------------------------------------------------- * + * copyright (C) 2008-2010 by Jurgen Knodlseder * + * ----------------------------------------------------------------------- * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +/* __ Includes ___________________________________________________________ */ +#ifdef HAVE_CONFIG_H +#include +#endif +#include +#include +#include "GException.hpp" +#include "GTools.hpp" +#include "GFitsTableStringCol.hpp" + +/* __ Method name definitions ____________________________________________ */ + +/* __ Macros _____________________________________________________________ */ + +/* __ Coding definitions _________________________________________________ */ + +/* __ Debug definitions __________________________________________________ */ + + +/*========================================================================== + = = + = Constructors/destructors = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Constructor + ***************************************************************************/ +GFitsTableStringCol::GFitsTableStringCol(void) : GFitsTableCol() +{ + // Initialise class members for clean destruction + init_members(); + + // Return + return; +} + + +/***********************************************************************//** + * @brief Constructor + * + * @param[in] name Name of column. + * @param[in] length Length of column. + * @param[in] width Length of individual string. + * @param[in] size Number of strings in each column. + ***************************************************************************/ +GFitsTableStringCol::GFitsTableStringCol(const std::string& name, + const int& length, + const int& width, + const int& size) + : GFitsTableCol(name, length, size, width) +{ + // Initialise class members for clean destruction + init_members(); + + // Return + return; +} + + +/***********************************************************************//** + * @brief Copy constructor + * + * @param[in] column Column from which class instance should be built. + ***************************************************************************/ +GFitsTableStringCol::GFitsTableStringCol(const GFitsTableStringCol& column) + : GFitsTableCol(column) +{ + // Initialise class members for clean destruction + init_members(); + + // Copy members + copy_members(column); + + // Return + return; +} + + +/***********************************************************************//** + * @brief Destructor + ***************************************************************************/ +GFitsTableStringCol::~GFitsTableStringCol(void) +{ + // Free members + free_members(); + + // Return + return; +} + + +/*========================================================================== + = = + = Operators = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Assignment operator + * + * @param[in] column Column which should be assigned + ***************************************************************************/ +GFitsTableStringCol& GFitsTableStringCol::operator= (const GFitsTableStringCol& column) +{ + // Execute only if object is not identical + if (this != &column) { + + // Copy base class members + this->GFitsTableCol::operator=(column); + + // Free members + free_members(); + + // Initialise private members for clean destruction + init_members(); + + // Copy members + copy_members(column); + + } // endif: object was not identical + + // Return this object + return *this; +} + + +/***********************************************************************//** + * @brief Column data access operator + * + * @param[in] row Row of column to access. + * @param[in] inx Vector index in column row to access + * + * Provides access to data in a column. + ***************************************************************************/ +std::string& GFitsTableStringCol::operator() (const int& row, const int& inx) +{ + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Return data bin + return m_data[offset(row, inx)]; +} + + +/***********************************************************************//** + * @brief Column data access operator (const variant) + * + * @param[in] row Row of column to access. + * @param[in] inx Vector index in column row to access + * + * Provides access to data in a column. + ***************************************************************************/ +const std::string& GFitsTableStringCol::operator() (const int& row, const int& inx) const +{ + // If data are not available then load them now + if (m_data == NULL) ((GFitsTableStringCol*)this)->fetch_data(); + + // Return data bin + return m_data[offset(row, inx)]; +} + + +/*========================================================================== + = = + = Public methods = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Get string value + * + * @param[in] row Table row. + * @param[in] inx Table column vector index. + * + * Returns value of specified row and vector index as string. + ***************************************************************************/ +std::string GFitsTableStringCol::string(const int& row, const int& inx) +{ + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Return value + return m_data[offset(row,inx)]; +} + + +/***********************************************************************//** + * @brief Get double precision value + * + * @param[in] row Table row. + * @param[in] inx Table column vector index. + * + * Returns value of specified row and vector index as double precision. + ***************************************************************************/ +double GFitsTableStringCol::real(const int& row, const int& inx) +{ + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Assign string to double + double value = todouble(m_data[offset(row,inx)]); + + // Return value + return value; +} + + +/***********************************************************************//** + * @brief Get integer value + * + * @param[in] row Table row. + * @param[in] inx Table column vector index. + * + * Returns value of specified row and vector index as integer. + ***************************************************************************/ +int GFitsTableStringCol::integer(const int& row, const int& inx) +{ + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Assign string to int + int value = toint(m_data[offset(row,inx)]); + + // Return value + return value; +} + + +/***********************************************************************//** + * @brief Set NULL string + * + * @param[in] value Pointer on NULL string + * + * Allows the specification of the FITS table NULL string. If the string + * is empty the data will not be screened for NULL values. + ***************************************************************************/ +void GFitsTableStringCol::nullval(const std::string& value) +{ + // Allocate nul value + alloc_nulval(value); + + // Update column +// if (m_data != NULL) { +// save(); +// load(); +// } + + // Return + return; +} + + +/*========================================================================== + = = + = Private methods = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Initialise class members + ***************************************************************************/ +void GFitsTableStringCol::init_members(void) +{ + // Initialise members + m_type = __TSTRING; + m_data = NULL; + m_buffer = NULL; + m_nulval = NULL; + + // Return + return; +} + + +/***********************************************************************//** + * @brief Copy class members + * + * @param[in] column Column for which members should be copied. + * + * Sets the content of the vector column by copying from another column. + * If the code is compiled with the small memory option, and if the source + * column has not yet been loaded, then we only load the column temporarily + * for copying purposes and release it again once copying is finished. + ***************************************************************************/ +void GFitsTableStringCol::copy_members(const GFitsTableStringCol& column) +{ + // Fetch column data if not yet fetched. The casting circumvents the + // const correctness + bool not_loaded = (column.m_data == NULL); + if (not_loaded) ((GFitsTableStringCol*)(&column))->fetch_data(); + + // Copy attributes + m_type = column.m_type; + m_size = column.m_size; + + // Copy column data + if (column.m_data != NULL && m_size > 0) { + alloc_data(); + for (int i = 0; i < m_size; ++i) + m_data[i] = column.m_data[i]; + } + + // Copy NULL value + alloc_nulval(std::string(column.m_nulval)); + + // Small memory option: release column if it was fetch above + #if defined(G_SMALL_MEMORY) + if (not_loaded) ((GFitsTableStringCol*)(&column))->release_data(); + #endif + + // Return + return; +} + + +/***********************************************************************//** + * @brief Delete class members + ***************************************************************************/ +void GFitsTableStringCol::free_members(void) +{ + // Free memory + if (m_data != NULL) delete [] m_data; + if (m_nulval != NULL) delete m_nulval; + + // Mark memory as freed + m_data = NULL; + m_nulval = NULL; + + // Reset load flag + m_size = 0; + + // Free buffer + free_buffer(); + + // Return + return; +} + + +/***********************************************************************//** + * @brief Save table column into FITS file + * + * The table column is only saved if it is linked to a FITS file and if the + * data are indeed present in the class instance. This avoids saving of data + * that have not been modified. + * + * Refer to GFitsTableCol::save_column() for more information. + ***************************************************************************/ +void GFitsTableStringCol::save(void) +{ + // Free buffer + free_buffer(); + + // Allocate buffer + alloc_buffer(); + + // Transfer string into buffer + for (int i = 0; i < m_size; ++i) + strncpy(m_buffer[i], m_data[i].c_str(), m_width); + + // Save column + save_column(); + + // Free buffer + free_buffer(); + + // Return + return; +} + + +/***********************************************************************//** + * @brief Clone column + ***************************************************************************/ +GFitsTableStringCol* GFitsTableStringCol::clone(void) const +{ + return new GFitsTableStringCol(*this); +} + + +/***********************************************************************//** + * @brief Returns format string of ASCII table + ***************************************************************************/ +std::string GFitsTableStringCol::ascii_format(void) const +{ + // Initialize format string + std::string format; + + // Set type code + format.append("A"); + + // Set width + format.append(str(m_width)); + + // Return format + return format; +} + + +/***********************************************************************//** + * @brief Returns format string of binary table + ***************************************************************************/ +std::string GFitsTableStringCol::binary_format(void) const +{ + // Initialize format string + std::string format; + + // Set number of elements + format.append(str(m_repeat)); + + // Set type code + format.append("A"); + + // If there are substrings then add width of substring + if (m_repeat > m_width) + format.append(str(m_width)); + + // Return format + return format; +} + + +/***********************************************************************//** + * @brief Allocates column data + ***************************************************************************/ +void GFitsTableStringCol::alloc_data(void) +{ + // Free memory + if (m_data != NULL) delete [] m_data; + + // Mark pointer as free + m_data = NULL; + + // Allocate new data + if (m_size > 0) + m_data = new std::string[m_size]; + + // Return + return; +} + + +/***********************************************************************//** + * @brief Release column data + ***************************************************************************/ +void GFitsTableStringCol::release_data(void) +{ + // Free any existing memory + if (m_data != NULL) delete [] m_data; + + // Mark pointer as free and reset loaded vector size + m_data = NULL; + m_size = 0; + + // Return + return; +} + + +/***********************************************************************//** + * @brief Allocate null value + ***************************************************************************/ +void GFitsTableStringCol::alloc_nulval(const std::string& value) +{ + // Free any existing memory + if (m_nulval != NULL) delete m_nulval; + + // Mark pointer as free + m_nulval = NULL; + + // If we have valid value, allocate and set nul value + if (value.empty()) { + m_nulval = new char[m_width+1]; + strncpy(m_nulval, value.c_str(), m_width); + } + + // Return + return; +} + + +/***********************************************************************//** + * @brief Initialise column data + ***************************************************************************/ +void GFitsTableStringCol::init_data(void) +{ + // Initialise data if they exist + if (m_data != NULL) { + for (int i = 0; i < m_size; ++i) + m_data[i].clear(); + } + + // Return + return; +} + + +/***********************************************************************//** + * @brief Fetch column data + * + * If a FITS file is attached to the column the data are loaded into memory + * from the FITS file. If no FITS file is attached, memory is allocated + * to hold the column data and all cells are set to 0. + * + * Refer to GFitsTableCol::load_column for more information. + ***************************************************************************/ +void GFitsTableStringCol::fetch_data(void) +{ + // Calculate size of memory + m_size = m_number * m_length; + + // Free old buffer memory + free_buffer(); + + // Allocate buffer memory + alloc_buffer(); + + // Save column + load_column(); + + // Extract string from buffer + for (int i = 0; i < m_size; ++i) { + if (m_buffer[i] != NULL) + m_data[i].assign(m_buffer[i]); + } + + // Free buffer memory + free_buffer(); + + // Return + return; +} + + +/***********************************************************************//** + * @brief Allocate CFITSIO transfer buffer + * + * The CFITSIO transfer buffer allows transparent conversion from the CFITSIO + * storage format to a vector of strings. + ***************************************************************************/ +void GFitsTableStringCol::alloc_buffer(void) +{ + // Allocate buffer memory + if (m_size > 0) { + m_buffer = new char*[m_size]; + for (int i = 0; i < m_size; ++i) + m_buffer[i] = new char[m_width+1]; + } + + // Initialise buffer + if (m_buffer != NULL) { + for (int i = 0; i < m_size; ++i) { + for (int j = 0; j <= m_width; ++j) + (m_buffer[i])[j] = '\0'; + } + } + + // Return + return; +} + + +/***********************************************************************//** + * @brief Free CFITSIO transfer buffer + * + * Release memory that has been allocated for the CFITSIO transfer buffer. + ***************************************************************************/ +void GFitsTableStringCol::free_buffer(void) +{ + // If there was a buffer allocated then free it + if (m_buffer != NULL) { + for (int i = 0; i < m_size; ++i) { + if (m_buffer[i] != NULL) delete [] m_buffer[i]; + } + delete [] m_buffer; + m_buffer = NULL; + } + + // Return + return; +} + + +/*========================================================================== + = = + = Friends = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Output operator + * + * @param[in] os Output stream. + * @param[in] column Column to put in output stream. + ***************************************************************************/ +std::ostream& operator<< (std::ostream& os, const GFitsTableStringCol& column) +{ + // Dump column in output stream + column.dump_column(os, column.m_data); + + // Return output stream + return os; +} diff --git a/src/fits/GFitsTableULongCol.cpp b/src/fits/GFitsTableULongCol.cpp new file mode 100644 index 0000000..8982d19 --- /dev/null +++ b/src/fits/GFitsTableULongCol.cpp @@ -0,0 +1,495 @@ +/*************************************************************************** + * GFitsTableULongCol.cpp - FITS table unsigned long column class * + * ----------------------------------------------------------------------- * + * copyright (C) 2010 by Jurgen Knodlseder * + * ----------------------------------------------------------------------- * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +/* __ Includes ___________________________________________________________ */ +#ifdef HAVE_CONFIG_H +#include +#endif +#include +#include "GException.hpp" +#include "GTools.hpp" +#include "GFitsTableULongCol.hpp" + +/* __ Method name definitions ____________________________________________ */ + +/* __ Macros _____________________________________________________________ */ + +/* __ Coding definitions _________________________________________________ */ + +/* __ Debug definitions __________________________________________________ */ + + +/*========================================================================== + = = + = Constructors/destructors = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Constructor + ***************************************************************************/ +GFitsTableULongCol::GFitsTableULongCol(void) : GFitsTableCol() +{ + // Initialise class members for clean destruction + init_members(); + + // Return + return; +} + + +/***********************************************************************//** + * @brief Constructor + * + * @param[in] name Name of column. + * @param[in] length Length of column. + * @param[in] size Vector size of column. + ***************************************************************************/ +GFitsTableULongCol::GFitsTableULongCol(const std::string& name, + const int& length, + const int& size) + : GFitsTableCol(name, length, size, 2) +{ + // Initialise class members for clean destruction + init_members(); + + // Return + return; +} + + +/***********************************************************************//** + * @brief Copy constructor + * + * @param[in] column Column from which class instance should be built. + ***************************************************************************/ +GFitsTableULongCol::GFitsTableULongCol(const GFitsTableULongCol& column) + : GFitsTableCol(column) +{ + // Initialise class members for clean destruction + init_members(); + + // Copy members + copy_members(column); + + // Return + return; +} + + +/***********************************************************************//** + * @brief Destructor + ***************************************************************************/ +GFitsTableULongCol::~GFitsTableULongCol(void) +{ + // Free members + free_members(); + + // Return + return; +} + + +/*========================================================================== + = = + = Operators = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Assignment operator + * + * @param[in] column Column which should be assigned + ***************************************************************************/ +GFitsTableULongCol& GFitsTableULongCol::operator= (const GFitsTableULongCol& column) +{ + // Execute only if object is not identical + if (this != &column) { + + // Copy base class members + this->GFitsTableCol::operator=(column); + + // Free members + free_members(); + + // Initialise private members for clean destruction + init_members(); + + // Copy members + copy_members(column); + + } // endif: object was not identical + + // Return this object + return *this; +} + + +/***********************************************************************//** + * @brief Column data access operator + * + * @param[in] row Row of column to access. + * @param[in] inx Vector index in column row to access + * + * Provides access to data in a column. + ***************************************************************************/ +unsigned long& GFitsTableULongCol::operator() (const int& row, const int& inx) +{ + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Return data bin + return m_data[offset(row, inx)]; +} + + +/***********************************************************************//** + * @brief Column data access operator (const variant) + * + * @param[in] row Row of column to access. + * @param[in] inx Vector index in column row to access + * + * Provides access to data in a column. + ***************************************************************************/ +const unsigned long& GFitsTableULongCol::operator() (const int& row, const int& inx) const +{ + // If data are not available then load them now + if (m_data == NULL) ((GFitsTableULongCol*)this)->fetch_data(); + + // Return data bin + return m_data[offset(row, inx)]; +} + + +/*========================================================================== + = = + = Public methods = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Get string value + * + * @param[in] row Table row. + * @param[in] inx Table column vector index. + * + * Returns value of specified row and vector index as string. + ***************************************************************************/ +std::string GFitsTableULongCol::string(const int& row, const int& inx) +{ + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Convert unsigned long into string + std::ostringstream s_value; + s_value << m_data[offset(row,inx)]; + + // Return value + return s_value.str(); +} + + +/***********************************************************************//** + * @brief Get double precision value + * + * @param[in] row Table row. + * @param[in] inx Table column vector index. + * + * Returns value of specified row and vector index as double precision. + ***************************************************************************/ +double GFitsTableULongCol::real(const int& row, const int& inx) +{ + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Convert unsigned long into double + double value = (double)m_data[offset(row,inx)]; + + // Return value + return value; +} + + +/***********************************************************************//** + * @brief Get integer value + * + * @param[in] row Table row. + * @param[in] inx Table column vector index. + * + * Returns value of specified row and vector index as integer. + ***************************************************************************/ +int GFitsTableULongCol::integer(const int& row, const int& inx) +{ + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Convert unsigned long into int + int value = (int)m_data[offset(row,inx)]; + + // Return value + return value; +} + + +/***********************************************************************//** + * @brief Set NULL value + * + * @param[in] value Pointer on NULL value + * + * Allows the specification of the FITS table NULL value. If value=NULL the + * data will not be screened for NULL values. + * + * @todo To correctly reflect the NULL value in the data, the column should + * be reloaded. However, the column may have been changed, so in principle + * saving is needed. However, we may not want to store the data, hence saving + * is also not desired. We thus have to develop a method to update the + * column information for a new NULL value in place ... + ***************************************************************************/ +void GFitsTableULongCol::nullval(const unsigned long* value) +{ + // Allocate nul value + alloc_nulval(value); + + // Update column +// if (m_data != NULL) { +// save(); +// load(); +// } + + // Return + return; +} + + +/*========================================================================== + = = + = Private methods = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Initialise class members + ***************************************************************************/ +void GFitsTableULongCol::init_members(void) +{ + // Initialise members + m_type = __TULONG; + m_data = NULL; + m_nulval = NULL; + + // Return + return; +} + + +/***********************************************************************//** + * @brief Copy class members + * + * @param[in] column Column for which members should be copied. + * + * Sets the content of the vector column by copying from another column. + * If the code is compiled with the small memory option, and if the source + * column has not yet been loaded, then we only load the column temporarily + * for copying purposes and release it again once copying is finished. + ***************************************************************************/ +void GFitsTableULongCol::copy_members(const GFitsTableULongCol& column) +{ + // Fetch column data if not yet fetched. The casting circumvents the + // const correctness + bool not_loaded = (column.m_data == NULL); + if (not_loaded) ((GFitsTableULongCol*)(&column))->fetch_data(); + + // Copy attributes + m_type = column.m_type; + m_size = column.m_size; + + // Copy column data + if (column.m_data != NULL && m_size > 0) { + alloc_data(); + for (int i = 0; i < m_size; ++i) + m_data[i] = column.m_data[i]; + } + + // Copy NULL value + alloc_nulval(column.m_nulval); + + // Small memory option: release column if it was fetch above + #if defined(G_SMALL_MEMORY) + if (not_loaded) ((GFitsTableULongCol*)(&column))->release_data(); + #endif + + // Return + return; +} + + +/***********************************************************************//** + * @brief Delete class members + ***************************************************************************/ +void GFitsTableULongCol::free_members(void) +{ + // Free memory + if (m_data != NULL) delete [] m_data; + if (m_nulval != NULL) delete m_nulval; + + // Mark memory as freed + m_data = NULL; + m_nulval = NULL; + + // Return + return; +} + + +/***********************************************************************//** + * @brief Clone column + ***************************************************************************/ +GFitsTableULongCol* GFitsTableULongCol::clone(void) const +{ + return new GFitsTableULongCol(*this); +} + + +/***********************************************************************//** + * @brief Returns format string of ASCII table + ***************************************************************************/ +std::string GFitsTableULongCol::ascii_format(void) const +{ + // Initialize format string + std::string format; + + // Set type code + format.append("V"); + + // Set width + format.append(str(m_width)); + + // Return format + return format; +} + + +/***********************************************************************//** + * @brief Returns format string of binary table + ***************************************************************************/ +std::string GFitsTableULongCol::binary_format(void) const +{ + // Initialize format string + std::string format; + + // Set number of elements + format.append(str(m_number)); + + // Set type code + format.append("V"); + + // Return format + return format; +} + + +/***********************************************************************//** + * @brief Allocates column data + ***************************************************************************/ +void GFitsTableULongCol::alloc_data(void) +{ + // Free any existing memory + if (m_data != NULL) delete [] m_data; + + // Mark pointer as free + m_data = NULL; + + // Allocate new data + if (m_size > 0) + m_data = new unsigned long[m_size]; + + // Return + return; +} + + +/***********************************************************************//** + * @brief Release column data + ***************************************************************************/ +void GFitsTableULongCol::release_data(void) +{ + // Free any existing memory + if (m_data != NULL) delete [] m_data; + + // Mark pointer as free and reset loaded vector size + m_data = NULL; + m_size = 0; + + // Return + return; +} + + +/***********************************************************************//** + * @brief Allocates null value + ***************************************************************************/ +void GFitsTableULongCol::alloc_nulval(const unsigned long* value) +{ + // Free any existing memory + if (m_nulval != NULL) delete m_nulval; + + // Mark pointer as free + m_nulval = NULL; + + // If we have valid value, allocate and set nul value + if (value != NULL) { + m_nulval = new unsigned long; + *m_nulval = *value; + } + + // Return + return; +} + + +/***********************************************************************//** + * @brief Initialise column data + ***************************************************************************/ +void GFitsTableULongCol::init_data(void) +{ + // Initialise data if they exist + if (m_data != NULL) { + for (int i = 0; i < m_size; ++i) + m_data[i] = 0; + } + + // Return + return; +} + + +/*========================================================================== + = = + = Friends = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Output operator + * + * @param[in] os Output stream. + * @param[in] column Column to put in output stream. + ***************************************************************************/ +std::ostream& operator<< (std::ostream& os, const GFitsTableULongCol& column) +{ + // Dump column in output stream + column.dump_column(os, column.m_data); + + // Return output stream + return os; +} diff --git a/src/fits/GFitsTableUShortCol.cpp b/src/fits/GFitsTableUShortCol.cpp new file mode 100644 index 0000000..1735418 --- /dev/null +++ b/src/fits/GFitsTableUShortCol.cpp @@ -0,0 +1,495 @@ +/*************************************************************************** + * GFitsTableUShortCol.cpp - FITS table unsigned short column class * + * ----------------------------------------------------------------------- * + * copyright (C) 2010 by Jurgen Knodlseder * + * ----------------------------------------------------------------------- * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +/* __ Includes ___________________________________________________________ */ +#ifdef HAVE_CONFIG_H +#include +#endif +#include +#include "GException.hpp" +#include "GTools.hpp" +#include "GFitsTableUShortCol.hpp" + +/* __ Method name definitions ____________________________________________ */ + +/* __ Macros _____________________________________________________________ */ + +/* __ Coding definitions _________________________________________________ */ + +/* __ Debug definitions __________________________________________________ */ + + +/*========================================================================== + = = + = Constructors/destructors = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Constructor + ***************************************************************************/ +GFitsTableUShortCol::GFitsTableUShortCol(void) : GFitsTableCol() +{ + // Initialise class members for clean destruction + init_members(); + + // Return + return; +} + + +/***********************************************************************//** + * @brief Constructor + * + * @param[in] name Name of column. + * @param[in] length Length of column. + * @param[in] size Vector size of column. + ***************************************************************************/ +GFitsTableUShortCol::GFitsTableUShortCol(const std::string& name, + const int& length, + const int& size) + : GFitsTableCol(name, length, size, 2) +{ + // Initialise class members for clean destruction + init_members(); + + // Return + return; +} + + +/***********************************************************************//** + * @brief Copy constructor + * + * @param[in] column Column from which class instance should be built. + ***************************************************************************/ +GFitsTableUShortCol::GFitsTableUShortCol(const GFitsTableUShortCol& column) + : GFitsTableCol(column) +{ + // Initialise class members for clean destruction + init_members(); + + // Copy members + copy_members(column); + + // Return + return; +} + + +/***********************************************************************//** + * @brief Destructor + ***************************************************************************/ +GFitsTableUShortCol::~GFitsTableUShortCol(void) +{ + // Free members + free_members(); + + // Return + return; +} + + +/*========================================================================== + = = + = Operators = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Assignment operator + * + * @param[in] column Column which should be assigned + ***************************************************************************/ +GFitsTableUShortCol& GFitsTableUShortCol::operator= (const GFitsTableUShortCol& column) +{ + // Execute only if object is not identical + if (this != &column) { + + // Copy base class members + this->GFitsTableCol::operator=(column); + + // Free members + free_members(); + + // Initialise private members for clean destruction + init_members(); + + // Copy members + copy_members(column); + + } // endif: object was not identical + + // Return this object + return *this; +} + + +/***********************************************************************//** + * @brief Column data access operator + * + * @param[in] row Row of column to access. + * @param[in] inx Vector index in column row to access + * + * Provides access to data in a column. + ***************************************************************************/ +unsigned short& GFitsTableUShortCol::operator() (const int& row, const int& inx) +{ + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Return data bin + return m_data[offset(row, inx)]; +} + + +/***********************************************************************//** + * @brief Column data access operator (const variant) + * + * @param[in] row Row of column to access. + * @param[in] inx Vector index in column row to access + * + * Provides access to data in a column. + ***************************************************************************/ +const unsigned short& GFitsTableUShortCol::operator() (const int& row, const int& inx) const +{ + // If data are not available then load them now + if (m_data == NULL) ((GFitsTableUShortCol*)this)->fetch_data(); + + // Return data bin + return m_data[offset(row, inx)]; +} + + +/*========================================================================== + = = + = Public methods = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Get string value + * + * @param[in] row Table row. + * @param[in] inx Table column vector index. + * + * Returns value of specified row and vector index as string. + ***************************************************************************/ +std::string GFitsTableUShortCol::string(const int& row, const int& inx) +{ + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Convert unsigned short into string + std::ostringstream s_value; + s_value << m_data[offset(row,inx)]; + + // Return value + return s_value.str(); +} + + +/***********************************************************************//** + * @brief Get double precision value + * + * @param[in] row Table row. + * @param[in] inx Table column vector index. + * + * Returns value of specified row and vector index as double precision. + ***************************************************************************/ +double GFitsTableUShortCol::real(const int& row, const int& inx) +{ + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Convert unsigned short into double + double value = (double)m_data[offset(row,inx)]; + + // Return value + return value; +} + + +/***********************************************************************//** + * @brief Get integer value + * + * @param[in] row Table row. + * @param[in] inx Table column vector index. + * + * Returns value of specified row and vector index as integer. + ***************************************************************************/ +int GFitsTableUShortCol::integer(const int& row, const int& inx) +{ + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Convert unsigned short into int + int value = (int)m_data[offset(row,inx)]; + + // Return value + return value; +} + + +/***********************************************************************//** + * @brief Set NULL value + * + * @param[in] value Pointer on NULL value + * + * Allows the specification of the FITS table NULL value. If value=NULL the + * data will not be screened for NULL values. + * + * @todo To correctly reflect the NULL value in the data, the column should + * be reloaded. However, the column may have been changed, so in principle + * saving is needed. However, we may not want to store the data, hence saving + * is also not desired. We thus have to develop a method to update the + * column information for a new NULL value in place ... + ***************************************************************************/ +void GFitsTableUShortCol::nullval(const unsigned short* value) +{ + // Allocate nul value + alloc_nulval(value); + + // Update column +// if (m_data != NULL) { +// save(); +// load(); +// } + + // Return + return; +} + + +/*========================================================================== + = = + = Private methods = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Initialise class members + ***************************************************************************/ +void GFitsTableUShortCol::init_members(void) +{ + // Initialise members + m_type = __TUSHORT; + m_data = NULL; + m_nulval = NULL; + + // Return + return; +} + + +/***********************************************************************//** + * @brief Copy class members + * + * @param[in] column Column for which members should be copied. + * + * Sets the content of the vector column by copying from another column. + * If the code is compiled with the small memory option, and if the source + * column has not yet been loaded, then we only load the column temporarily + * for copying purposes and release it again once copying is finished. + ***************************************************************************/ +void GFitsTableUShortCol::copy_members(const GFitsTableUShortCol& column) +{ + // Fetch column data if not yet fetched. The casting circumvents the + // const correctness + bool not_loaded = (column.m_data == NULL); + if (not_loaded) ((GFitsTableUShortCol*)(&column))->fetch_data(); + + // Copy attributes + m_type = column.m_type; + m_size = column.m_size; + + // Copy column data + if (column.m_data != NULL && m_size > 0) { + alloc_data(); + for (int i = 0; i < m_size; ++i) + m_data[i] = column.m_data[i]; + } + + // Copy NULL value + alloc_nulval(column.m_nulval); + + // Small memory option: release column if it was fetch above + #if defined(G_SMALL_MEMORY) + if (not_loaded) ((GFitsTableUShortCol*)(&column))->release_data(); + #endif + + // Return + return; +} + + +/***********************************************************************//** + * @brief Delete class members + ***************************************************************************/ +void GFitsTableUShortCol::free_members(void) +{ + // Free memory + if (m_data != NULL) delete [] m_data; + if (m_nulval != NULL) delete m_nulval; + + // Mark memory as freed + m_data = NULL; + m_nulval = NULL; + + // Return + return; +} + + +/***********************************************************************//** + * @brief Clone column + ***************************************************************************/ +GFitsTableUShortCol* GFitsTableUShortCol::clone(void) const +{ + return new GFitsTableUShortCol(*this); +} + + +/***********************************************************************//** + * @brief Returns format string of ASCII table + ***************************************************************************/ +std::string GFitsTableUShortCol::ascii_format(void) const +{ + // Initialize format string + std::string format; + + // Set type code + format.append("U"); + + // Set width + format.append(str(m_width)); + + // Return format + return format; +} + + +/***********************************************************************//** + * @brief Returns format string of binary table + ***************************************************************************/ +std::string GFitsTableUShortCol::binary_format(void) const +{ + // Initialize format string + std::string format; + + // Set number of elements + format.append(str(m_number)); + + // Set type code + format.append("U"); + + // Return format + return format; +} + + +/***********************************************************************//** + * @brief Allocates column data + ***************************************************************************/ +void GFitsTableUShortCol::alloc_data(void) +{ + // Free any existing memory + if (m_data != NULL) delete [] m_data; + + // Mark pointer as free + m_data = NULL; + + // Allocate new data + if (m_size > 0) + m_data = new unsigned short[m_size]; + + // Return + return; +} + + +/***********************************************************************//** + * @brief Release column data + ***************************************************************************/ +void GFitsTableUShortCol::release_data(void) +{ + // Free any existing memory + if (m_data != NULL) delete [] m_data; + + // Mark pointer as free and reset loaded vector size + m_data = NULL; + m_size = 0; + + // Return + return; +} + + +/***********************************************************************//** + * @brief Allocates null value + ***************************************************************************/ +void GFitsTableUShortCol::alloc_nulval(const unsigned short* value) +{ + // Free any existing memory + if (m_nulval != NULL) delete m_nulval; + + // Mark pointer as free + m_nulval = NULL; + + // If we have valid value, allocate and set nul value + if (value != NULL) { + m_nulval = new unsigned short; + *m_nulval = *value; + } + + // Return + return; +} + + +/***********************************************************************//** + * @brief Initialise column data + ***************************************************************************/ +void GFitsTableUShortCol::init_data(void) +{ + // Initialise data if they exist + if (m_data != NULL) { + for (int i = 0; i < m_size; ++i) + m_data[i] = 0; + } + + // Return + return; +} + + +/*========================================================================== + = = + = Friends = + = = + ==========================================================================*/ + +/***********************************************************************//** + * @brief Output operator + * + * @param[in] os Output stream. + * @param[in] column Column to put in output stream. + ***************************************************************************/ +std::ostream& operator<< (std::ostream& os, const GFitsTableUShortCol& column) +{ + // Dump column in output stream + column.dump_column(os, column.m_data); + + // Return output stream + return os; +} diff --git a/src/fits/Makefile.am b/src/fits/Makefile.am index e30954d..8415b22 100644 --- a/src/fits/Makefile.am +++ b/src/fits/Makefile.am @@ -17,15 +17,15 @@ sources = GFitsHeaderCard.cpp \ GFitsBinTable.cpp \ GFitsTableCol.cpp \ GFitsTableBitCol.cpp \ - GFitsTableLogCol.cpp \ - GFitsTableStrCol.cpp \ - GFitsTableUStCol.cpp \ - GFitsTableShtCol.cpp \ - GFitsTableULgCol.cpp \ - GFitsTableLngCol.cpp \ - GFitsTableLlgCol.cpp \ - GFitsTableFltCol.cpp \ - GFitsTableDblCol.cpp \ + GFitsTableBoolCol.cpp \ + GFitsTableStringCol.cpp \ + GFitsTableUShortCol.cpp \ + GFitsTableShortCol.cpp \ + GFitsTableULongCol.cpp \ + GFitsTableLongCol.cpp \ + GFitsTableLongLongCol.cpp \ + GFitsTableFloatCol.cpp \ + GFitsTableDoubleCol.cpp \ GFitsHDU.cpp \ GFits.cpp \ GException_fits.cpp diff --git a/src/obs/GEbounds.cpp b/src/obs/GEbounds.cpp index 52fea40..2b64200 100644 --- a/src/obs/GEbounds.cpp +++ b/src/obs/GEbounds.cpp @@ -27,7 +27,7 @@ #include "GFits.hpp" #include "GFitsHDU.hpp" #include "GFitsBinTable.hpp" -#include "GFitsTableDblCol.hpp" +#include "GFitsTableDoubleCol.hpp" /* __ Method name definitions ____________________________________________ */ #define G_EMIN "GEbounds::emin(int)" @@ -381,8 +381,8 @@ void GEbounds::read(GFitsHDU* hdu) void GEbounds::write(GFits* file, const std::string& extname) { // Create energy boundary columns - GFitsTableDblCol cemin = GFitsTableDblCol("E_MIN", m_num); - GFitsTableDblCol cemax = GFitsTableDblCol("E_MAX", m_num); + GFitsTableDoubleCol cemin = GFitsTableDoubleCol("E_MIN", m_num); + GFitsTableDoubleCol cemax = GFitsTableDoubleCol("E_MAX", m_num); // Fill energy boundary columns for (int i = 0; i < m_num; ++i) { diff --git a/src/obs/GGti.cpp b/src/obs/GGti.cpp index 84b7d03..4b8d6b2 100644 --- a/src/obs/GGti.cpp +++ b/src/obs/GGti.cpp @@ -26,7 +26,7 @@ #include "GFits.hpp" #include "GFitsHDU.hpp" #include "GFitsBinTable.hpp" -#include "GFitsTableDblCol.hpp" +#include "GFitsTableDoubleCol.hpp" /* __ Method name definitions ____________________________________________ */ #define G_TSTART "GGti::tstart(int)" @@ -354,8 +354,8 @@ void GGti::read(GFitsHDU* hdu) void GGti::write(GFits* file, const std::string& extname) { // Create GTI columns - GFitsTableDblCol cstart = GFitsTableDblCol("START", m_num); - GFitsTableDblCol cstop = GFitsTableDblCol("STOP", m_num); + GFitsTableDoubleCol cstart = GFitsTableDoubleCol("START", m_num); + GFitsTableDoubleCol cstop = GFitsTableDoubleCol("STOP", m_num); // Fill GTI columns for (int i = 0; i < m_num; ++i) { diff --git a/src/sky/GSkymap.cpp b/src/sky/GSkymap.cpp index 27b9619..698738c 100644 --- a/src/sky/GSkymap.cpp +++ b/src/sky/GSkymap.cpp @@ -27,7 +27,7 @@ #include "GWcsCAR.hpp" #include "GWcsHPX.hpp" #include "GFits.hpp" -#include "GFitsTableDblCol.hpp" +#include "GFitsTableDoubleCol.hpp" #include "GFitsImageDbl.hpp" /* __ Method name definitions ____________________________________________ */ @@ -1250,7 +1250,7 @@ GFitsHDU* GSkymap::create_healpix_hdu(void) int number = m_num_maps; // Create column to hold Healpix data - GFitsTableDblCol column = GFitsTableDblCol("DATA", rows, number); + GFitsTableDoubleCol column = GFitsTableDoubleCol("DATA", rows, number); // Fill data into column double* ptr = m_pixels; diff --git a/test/test_GFits.cpp b/test/test_GFits.cpp index 9d6f888..8022577 100644 --- a/test/test_GFits.cpp +++ b/test/test_GFits.cpp @@ -12,13 +12,12 @@ ***************************************************************************/ /* __ Includes ___________________________________________________________ */ -#include // cout, cerr +#include // std::cout, cerr #include // std::exception #include #include "GammaLib.hpp" /* __ Namespaces _________________________________________________________ */ -using namespace std; /* __ Globals ____________________________________________________________ */ @@ -46,7 +45,7 @@ int dequal(double val, double ref) void test_create(void) { // Dump header - cout << "Test GFits: Create FITS file: "; + std::cout << "Test GFits: Create FITS file: "; // Remove FITS file system("rm -rf test.fits"); @@ -60,12 +59,14 @@ void test_create(void) fits.append(hdu); fits.save(); } - catch (exception &e) { - cout << endl << "TEST ERROR: Unable to create FITS file." << endl; - cout << e.what() << endl; + catch (std::exception &e) { + std::cout << std::endl + << "TEST ERROR: Unable to create FITS file." + << std::endl; + std::cout << e.what() << std::endl; throw; } - cout << "."; + std::cout << "."; // Attach double precision image double sum = 0.0; @@ -87,12 +88,14 @@ void test_create(void) fits.append(hdu); fits.save(); } - catch (exception &e) { - cout << endl << "TEST ERROR: Unable to create FITS file." << endl; - cout << e.what() << endl; + catch (std::exception &e) { + std::cout << std::endl + << "TEST ERROR: Unable to create FITS file." + << std::endl; + std::cout << e.what() << std::endl; throw; } - cout << "."; + std::cout << "."; // Re-open double precision image try { @@ -109,16 +112,20 @@ void test_create(void) } } if (!dequal(total, sum)) { - cout << endl << "TEST ERROR: Bad values in loaded image." << endl; + std::cout << std::endl + << "TEST ERROR: Bad values in loaded image." + << std::endl; throw; } } - catch (exception &e) { - cout << endl << "TEST ERROR: Unable to re-open FITS file." << endl; - cout << e.what() << endl; + catch (std::exception &e) { + std::cout << std::endl + << "TEST ERROR: Unable to re-open FITS file." + << std::endl; + std::cout << e.what() << std::endl; throw; } - cout << "."; + std::cout << "."; // Attach binary table try { @@ -128,18 +135,17 @@ void test_create(void) // Create binary Table with 10 rows int nrows = 10; - GFitsBinTable table = GFitsBinTable(nrows); - GFitsTableDblCol first = GFitsTableDblCol("First", nrows); - GFitsTableDblCol second = GFitsTableDblCol("Second", nrows); + GFitsBinTable table = GFitsBinTable(nrows); + GFitsTableDoubleCol first = GFitsTableDoubleCol("First", nrows); + GFitsTableDoubleCol second = GFitsTableDoubleCol("Second", nrows); first(0) = 1.0; first(1) = 2.0; first(2) = 3.0; second(0) = -99.0; - cout << endl << first << endl; - cout << second << endl; + std::cout << std::endl << first << std::endl; + std::cout << second << std::endl; table.append_column(first); table.append_column(second); -// cout << table; // Create HDU and append to FILE file GFitsHDU hdu(table); @@ -148,15 +154,17 @@ void test_create(void) // Save FITS file fits.save(); } - catch (exception &e) { - cout << endl << "TEST ERROR: Unable to attach binary table." << endl; - cout << e.what() << endl; + catch (std::exception &e) { + std::cout << std::endl + << "TEST ERROR: Unable to attach binary table." + << std::endl; + std::cout << e.what() << std::endl; throw; } - cout << "."; + std::cout << "."; - cout << ". ok." << endl; + std::cout << ". ok." << std::endl; } @@ -166,7 +174,7 @@ void test_create(void) void test_image_double(void) { // Dump header - cout << "Test GFitsDblImage: "; + std::cout << "Test GFitsDblImage: "; // Test 1D Image try { @@ -174,7 +182,7 @@ void test_image_double(void) int nx = 10; int naxes[] = {nx}; GFitsImageDbl image(naxis, naxes); - cout << "."; + std::cout << "."; // Fill and read image try { @@ -184,27 +192,33 @@ void test_image_double(void) for (int ix = 0; ix < nx; ++ix) sum += image(ix); if (!dequal(sum, 0.5*double(nx-1)*double(nx))) { - cout << endl << "TEST ERROR: Bad fill/read of 1D image." << endl; + std::cout << std::endl + << "TEST ERROR: Bad fill/read of 1D image." + << std::endl; throw; } } - catch (exception &e) { - cout << endl << "TEST ERROR: Unable to fill/read 1D image." << endl; - cout << e.what() << endl; + catch (std::exception &e) { + std::cout << std::endl + << "TEST ERROR: Unable to fill/read 1D image." + << std::endl; + std::cout << e.what() << std::endl; throw; } - cout << "."; + std::cout << "."; // Bad 2D operator try { double result = image(0,1); } catch (GException::fits_wrong_image_operator &e) { - cout << "."; + std::cout << "."; } - catch (exception &e) { - cout << endl << "TEST ERROR: Wrong operactor access error." << endl; - cout << e.what() << endl; + catch (std::exception &e) { + std::cout << std::endl + << "TEST ERROR: Wrong operactor access error." + << std::endl; + std::cout << e.what() << std::endl; throw; } @@ -213,11 +227,13 @@ void test_image_double(void) double result = image(0,1,2); } catch (GException::fits_wrong_image_operator &e) { - cout << "."; + std::cout << "."; } - catch (exception &e) { - cout << endl << "TEST ERROR: Wrong operactor access error." << endl; - cout << e.what() << endl; + catch (std::exception &e) { + std::cout << std::endl + << "TEST ERROR: Wrong operactor access error." + << std::endl; + std::cout << e.what() << std::endl; throw; } @@ -226,21 +242,25 @@ void test_image_double(void) double result = image(0,1,2,3); } catch (GException::fits_wrong_image_operator &e) { - cout << "."; + std::cout << "."; } - catch (exception &e) { - cout << endl << "TEST ERROR: Wrong operactor access error." << endl; - cout << e.what() << endl; + catch (std::exception &e) { + std::cout << std::endl + << "TEST ERROR: Wrong operactor access error." + << std::endl; + std::cout << e.what() << std::endl; throw; } } - catch (exception &e) { - cout << endl << "TEST ERROR: Unable to test GFitsDblImage classes." << endl; - cout << e.what() << endl; + catch (std::exception &e) { + std::cout << std::endl + << "TEST ERROR: Unable to test GFitsDblImage classes." + << std::endl; + std::cout << e.what() << std::endl; throw; } - cout << ". ok." << endl; + std::cout << ". ok." << std::endl; } @@ -253,7 +273,7 @@ void test_bintable_double(void) std::string filename = "test_bintable_double.fits"; // Dump header - cout << "Test GFitsTableDblCol: "; + std::cout << "Test GFitsTableDoubleCol: "; // Remove FITS file std::string cmd = "rm -rf "+ filename; @@ -290,84 +310,84 @@ void test_bintable_double(void) // // Set double precision table - GFitsTableDblCol col_dbl = GFitsTableDblCol("DOUBLE", nrows); + GFitsTableDoubleCol col_dbl = GFitsTableDoubleCol("DOUBLE", nrows); for (int i = 0; i < nrows; ++i) { double val_dbl = cos(double(i)); col_dbl(i) = val_dbl; sum_dbl += val_dbl; sum_dbl_int += int(val_dbl); - ostringstream s_value; - s_value << scientific << val_dbl; + std::ostringstream s_value; + s_value << std::scientific << val_dbl; sum_dbl_str += ":"+s_value.str(); } - cout << "."; + std::cout << "."; // Check double precision table (operator access) tot_dbl = 0.0; for (int i = 0; i < nrows; ++i) tot_dbl += col_dbl(i); if (!dequal(tot_dbl, sum_dbl)) { - cout << endl << "TEST ERROR: GFitsTableDblCol::operator()"; - cout << endl << " Reference sum: " << sum_dbl; - cout << endl << " Derived sum: " << tot_dbl << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableDoubleCol::operator()"; + std::cout << std::endl << " Reference sum: " << sum_dbl; + std::cout << std::endl << " Derived sum: " << tot_dbl << std::endl; throw; } - cout << "."; + std::cout << "."; // Check double precision table (real access) tot_dbl = 0.0; for (int i = 0; i < nrows; ++i) tot_dbl += col_dbl.real(i); if (!dequal(tot_dbl, sum_dbl)) { - cout << endl << "TEST ERROR: GFitsTableDblCol::real()"; - cout << endl << " Reference sum: " << sum_dbl; - cout << endl << " Derived sum: " << tot_dbl << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableDoubleCol::real()"; + std::cout << std::endl << " Reference sum: " << sum_dbl; + std::cout << std::endl << " Derived sum: " << tot_dbl << std::endl; throw; } - cout << "."; + std::cout << "."; // Check double precision table (int access) tot_int = 0; for (int i = 0; i < nrows; ++i) tot_int += col_dbl.integer(i); if (tot_int != sum_dbl_int) { - cout << endl << "TEST ERROR: GFitsTableDblCol::integer()"; - cout << endl << " Reference sum: " << sum_dbl_int; - cout << endl << " Derived sum: " << tot_int << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableDoubleCol::integer()"; + std::cout << std::endl << " Reference sum: " << sum_dbl_int; + std::cout << std::endl << " Derived sum: " << tot_int << std::endl; throw; } - cout << "."; + std::cout << "."; // Check double precision table (string access) tot_str.clear(); for (int i = 0; i < nrows; ++i) tot_str += ":"+col_dbl.string(i); if (tot_str != sum_dbl_str) { - cout << endl << "TEST ERROR: GFitsTableDblCol::string()"; - cout << endl << " Reference sum: " << sum_dbl_str; - cout << endl << " Derived sum: " << tot_str << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableDoubleCol::string()"; + std::cout << std::endl << " Reference sum: " << sum_dbl_str; + std::cout << std::endl << " Derived sum: " << tot_str << std::endl; throw; } - cout << "."; + std::cout << "."; // // ===== D O U B L E 1 0 ===== // // Set double precision table - GFitsTableDblCol col_dbl10 = GFitsTableDblCol("DOUBLE10", nrows, nvec); + GFitsTableDoubleCol col_dbl10 = GFitsTableDoubleCol("DOUBLE10", nrows, nvec); for (int i = 0; i < nrows; ++i) { for (int j = 0; j < nvec; ++j) { double val_dbl = cos(double(i))*cos(0.33*double(j)); col_dbl10(i,j) = val_dbl; sum_dbl10 += val_dbl; sum_dbl10_int += int(val_dbl); - ostringstream s_value; - s_value << scientific << val_dbl; + std::ostringstream s_value; + s_value << std::scientific << val_dbl; sum_dbl10_str += ":"+s_value.str(); } } - cout << "."; + std::cout << "."; // Check double precision table (operator access) tot_dbl = 0.0; @@ -376,12 +396,12 @@ void test_bintable_double(void) tot_dbl += col_dbl10(i,j); } if (!dequal(tot_dbl, sum_dbl10)) { - cout << endl << "TEST ERROR: GFitsTableDblCol::operator() - 10"; - cout << endl << " Reference sum: " << sum_dbl10; - cout << endl << " Derived sum: " << tot_dbl << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableDoubleCol::operator() - 10"; + std::cout << std::endl << " Reference sum: " << sum_dbl10; + std::cout << std::endl << " Derived sum: " << tot_dbl << std::endl; throw; } - cout << "."; + std::cout << "."; // Check double precision table (real access) tot_dbl = 0.0; @@ -390,12 +410,12 @@ void test_bintable_double(void) tot_dbl += col_dbl10.real(i,j); } if (!dequal(tot_dbl, sum_dbl10)) { - cout << endl << "TEST ERROR: GFitsTableDblCol::real() - 10"; - cout << endl << " Reference sum: " << sum_dbl10; - cout << endl << " Derived sum: " << tot_dbl << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableDoubleCol::real() - 10"; + std::cout << std::endl << " Reference sum: " << sum_dbl10; + std::cout << std::endl << " Derived sum: " << tot_dbl << std::endl; throw; } - cout << "."; + std::cout << "."; // Check double precision table (int access) tot_int = 0; @@ -404,12 +424,12 @@ void test_bintable_double(void) tot_int += col_dbl10.integer(i,j); } if (tot_int != sum_dbl10_int) { - cout << endl << "TEST ERROR: GFitsTableDblCol::integer() - 10"; - cout << endl << " Reference sum: " << sum_dbl10_int; - cout << endl << " Derived sum: " << tot_int << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableDoubleCol::integer() - 10"; + std::cout << std::endl << " Reference sum: " << sum_dbl10_int; + std::cout << std::endl << " Derived sum: " << tot_int << std::endl; throw; } - cout << "."; + std::cout << "."; // Check double precision table (string access) tot_str.clear(); @@ -418,12 +438,12 @@ void test_bintable_double(void) tot_str += ":"+col_dbl10.string(i,j); } if (tot_str != sum_dbl10_str) { - cout << endl << "TEST ERROR: GFitsTableDblCol::string() - 10"; - cout << endl << " Reference sum: " << sum_dbl10_str; - cout << endl << " Derived sum: " << tot_str << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableDoubleCol::string() - 10"; + std::cout << std::endl << " Reference sum: " << sum_dbl10_str; + std::cout << std::endl << " Derived sum: " << tot_str << std::endl; throw; } - cout << "."; + std::cout << "."; // // ===== W R I T E T A B L E ===== @@ -440,14 +460,14 @@ void test_bintable_double(void) // Save FITS file fits.save(); - cout << "."; + std::cout << "."; } - catch (exception &e) { - cout << endl << "TEST ERROR: Unable to build tables." << endl; - cout << e.what() << endl; + catch (std::exception &e) { + std::cout << std::endl << "TEST ERROR: Unable to build tables." << std::endl; + std::cout << e.what() << std::endl; throw; } - cout << "."; + std::cout << "."; //================================================================ @@ -477,64 +497,64 @@ void test_bintable_double(void) // // Get column - GFitsTableDblCol* col_dbl = - (GFitsTableDblCol*)fits.hdu(1)->column("DOUBLE"); + GFitsTableDoubleCol* col_dbl = + (GFitsTableDoubleCol*)fits.hdu(1)->column("DOUBLE"); // Check double precision table (operator access) tot_dbl = 0.0; for (int i = 0; i < nrows; ++i) tot_dbl += (*col_dbl)(i); if (!dequal(tot_dbl, sum_dbl)) { - cout << endl << "TEST ERROR: GFitsTableDblCol::operator()"; - cout << endl << " Reference sum: " << sum_dbl; - cout << endl << " Derived sum: " << tot_dbl << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableDoubleCol::operator()"; + std::cout << std::endl << " Reference sum: " << sum_dbl; + std::cout << std::endl << " Derived sum: " << tot_dbl << std::endl; throw; } - cout << "."; + std::cout << "."; // Check double precision table (real access) tot_dbl = 0.0; for (int i = 0; i < nrows; ++i) tot_dbl += (*col_dbl).real(i); if (!dequal(tot_dbl, sum_dbl)) { - cout << endl << "TEST ERROR: GFitsTableDblCol::real()"; - cout << endl << " Reference sum: " << sum_dbl; - cout << endl << " Derived sum: " << tot_dbl << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableDoubleCol::real()"; + std::cout << std::endl << " Reference sum: " << sum_dbl; + std::cout << std::endl << " Derived sum: " << tot_dbl << std::endl; throw; } - cout << "."; + std::cout << "."; // Check double precision table (int access) tot_int = 0; for (int i = 0; i < nrows; ++i) tot_int += (*col_dbl).integer(i); if (tot_int != sum_dbl_int) { - cout << endl << "TEST ERROR: GFitsTableDblCol::integer()"; - cout << endl << " Reference sum: " << sum_dbl_int; - cout << endl << " Derived sum: " << tot_int << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableDoubleCol::integer()"; + std::cout << std::endl << " Reference sum: " << sum_dbl_int; + std::cout << std::endl << " Derived sum: " << tot_int << std::endl; throw; } - cout << "."; + std::cout << "."; // Check double precision table (string access) tot_str.clear(); for (int i = 0; i < nrows; ++i) tot_str += ":"+ (*col_dbl).string(i); if (tot_str != sum_dbl_str) { - cout << endl << "TEST ERROR: GFitsTableDblCol::string()"; - cout << endl << " Reference sum: " << sum_dbl_str; - cout << endl << " Derived sum: " << tot_str << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableDoubleCol::string()"; + std::cout << std::endl << " Reference sum: " << sum_dbl_str; + std::cout << std::endl << " Derived sum: " << tot_str << std::endl; throw; } - cout << "."; + std::cout << "."; // // ===== D O U B L E 1 0 ===== // // Get column - GFitsTableDblCol* col_dbl10 = - (GFitsTableDblCol*)fits.hdu(1)->column("DOUBLE10"); + GFitsTableDoubleCol* col_dbl10 = + (GFitsTableDoubleCol*)fits.hdu(1)->column("DOUBLE10"); // Check double precision table (operator access) tot_dbl = 0.0; @@ -543,12 +563,12 @@ void test_bintable_double(void) tot_dbl += (*col_dbl10)(i,j); } if (!dequal(tot_dbl, sum_dbl10)) { - cout << endl << "TEST ERROR: GFitsTableDblCol::operator() - 10"; - cout << endl << " Reference sum: " << sum_dbl10; - cout << endl << " Derived sum: " << tot_dbl << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableDoubleCol::operator() - 10"; + std::cout << std::endl << " Reference sum: " << sum_dbl10; + std::cout << std::endl << " Derived sum: " << tot_dbl << std::endl; throw; } - cout << "."; + std::cout << "."; // Check double precision table (real access) tot_dbl = 0.0; @@ -557,12 +577,12 @@ void test_bintable_double(void) tot_dbl += col_dbl10->real(i,j); } if (!dequal(tot_dbl, sum_dbl10)) { - cout << endl << "TEST ERROR: GFitsTableDblCol::real() - 10"; - cout << endl << " Reference sum: " << sum_dbl10; - cout << endl << " Derived sum: " << tot_dbl << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableDoubleCol::real() - 10"; + std::cout << std::endl << " Reference sum: " << sum_dbl10; + std::cout << std::endl << " Derived sum: " << tot_dbl << std::endl; throw; } - cout << "."; + std::cout << "."; // Check double precision table (int access) tot_int = 0; @@ -571,12 +591,12 @@ void test_bintable_double(void) tot_int += col_dbl10->integer(i,j); } if (tot_int != sum_dbl10_int) { - cout << endl << "TEST ERROR: GFitsTableDblCol::integer() - 10"; - cout << endl << " Reference sum: " << sum_dbl10_int; - cout << endl << " Derived sum: " << tot_int << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableDoubleCol::integer() - 10"; + std::cout << std::endl << " Reference sum: " << sum_dbl10_int; + std::cout << std::endl << " Derived sum: " << tot_int << std::endl; throw; } - cout << "."; + std::cout << "."; // Check double precision table (string access) tot_str.clear(); @@ -585,19 +605,19 @@ void test_bintable_double(void) tot_str += ":"+col_dbl10->string(i,j); } if (tot_str != sum_dbl10_str) { - cout << endl << "TEST ERROR: GFitsTableDblCol::string() - 10"; - cout << endl << " Reference sum: " << sum_dbl10_str; - cout << endl << " Derived sum: " << tot_str << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableDoubleCol::string() - 10"; + std::cout << std::endl << " Reference sum: " << sum_dbl10_str; + std::cout << std::endl << " Derived sum: " << tot_str << std::endl; throw; } - cout << "."; + std::cout << "."; } - catch (exception &e) { - cout << endl << "TEST ERROR: Unable to build tables." << endl; - cout << e.what() << endl; + catch (std::exception &e) { + std::cout << std::endl << "TEST ERROR: Unable to build tables." << std::endl; + std::cout << e.what() << std::endl; throw; } - cout << ". ok." << endl; + std::cout << ". ok." << std::endl; } @@ -611,7 +631,7 @@ void test_bintable_float(void) std::string filename = "test_bintable_float.fits"; // Dump header - cout << "Test GFitsTableFltCol: "; + std::cout << "Test GFitsTableFloatCol: "; // Remove FITS file std::string cmd = "rm -rf "+ filename; @@ -648,84 +668,84 @@ void test_bintable_float(void) // // Set single precision table - GFitsTableFltCol col_flt = GFitsTableFltCol("FLOAT", nrows); + GFitsTableFloatCol col_flt = GFitsTableFloatCol("FLOAT", nrows); for (int i = 0; i < nrows; ++i) { float val_flt = cos(0.1*float(i)); col_flt(i) = val_flt; sum_flt += val_flt; sum_flt_int += int(val_flt); - ostringstream s_value; - s_value << scientific << val_flt; + std::ostringstream s_value; + s_value << std::scientific << val_flt; sum_flt_str += ":"+s_value.str(); } - cout << "."; + std::cout << "."; // Check single precision table (operator access) tot_flt = 0.0; for (int i = 0; i < nrows; ++i) tot_flt += col_flt(i); if (!fequal(tot_flt, sum_flt)) { - cout << endl << "TEST ERROR: GFitsTableFltCol::operator()"; - cout << endl << " Reference sum: " << sum_flt; - cout << endl << " Derived sum: " << tot_flt << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableFloatCol::operator()"; + std::cout << std::endl << " Reference sum: " << sum_flt; + std::cout << std::endl << " Derived sum: " << tot_flt << std::endl; throw; } - cout << "."; + std::cout << "."; // Check single precision table (real access) tot_flt = 0.0; for (int i = 0; i < nrows; ++i) tot_flt += col_flt.real(i); if (!fequal(tot_flt, sum_flt)) { - cout << endl << "TEST ERROR: GFitsTableFltCol::real()"; - cout << endl << " Reference sum: " << sum_flt; - cout << endl << " Derived sum: " << tot_flt << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableFloatCol::real()"; + std::cout << std::endl << " Reference sum: " << sum_flt; + std::cout << std::endl << " Derived sum: " << tot_flt << std::endl; throw; } - cout << "."; + std::cout << "."; // Check single precision table (int access) tot_int = 0; for (int i = 0; i < nrows; ++i) tot_int += col_flt.integer(i); if (tot_int != sum_flt_int) { - cout << endl << "TEST ERROR: GFitsTableFltCol::integer()"; - cout << endl << " Reference sum: " << sum_flt_int; - cout << endl << " Derived sum: " << tot_int << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableFloatCol::integer()"; + std::cout << std::endl << " Reference sum: " << sum_flt_int; + std::cout << std::endl << " Derived sum: " << tot_int << std::endl; throw; } - cout << "."; + std::cout << "."; // Check single precision table (string access) tot_str.clear(); for (int i = 0; i < nrows; ++i) tot_str += ":"+col_flt.string(i); if (tot_str != sum_flt_str) { - cout << endl << "TEST ERROR: GFitsTableFltCol::string()"; - cout << endl << " Reference sum: " << sum_flt_str; - cout << endl << " Derived sum: " << tot_str << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableFloatCol::string()"; + std::cout << std::endl << " Reference sum: " << sum_flt_str; + std::cout << std::endl << " Derived sum: " << tot_str << std::endl; throw; } - cout << "."; + std::cout << "."; // // ===== F L O A T 1 0 ===== // // Set single precision table - GFitsTableFltCol col_flt10 = GFitsTableFltCol("FLOAT10", nrows, nvec); + GFitsTableFloatCol col_flt10 = GFitsTableFloatCol("FLOAT10", nrows, nvec); for (int i = 0; i < nrows; ++i) { for (int j = 0; j < nvec; ++j) { float val_flt = cos(0.1*float(i))*cos(0.33*float(j)); col_flt10(i,j) = val_flt; sum_flt10 += val_flt; sum_flt10_int += int(val_flt); - ostringstream s_value; - s_value << scientific << val_flt; + std::ostringstream s_value; + s_value << std::scientific << val_flt; sum_flt10_str += ":"+s_value.str(); } } - cout << "."; + std::cout << "."; // Check single precision table (operator access) tot_flt = 0.0; @@ -734,12 +754,12 @@ void test_bintable_float(void) tot_flt += col_flt10(i,j); } if (!fequal(tot_flt, sum_flt10)) { - cout << endl << "TEST ERROR: GFitsTableFltCol::operator() - 10"; - cout << endl << " Reference sum: " << sum_flt10; - cout << endl << " Derived sum: " << tot_flt << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableFloatCol::operator() - 10"; + std::cout << std::endl << " Reference sum: " << sum_flt10; + std::cout << std::endl << " Derived sum: " << tot_flt << std::endl; throw; } - cout << "."; + std::cout << "."; // Check single precision table (real access) tot_flt = 0.0; @@ -748,12 +768,12 @@ void test_bintable_float(void) tot_flt += col_flt10.real(i,j); } if (!fequal(tot_flt, sum_flt10)) { - cout << endl << "TEST ERROR: GFitsTableFltCol::real() - 10"; - cout << endl << " Reference sum: " << sum_flt10; - cout << endl << " Derived sum: " << tot_flt << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableFloatCol::real() - 10"; + std::cout << std::endl << " Reference sum: " << sum_flt10; + std::cout << std::endl << " Derived sum: " << tot_flt << std::endl; throw; } - cout << "."; + std::cout << "."; // Check double precision table (int access) tot_int = 0; @@ -762,12 +782,12 @@ void test_bintable_float(void) tot_int += col_flt10.integer(i,j); } if (tot_int != sum_flt10_int) { - cout << endl << "TEST ERROR: GFitsTableFltCol::integer() - 10"; - cout << endl << " Reference sum: " << sum_flt10_int; - cout << endl << " Derived sum: " << tot_int << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableFloatCol::integer() - 10"; + std::cout << std::endl << " Reference sum: " << sum_flt10_int; + std::cout << std::endl << " Derived sum: " << tot_int << std::endl; throw; } - cout << "."; + std::cout << "."; // Check single precision table (string access) tot_str.clear(); @@ -776,12 +796,12 @@ void test_bintable_float(void) tot_str += ":"+col_flt10.string(i,j); } if (tot_str != sum_flt10_str) { - cout << endl << "TEST ERROR: GFitsTableFltCol::string() - 10"; - cout << endl << " Reference sum: " << sum_flt10_str; - cout << endl << " Derived sum: " << tot_str << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableFloatCol::string() - 10"; + std::cout << std::endl << " Reference sum: " << sum_flt10_str; + std::cout << std::endl << " Derived sum: " << tot_str << std::endl; throw; } - cout << "."; + std::cout << "."; // // ===== W R I T E T A B L E ===== @@ -798,15 +818,15 @@ void test_bintable_float(void) // Save FITS file fits.save(); - cout << "."; + std::cout << "."; } - catch (exception &e) { - cout << endl << "TEST ERROR: Unable to test floating point column in" - " binary tables." << endl; - cout << e.what() << endl; + catch (std::exception &e) { + std::cout << std::endl << "TEST ERROR: Unable to test floating point column in" + " binary tables." << std::endl; + std::cout << e.what() << std::endl; throw; } - cout << "."; + std::cout << "."; //================================================================ @@ -836,64 +856,64 @@ void test_bintable_float(void) // // Get column - GFitsTableFltCol* col_flt = - (GFitsTableFltCol*)fits.hdu(1)->column("FLOAT"); + GFitsTableFloatCol* col_flt = + (GFitsTableFloatCol*)fits.hdu(1)->column("FLOAT"); // Check single precision table (operator access) tot_flt = 0.0; for (int i = 0; i < nrows; ++i) tot_flt += (*col_flt)(i); if (!fequal(tot_flt, sum_flt)) { - cout << endl << "TEST ERROR: GFitsTableFltCol::operator()"; - cout << endl << " Reference sum: " << sum_flt; - cout << endl << " Derived sum: " << tot_flt << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableFloatCol::operator()"; + std::cout << std::endl << " Reference sum: " << sum_flt; + std::cout << std::endl << " Derived sum: " << tot_flt << std::endl; throw; } - cout << "."; + std::cout << "."; // Check single precision table (real access) tot_flt = 0.0; for (int i = 0; i < nrows; ++i) tot_flt += col_flt->real(i); if (!fequal(tot_flt, sum_flt)) { - cout << endl << "TEST ERROR: GFitsTableFltCol::real()"; - cout << endl << " Reference sum: " << sum_flt; - cout << endl << " Derived sum: " << tot_flt << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableFloatCol::real()"; + std::cout << std::endl << " Reference sum: " << sum_flt; + std::cout << std::endl << " Derived sum: " << tot_flt << std::endl; throw; } - cout << "."; + std::cout << "."; // Check single precision table (int access) tot_int = 0; for (int i = 0; i < nrows; ++i) tot_int += col_flt->integer(i); if (tot_int != sum_flt_int) { - cout << endl << "TEST ERROR: GFitsTableFltCol::integer()"; - cout << endl << " Reference sum: " << sum_flt_int; - cout << endl << " Derived sum: " << tot_int << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableFloatCol::integer()"; + std::cout << std::endl << " Reference sum: " << sum_flt_int; + std::cout << std::endl << " Derived sum: " << tot_int << std::endl; throw; } - cout << "."; + std::cout << "."; // Check single precision table (string access) tot_str.clear(); for (int i = 0; i < nrows; ++i) tot_str += ":"+col_flt->string(i); if (tot_str != sum_flt_str) { - cout << endl << "TEST ERROR: GFitsTableFltCol::string()"; - cout << endl << " Reference sum: " << sum_flt_str; - cout << endl << " Derived sum: " << tot_str << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableFloatCol::string()"; + std::cout << std::endl << " Reference sum: " << sum_flt_str; + std::cout << std::endl << " Derived sum: " << tot_str << std::endl; throw; } - cout << "."; + std::cout << "."; // // ===== F L O A T 1 0 ===== // // Get column - GFitsTableFltCol* col_flt10 = - (GFitsTableFltCol*)fits.hdu(1)->column("FLOAT10"); + GFitsTableFloatCol* col_flt10 = + (GFitsTableFloatCol*)fits.hdu(1)->column("FLOAT10"); // Check single precision table (operator access) tot_flt = 0.0; @@ -902,12 +922,12 @@ void test_bintable_float(void) tot_flt += (*col_flt10)(i,j); } if (!fequal(tot_flt, sum_flt10)) { - cout << endl << "TEST ERROR: GFitsTableFltCol::operator() - 10"; - cout << endl << " Reference sum: " << sum_flt10; - cout << endl << " Derived sum: " << tot_flt << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableFloatCol::operator() - 10"; + std::cout << std::endl << " Reference sum: " << sum_flt10; + std::cout << std::endl << " Derived sum: " << tot_flt << std::endl; throw; } - cout << "."; + std::cout << "."; // Check single precision table (real access) tot_flt = 0.0; @@ -916,12 +936,12 @@ void test_bintable_float(void) tot_flt += col_flt10->real(i,j); } if (!fequal(tot_flt, sum_flt10)) { - cout << endl << "TEST ERROR: GFitsTableFltCol::real() - 10"; - cout << endl << " Reference sum: " << sum_flt10; - cout << endl << " Derived sum: " << tot_flt << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableFloatCol::real() - 10"; + std::cout << std::endl << " Reference sum: " << sum_flt10; + std::cout << std::endl << " Derived sum: " << tot_flt << std::endl; throw; } - cout << "."; + std::cout << "."; // Check double precision table (int access) tot_int = 0; @@ -930,12 +950,12 @@ void test_bintable_float(void) tot_int += col_flt10->integer(i,j); } if (tot_int != sum_flt10_int) { - cout << endl << "TEST ERROR: GFitsTableFltCol::integer() - 10"; - cout << endl << " Reference sum: " << sum_flt10_int; - cout << endl << " Derived sum: " << tot_int << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableFloatCol::integer() - 10"; + std::cout << std::endl << " Reference sum: " << sum_flt10_int; + std::cout << std::endl << " Derived sum: " << tot_int << std::endl; throw; } - cout << "."; + std::cout << "."; // Check single precision table (string access) tot_str.clear(); @@ -944,20 +964,20 @@ void test_bintable_float(void) tot_str += ":"+col_flt10->string(i,j); } if (tot_str != sum_flt10_str) { - cout << endl << "TEST ERROR: GFitsTableFltCol::string() - 10"; - cout << endl << " Reference sum: " << sum_flt10_str; - cout << endl << " Derived sum: " << tot_str << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableFloatCol::string() - 10"; + std::cout << std::endl << " Reference sum: " << sum_flt10_str; + std::cout << std::endl << " Derived sum: " << tot_str << std::endl; throw; } - cout << "."; + std::cout << "."; } - catch (exception &e) { - cout << endl << "TEST ERROR: Unable to build tables." << endl; - cout << e.what() << endl; + catch (std::exception &e) { + std::cout << std::endl << "TEST ERROR: Unable to build tables." << std::endl; + std::cout << e.what() << std::endl; throw; } - cout << ". ok." << endl; + std::cout << ". ok." << std::endl; } @@ -971,7 +991,7 @@ void test_bintable_short(void) std::string filename = "test_bintable_short.fits"; // Dump header - cout << "Test GFitsTableShtCol: "; + std::cout << "Test GFitsTableShortCol: "; // Remove FITS file std::string cmd = "rm -rf "+ filename; @@ -1008,72 +1028,72 @@ void test_bintable_short(void) // // Set short table - GFitsTableShtCol col_sht = GFitsTableShtCol("SHORT", nrows); + GFitsTableShortCol col_sht = GFitsTableShortCol("SHORT", nrows); for (int i = 0; i < nrows; ++i) { short val_sht = short(1000.0 * cos(0.1*float(i))); col_sht(i) = val_sht; sum_sht += val_sht; sum_sht_int += int(val_sht); - ostringstream s_value; + std::ostringstream s_value; s_value << val_sht; sum_sht_str += ":"+s_value.str(); } - cout << "."; + std::cout << "."; // Check short table (operator access) tot_sht = 0; for (int i = 0; i < nrows; ++i) tot_sht += col_sht(i); if (tot_sht != sum_sht) { - cout << endl << "TEST ERROR: GFitsTableShtCol::operator()"; - cout << endl << " Reference sum: " << sum_sht; - cout << endl << " Derived sum: " << tot_sht << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableShortCol::operator()"; + std::cout << std::endl << " Reference sum: " << sum_sht; + std::cout << std::endl << " Derived sum: " << tot_sht << std::endl; throw; } - cout << "."; + std::cout << "."; // Check short table (real access) tot_dbl = 0.0; for (int i = 0; i < nrows; ++i) tot_dbl += col_sht.real(i); if (!dequal(tot_dbl, double(sum_sht))) { - cout << endl << "TEST ERROR: GFitsTableShtCol::real()"; - cout << endl << " Reference sum: " << sum_sht; - cout << endl << " Derived sum: " << tot_dbl << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableShortCol::real()"; + std::cout << std::endl << " Reference sum: " << sum_sht; + std::cout << std::endl << " Derived sum: " << tot_dbl << std::endl; throw; } - cout << "."; + std::cout << "."; // Check short table (int access) tot_int = 0; for (int i = 0; i < nrows; ++i) tot_int += col_sht.integer(i); if (tot_int != sum_sht_int) { - cout << endl << "TEST ERROR: GFitsTableShtCol::integer()"; - cout << endl << " Reference sum: " << sum_sht_int; - cout << endl << " Derived sum: " << tot_int << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableShortCol::integer()"; + std::cout << std::endl << " Reference sum: " << sum_sht_int; + std::cout << std::endl << " Derived sum: " << tot_int << std::endl; throw; } - cout << "."; + std::cout << "."; // Check single precision table (string access) tot_str.clear(); for (int i = 0; i < nrows; ++i) tot_str += ":"+col_sht.string(i); if (tot_str != sum_sht_str) { - cout << endl << "TEST ERROR: GFitsTableShtCol::string()"; - cout << endl << " Reference sum: " << sum_sht_str; - cout << endl << " Derived sum: " << tot_str << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableShortCol::string()"; + std::cout << std::endl << " Reference sum: " << sum_sht_str; + std::cout << std::endl << " Derived sum: " << tot_str << std::endl; throw; } - cout << "."; + std::cout << "."; // // ===== S H O R T 1 0 ===== // // Set short table - GFitsTableShtCol col_sht10 = GFitsTableShtCol("SHORT10", nrows, nvec); + GFitsTableShortCol col_sht10 = GFitsTableShortCol("SHORT10", nrows, nvec); for (int i = 0; i < nrows; ++i) { for (int j = 0; j < nvec; ++j) { short val_sht = short(100.0*cos(0.1*float(i))* @@ -1081,12 +1101,12 @@ void test_bintable_short(void) col_sht10(i,j) = val_sht; sum_sht10 += val_sht; sum_sht10_int += int(val_sht); - ostringstream s_value; + std::ostringstream s_value; s_value << val_sht; sum_sht10_str += ":"+s_value.str(); } } - cout << "."; + std::cout << "."; // Check short table (operator access) tot_sht = 0; @@ -1095,12 +1115,12 @@ void test_bintable_short(void) tot_sht += col_sht10(i,j); } if (tot_sht != sum_sht10) { - cout << endl << "TEST ERROR: GFitsTableShtCol::operator() - 10"; - cout << endl << " Reference sum: " << sum_sht10; - cout << endl << " Derived sum: " << tot_sht << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableShortCol::operator() - 10"; + std::cout << std::endl << " Reference sum: " << sum_sht10; + std::cout << std::endl << " Derived sum: " << tot_sht << std::endl; throw; } - cout << "."; + std::cout << "."; // Check short table (real access) tot_dbl = 0.0; @@ -1109,12 +1129,12 @@ void test_bintable_short(void) tot_dbl += col_sht10.real(i,j); } if (!dequal(tot_dbl, sum_sht10)) { - cout << endl << "TEST ERROR: GFitsTableShtCol::real() - 10"; - cout << endl << " Reference sum: " << sum_sht10; - cout << endl << " Derived sum: " << tot_dbl << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableShortCol::real() - 10"; + std::cout << std::endl << " Reference sum: " << sum_sht10; + std::cout << std::endl << " Derived sum: " << tot_dbl << std::endl; throw; } - cout << "."; + std::cout << "."; // Check short table (int access) tot_int = 0; @@ -1123,12 +1143,12 @@ void test_bintable_short(void) tot_int += col_sht10.integer(i,j); } if (tot_int != sum_sht10_int) { - cout << endl << "TEST ERROR: GFitsTableShtCol::integer() - 10"; - cout << endl << " Reference sum: " << sum_sht10_int; - cout << endl << " Derived sum: " << tot_int << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableShortCol::integer() - 10"; + std::cout << std::endl << " Reference sum: " << sum_sht10_int; + std::cout << std::endl << " Derived sum: " << tot_int << std::endl; throw; } - cout << "."; + std::cout << "."; // Check single precision table (string access) tot_str.clear(); @@ -1137,12 +1157,12 @@ void test_bintable_short(void) tot_str += ":"+col_sht10.string(i,j); } if (tot_str != sum_sht10_str) { - cout << endl << "TEST ERROR: GFitsTableShtCol::string() - 10"; - cout << endl << " Reference sum: " << sum_sht10_str; - cout << endl << " Derived sum: " << tot_str << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableShortCol::string() - 10"; + std::cout << std::endl << " Reference sum: " << sum_sht10_str; + std::cout << std::endl << " Derived sum: " << tot_str << std::endl; throw; } - cout << "."; + std::cout << "."; // // ===== W R I T E T A B L E ===== @@ -1159,15 +1179,15 @@ void test_bintable_short(void) // Save FITS file fits.save(); - cout << "."; + std::cout << "."; } - catch (exception &e) { - cout << endl << "TEST ERROR: Unable to build tables." << endl; - cout << e.what() << endl; + catch (std::exception &e) { + std::cout << std::endl << "TEST ERROR: Unable to build tables." << std::endl; + std::cout << e.what() << std::endl; throw; } - cout << "."; + std::cout << "."; //================================================================ @@ -1198,64 +1218,64 @@ void test_bintable_short(void) // // Get column - GFitsTableShtCol* col_sht = - (GFitsTableShtCol*)fits.hdu(1)->column("SHORT"); + GFitsTableShortCol* col_sht = + (GFitsTableShortCol*)fits.hdu(1)->column("SHORT"); // Check short table (operator access) tot_sht = 0; for (int i = 0; i < nrows; ++i) tot_sht += (*col_sht)(i); if (tot_sht != sum_sht) { - cout << endl << "TEST ERROR: GFitsTableShtCol::operator()"; - cout << endl << " Reference sum: " << sum_sht; - cout << endl << " Derived sum: " << tot_sht << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableShortCol::operator()"; + std::cout << std::endl << " Reference sum: " << sum_sht; + std::cout << std::endl << " Derived sum: " << tot_sht << std::endl; throw; } - cout << "."; + std::cout << "."; // Check short table (real access) tot_dbl = 0.0; for (int i = 0; i < nrows; ++i) tot_dbl += col_sht->real(i); if (!dequal(tot_dbl, double(sum_sht))) { - cout << endl << "TEST ERROR: GFitsTableShtCol::real()"; - cout << endl << " Reference sum: " << sum_sht; - cout << endl << " Derived sum: " << tot_dbl << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableShortCol::real()"; + std::cout << std::endl << " Reference sum: " << sum_sht; + std::cout << std::endl << " Derived sum: " << tot_dbl << std::endl; throw; } - cout << "."; + std::cout << "."; // Check short table (int access) tot_int = 0; for (int i = 0; i < nrows; ++i) tot_int += col_sht->integer(i); if (tot_int != sum_sht_int) { - cout << endl << "TEST ERROR: GFitsTableShtCol::integer()"; - cout << endl << " Reference sum: " << sum_sht_int; - cout << endl << " Derived sum: " << tot_int << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableShortCol::integer()"; + std::cout << std::endl << " Reference sum: " << sum_sht_int; + std::cout << std::endl << " Derived sum: " << tot_int << std::endl; throw; } - cout << "."; + std::cout << "."; // Check single precision table (string access) tot_str.clear(); for (int i = 0; i < nrows; ++i) tot_str += ":"+col_sht->string(i); if (tot_str != sum_sht_str) { - cout << endl << "TEST ERROR: GFitsTableShtCol::string()"; - cout << endl << " Reference sum: " << sum_sht_str; - cout << endl << " Derived sum: " << tot_str << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableShortCol::string()"; + std::cout << std::endl << " Reference sum: " << sum_sht_str; + std::cout << std::endl << " Derived sum: " << tot_str << std::endl; throw; } - cout << "."; + std::cout << "."; // // ===== S H O R T 1 0 ===== // // Get column - GFitsTableShtCol* col_sht10 = - (GFitsTableShtCol*)fits.hdu(1)->column("SHORT10"); + GFitsTableShortCol* col_sht10 = + (GFitsTableShortCol*)fits.hdu(1)->column("SHORT10"); // Check short table (operator access) tot_sht = 0; @@ -1264,12 +1284,12 @@ void test_bintable_short(void) tot_sht += (*col_sht10)(i,j); } if (tot_sht != sum_sht10) { - cout << endl << "TEST ERROR: GFitsTableShtCol::operator() - 10"; - cout << endl << " Reference sum: " << sum_sht10; - cout << endl << " Derived sum: " << tot_sht << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableShortCol::operator() - 10"; + std::cout << std::endl << " Reference sum: " << sum_sht10; + std::cout << std::endl << " Derived sum: " << tot_sht << std::endl; throw; } - cout << "."; + std::cout << "."; // Check short table (real access) tot_dbl = 0.0; @@ -1278,12 +1298,12 @@ void test_bintable_short(void) tot_dbl += col_sht10->real(i,j); } if (!dequal(tot_dbl, sum_sht10)) { - cout << endl << "TEST ERROR: GFitsTableShtCol::real() - 10"; - cout << endl << " Reference sum: " << sum_sht10; - cout << endl << " Derived sum: " << tot_dbl << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableShortCol::real() - 10"; + std::cout << std::endl << " Reference sum: " << sum_sht10; + std::cout << std::endl << " Derived sum: " << tot_dbl << std::endl; throw; } - cout << "."; + std::cout << "."; // Check short table (int access) tot_int = 0; @@ -1292,12 +1312,12 @@ void test_bintable_short(void) tot_int += col_sht10->integer(i,j); } if (tot_int != sum_sht10_int) { - cout << endl << "TEST ERROR: GFitsTableShtCol::integer() - 10"; - cout << endl << " Reference sum: " << sum_sht10_int; - cout << endl << " Derived sum: " << tot_int << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableShortCol::integer() - 10"; + std::cout << std::endl << " Reference sum: " << sum_sht10_int; + std::cout << std::endl << " Derived sum: " << tot_int << std::endl; throw; } - cout << "."; + std::cout << "."; // Check single precision table (string access) tot_str.clear(); @@ -1306,19 +1326,19 @@ void test_bintable_short(void) tot_str += ":"+col_sht10->string(i,j); } if (tot_str != sum_sht10_str) { - cout << endl << "TEST ERROR: GFitsTableShtCol::string() - 10"; - cout << endl << " Reference sum: " << sum_sht10_str; - cout << endl << " Derived sum: " << tot_str << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableShortCol::string() - 10"; + std::cout << std::endl << " Reference sum: " << sum_sht10_str; + std::cout << std::endl << " Derived sum: " << tot_str << std::endl; throw; } - cout << "."; + std::cout << "."; } - catch (exception &e) { - cout << endl << "TEST ERROR: Unable to build tables." << endl; - cout << e.what() << endl; + catch (std::exception &e) { + std::cout << std::endl << "TEST ERROR: Unable to build tables." << std::endl; + std::cout << e.what() << std::endl; throw; } - cout << ". ok." << endl; + std::cout << ". ok." << std::endl; } @@ -1332,7 +1352,7 @@ void test_bintable_long(void) std::string filename = "test_bintable_long.fits"; // Dump header - cout << "Test GFitsTableLngCol: "; + std::cout << "Test GFitsTableLongCol: "; // Remove FITS file std::string cmd = "rm -rf "+ filename; @@ -1369,72 +1389,72 @@ void test_bintable_long(void) // // Set long table - GFitsTableLngCol col_lng = GFitsTableLngCol("LONG", nrows); + GFitsTableLongCol col_lng = GFitsTableLongCol("LONG", nrows); for (int i = 0; i < nrows; ++i) { long val_lng = long(100000.0 * cos(0.1*float(i))); col_lng(i) = val_lng; sum_lng += val_lng; sum_lng_int += int(val_lng); - ostringstream s_value; + std::ostringstream s_value; s_value << val_lng; sum_lng_str += ":"+s_value.str(); } - cout << "."; + std::cout << "."; // Check long table (operator access) tot_lng = 0; for (int i = 0; i < nrows; ++i) tot_lng += col_lng(i); if (tot_lng != sum_lng) { - cout << endl << "TEST ERROR: GFitsTableLngCol::operator()"; - cout << endl << " Reference sum: " << sum_lng; - cout << endl << " Derived sum: " << tot_lng << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableLongCol::operator()"; + std::cout << std::endl << " Reference sum: " << sum_lng; + std::cout << std::endl << " Derived sum: " << tot_lng << std::endl; throw; } - cout << "."; + std::cout << "."; // Check long table (real access) tot_dbl = 0.0; for (int i = 0; i < nrows; ++i) tot_dbl += col_lng.real(i); if (!dequal(tot_dbl, double(sum_lng))) { - cout << endl << "TEST ERROR: GFitsTableLngCol::real()"; - cout << endl << " Reference sum: " << sum_lng; - cout << endl << " Derived sum: " << tot_dbl << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableLongCol::real()"; + std::cout << std::endl << " Reference sum: " << sum_lng; + std::cout << std::endl << " Derived sum: " << tot_dbl << std::endl; throw; } - cout << "."; + std::cout << "."; // Check long table (int access) tot_int = 0; for (int i = 0; i < nrows; ++i) tot_int += col_lng.integer(i); if (tot_int != sum_lng_int) { - cout << endl << "TEST ERROR: GFitsTableLngCol::integer()"; - cout << endl << " Reference sum: " << sum_lng_int; - cout << endl << " Derived sum: " << tot_int << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableLongCol::integer()"; + std::cout << std::endl << " Reference sum: " << sum_lng_int; + std::cout << std::endl << " Derived sum: " << tot_int << std::endl; throw; } - cout << "."; + std::cout << "."; // Check long table (string access) tot_str.clear(); for (int i = 0; i < nrows; ++i) tot_str += ":"+col_lng.string(i); if (tot_str != sum_lng_str) { - cout << endl << "TEST ERROR: GFitsTableLngCol::string()"; - cout << endl << " Reference sum: " << sum_lng_str; - cout << endl << " Derived sum: " << tot_str << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableLongCol::string()"; + std::cout << std::endl << " Reference sum: " << sum_lng_str; + std::cout << std::endl << " Derived sum: " << tot_str << std::endl; throw; } - cout << "."; + std::cout << "."; // // ===== L O N G 1 0 ===== // // Set long table - GFitsTableLngCol col_lng10 = GFitsTableLngCol("LONG10", nrows, nvec); + GFitsTableLongCol col_lng10 = GFitsTableLongCol("LONG10", nrows, nvec); for (int i = 0; i < nrows; ++i) { for (int j = 0; j < nvec; ++j) { long val_lng = long(1000.0*cos(0.1*float(i))* @@ -1442,12 +1462,12 @@ void test_bintable_long(void) col_lng10(i,j) = val_lng; sum_lng10 += val_lng; sum_lng10_int += int(val_lng); - ostringstream s_value; + std::ostringstream s_value; s_value << val_lng; sum_lng10_str += ":"+s_value.str(); } } - cout << "."; + std::cout << "."; // Check long table (operator access) tot_lng = 0; @@ -1456,12 +1476,12 @@ void test_bintable_long(void) tot_lng += col_lng10(i,j); } if (tot_lng != sum_lng10) { - cout << endl << "TEST ERROR: GFitsTableLngCol::operator() - 10"; - cout << endl << " Reference sum: " << sum_lng10; - cout << endl << " Derived sum: " << tot_lng << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableLongCol::operator() - 10"; + std::cout << std::endl << " Reference sum: " << sum_lng10; + std::cout << std::endl << " Derived sum: " << tot_lng << std::endl; throw; } - cout << "."; + std::cout << "."; // Check long table (real access) tot_dbl = 0.0; @@ -1470,12 +1490,12 @@ void test_bintable_long(void) tot_dbl += col_lng10.real(i,j); } if (!dequal(tot_dbl, sum_lng10)) { - cout << endl << "TEST ERROR: GFitsTableLngCol::real() - 10"; - cout << endl << " Reference sum: " << sum_lng10; - cout << endl << " Derived sum: " << tot_dbl << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableLongCol::real() - 10"; + std::cout << std::endl << " Reference sum: " << sum_lng10; + std::cout << std::endl << " Derived sum: " << tot_dbl << std::endl; throw; } - cout << "."; + std::cout << "."; // Check long table (int access) tot_int = 0; @@ -1484,12 +1504,12 @@ void test_bintable_long(void) tot_int += col_lng10.integer(i,j); } if (tot_int != sum_lng10_int) { - cout << endl << "TEST ERROR: GFitsTableLngCol::integer() - 10"; - cout << endl << " Reference sum: " << sum_lng10_int; - cout << endl << " Derived sum: " << tot_int << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableLongCol::integer() - 10"; + std::cout << std::endl << " Reference sum: " << sum_lng10_int; + std::cout << std::endl << " Derived sum: " << tot_int << std::endl; throw; } - cout << "."; + std::cout << "."; // Check single precision table (string access) tot_str.clear(); @@ -1498,12 +1518,12 @@ void test_bintable_long(void) tot_str += ":"+col_lng10.string(i,j); } if (tot_str != sum_lng10_str) { - cout << endl << "TEST ERROR: GFitsTableLngCol::string() - 10"; - cout << endl << " Reference sum: " << sum_lng10_str; - cout << endl << " Derived sum: " << tot_str << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableLongCol::string() - 10"; + std::cout << std::endl << " Reference sum: " << sum_lng10_str; + std::cout << std::endl << " Derived sum: " << tot_str << std::endl; throw; } - cout << "."; + std::cout << "."; // // ===== W R I T E T A B L E ===== @@ -1520,14 +1540,14 @@ void test_bintable_long(void) // Save FITS file fits.save(); - cout << "."; + std::cout << "."; } - catch (exception &e) { - cout << endl << "TEST ERROR: Unable to build tables." << endl; - cout << e.what() << endl; + catch (std::exception &e) { + std::cout << std::endl << "TEST ERROR: Unable to build tables." << std::endl; + std::cout << e.what() << std::endl; throw; } - cout << "."; + std::cout << "."; //================================================================ @@ -1558,64 +1578,64 @@ void test_bintable_long(void) // // Get column - GFitsTableLngCol* col_lng = - (GFitsTableLngCol*)fits.hdu(1)->column("LONG"); + GFitsTableLongCol* col_lng = + (GFitsTableLongCol*)fits.hdu(1)->column("LONG"); // Check long table (operator access) tot_lng = 0; for (int i = 0; i < nrows; ++i) tot_lng += (*col_lng)(i); if (tot_lng != sum_lng) { - cout << endl << "TEST ERROR: GFitsTableLngCol::operator()"; - cout << endl << " Reference sum: " << sum_lng; - cout << endl << " Derived sum: " << tot_lng << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableLongCol::operator()"; + std::cout << std::endl << " Reference sum: " << sum_lng; + std::cout << std::endl << " Derived sum: " << tot_lng << std::endl; throw; } - cout << "."; + std::cout << "."; // Check long table (real access) tot_dbl = 0.0; for (int i = 0; i < nrows; ++i) tot_dbl += col_lng->real(i); if (!dequal(tot_dbl, double(sum_lng))) { - cout << endl << "TEST ERROR: GFitsTableLngCol::real()"; - cout << endl << " Reference sum: " << sum_lng; - cout << endl << " Derived sum: " << tot_dbl << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableLongCol::real()"; + std::cout << std::endl << " Reference sum: " << sum_lng; + std::cout << std::endl << " Derived sum: " << tot_dbl << std::endl; throw; } - cout << "."; + std::cout << "."; // Check long table (int access) tot_int = 0; for (int i = 0; i < nrows; ++i) tot_int += col_lng->integer(i); if (tot_int != sum_lng_int) { - cout << endl << "TEST ERROR: GFitsTableLngCol::integer()"; - cout << endl << " Reference sum: " << sum_lng_int; - cout << endl << " Derived sum: " << tot_int << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableLongCol::integer()"; + std::cout << std::endl << " Reference sum: " << sum_lng_int; + std::cout << std::endl << " Derived sum: " << tot_int << std::endl; throw; } - cout << "."; + std::cout << "."; // Check long table (string access) tot_str.clear(); for (int i = 0; i < nrows; ++i) tot_str += ":"+col_lng->string(i); if (tot_str != sum_lng_str) { - cout << endl << "TEST ERROR: GFitsTableLngCol::string()"; - cout << endl << " Reference sum: " << sum_lng_str; - cout << endl << " Derived sum: " << tot_str << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableLongCol::string()"; + std::cout << std::endl << " Reference sum: " << sum_lng_str; + std::cout << std::endl << " Derived sum: " << tot_str << std::endl; throw; } - cout << "."; + std::cout << "."; // // ===== L O N G 1 0 ===== // // Get column - GFitsTableLngCol* col_lng10 = - (GFitsTableLngCol*)fits.hdu(1)->column("LONG10"); + GFitsTableLongCol* col_lng10 = + (GFitsTableLongCol*)fits.hdu(1)->column("LONG10"); // Check long table (operator access) tot_lng = 0; @@ -1624,12 +1644,12 @@ void test_bintable_long(void) tot_lng += (*col_lng10)(i,j); } if (tot_lng != sum_lng10) { - cout << endl << "TEST ERROR: GFitsTableLngCol::operator() - 10"; - cout << endl << " Reference sum: " << sum_lng10; - cout << endl << " Derived sum: " << tot_lng << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableLongCol::operator() - 10"; + std::cout << std::endl << " Reference sum: " << sum_lng10; + std::cout << std::endl << " Derived sum: " << tot_lng << std::endl; throw; } - cout << "."; + std::cout << "."; // Check long table (real access) tot_dbl = 0.0; @@ -1638,12 +1658,12 @@ void test_bintable_long(void) tot_dbl += col_lng10->real(i,j); } if (!dequal(tot_dbl, sum_lng10)) { - cout << endl << "TEST ERROR: GFitsTableLngCol::real() - 10"; - cout << endl << " Reference sum: " << sum_lng10; - cout << endl << " Derived sum: " << tot_dbl << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableLongCol::real() - 10"; + std::cout << std::endl << " Reference sum: " << sum_lng10; + std::cout << std::endl << " Derived sum: " << tot_dbl << std::endl; throw; } - cout << "."; + std::cout << "."; // Check long table (int access) tot_int = 0; @@ -1652,12 +1672,12 @@ void test_bintable_long(void) tot_int += col_lng10->integer(i,j); } if (tot_int != sum_lng10_int) { - cout << endl << "TEST ERROR: GFitsTableLngCol::integer() - 10"; - cout << endl << " Reference sum: " << sum_lng10_int; - cout << endl << " Derived sum: " << tot_int << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableLongCol::integer() - 10"; + std::cout << std::endl << " Reference sum: " << sum_lng10_int; + std::cout << std::endl << " Derived sum: " << tot_int << std::endl; throw; } - cout << "."; + std::cout << "."; // Check single precision table (string access) tot_str.clear(); @@ -1666,19 +1686,19 @@ void test_bintable_long(void) tot_str += ":"+col_lng10->string(i,j); } if (tot_str != sum_lng10_str) { - cout << endl << "TEST ERROR: GFitsTableLngCol::string() - 10"; - cout << endl << " Reference sum: " << sum_lng10_str; - cout << endl << " Derived sum: " << tot_str << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableLongCol::string() - 10"; + std::cout << std::endl << " Reference sum: " << sum_lng10_str; + std::cout << std::endl << " Derived sum: " << tot_str << std::endl; throw; } - cout << "."; + std::cout << "."; } - catch (exception &e) { - cout << endl << "TEST ERROR: Unable to build tables." << endl; - cout << e.what() << endl; + catch (std::exception &e) { + std::cout << std::endl << "TEST ERROR: Unable to build tables." << std::endl; + std::cout << e.what() << std::endl; throw; } - cout << ". ok." << endl; + std::cout << ". ok." << std::endl; } @@ -1692,7 +1712,7 @@ void test_bintable_string(void) std::string filename = "test_bintable_string.fits"; // Dump header - cout << "Test GFitsTableStrCol: "; + std::cout << "Test GFitsTableStringCol: "; // Remove FITS file std::string cmd = "rm -rf "+ filename; @@ -1729,84 +1749,84 @@ void test_bintable_string(void) // // Set string table - GFitsTableStrCol col_str = GFitsTableStrCol("STRING", nrows, 20); + GFitsTableStringCol col_str = GFitsTableStringCol("STRING", nrows, 20); for (int i = 0; i < nrows; ++i) { double val_dbl = 100.0 * cos(0.1*double(i)); - ostringstream s_value; - s_value << scientific << val_dbl; + std::ostringstream s_value; + s_value << std::scientific << val_dbl; col_str(i) = s_value.str(); sum_str += ":" + s_value.str(); sum_str_dbl += val_dbl; sum_str_int += int(val_dbl); } - cout << "."; + std::cout << "."; // Check string table (operator access) tot_str.clear(); for (int i = 0; i < nrows; ++i) tot_str += ":" + col_str(i); if (tot_str != sum_str) { - cout << endl << "TEST ERROR: GFitsTableStrCol::operator()"; - cout << endl << " Reference sum: " << sum_str; - cout << endl << " Derived sum: " << tot_str << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableStringCol::operator()"; + std::cout << std::endl << " Reference sum: " << sum_str; + std::cout << std::endl << " Derived sum: " << tot_str << std::endl; throw; } - cout << "."; + std::cout << "."; // Check string table (real access) tot_dbl = 0.0; for (int i = 0; i < nrows; ++i) tot_dbl += col_str.real(i); if (!equal(tot_dbl, sum_str_dbl, 1.0e-4)) { - cout << endl << "TEST ERROR: GFitsTableStrCol::real()"; - cout << endl << " Reference sum: " << sum_str_dbl; - cout << endl << " Derived sum: " << tot_dbl << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableStringCol::real()"; + std::cout << std::endl << " Reference sum: " << sum_str_dbl; + std::cout << std::endl << " Derived sum: " << tot_dbl << std::endl; throw; } - cout << "."; + std::cout << "."; // Check string table (int access) tot_int = 0; for (int i = 0; i < nrows; ++i) tot_int += col_str.integer(i); if (tot_int != sum_str_int) { - cout << endl << "TEST ERROR: GFitsTableStrCol::integer()"; - cout << endl << " Reference sum: " << sum_str_int; - cout << endl << " Derived sum: " << tot_int << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableStringCol::integer()"; + std::cout << std::endl << " Reference sum: " << sum_str_int; + std::cout << std::endl << " Derived sum: " << tot_int << std::endl; throw; } - cout << "."; + std::cout << "."; // Check string table (string access) tot_str.clear(); for (int i = 0; i < nrows; ++i) tot_str += ":"+col_str.string(i); if (tot_str != sum_str) { - cout << endl << "TEST ERROR: GFitsTableStrCol::string()"; - cout << endl << " Reference sum: " << sum_str; - cout << endl << " Derived sum: " << tot_str << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableStringCol::string()"; + std::cout << std::endl << " Reference sum: " << sum_str; + std::cout << std::endl << " Derived sum: " << tot_str << std::endl; throw; } - cout << "."; + std::cout << "."; // // ===== S T R I N G 1 0 ===== // // Set string table - GFitsTableStrCol col_str10 = GFitsTableStrCol("STRING10", nrows, 20, nvec); + GFitsTableStringCol col_str10 = GFitsTableStringCol("STRING10", nrows, 20, nvec); for (int i = 0; i < nrows; ++i) { for (int j = 0; j < nvec; ++j) { double val_dbl = 100.0 * cos(0.1*double(i)) * cos(0.3*double(j)); - ostringstream s_value; - s_value << scientific << val_dbl; + std::ostringstream s_value; + s_value << std::scientific << val_dbl; col_str10(i,j) = s_value.str(); sum_str10 += ":" + s_value.str(); sum_str10_dbl += val_dbl; sum_str10_int += int(val_dbl); } } - cout << "."; + std::cout << "."; // Check string table (operator access) tot_str.clear(); @@ -1815,12 +1835,12 @@ void test_bintable_string(void) tot_str += ":" + col_str10(i,j); } if (tot_str != sum_str10) { - cout << endl << "TEST ERROR: GFitsTableStrCol::operator() - 10"; - cout << endl << " Reference sum: " << sum_str10; - cout << endl << " Derived sum: " << tot_str << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableStringCol::operator() - 10"; + std::cout << std::endl << " Reference sum: " << sum_str10; + std::cout << std::endl << " Derived sum: " << tot_str << std::endl; throw; } - cout << "."; + std::cout << "."; // Check string table (real access) tot_dbl = 0.0; @@ -1829,12 +1849,12 @@ void test_bintable_string(void) tot_dbl += col_str10.real(i,j); } if (!equal(tot_dbl, sum_str10_dbl, 1.0e-4)) { - cout << endl << "TEST ERROR: GFitsTableStrCol::real() - 10"; - cout << endl << " Reference sum: " << sum_str10_dbl; - cout << endl << " Derived sum: " << tot_dbl << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableStringCol::real() - 10"; + std::cout << std::endl << " Reference sum: " << sum_str10_dbl; + std::cout << std::endl << " Derived sum: " << tot_dbl << std::endl; throw; } - cout << "."; + std::cout << "."; // Check string table (int access) tot_int = 0; @@ -1843,12 +1863,12 @@ void test_bintable_string(void) tot_int += col_str10.integer(i,j); } if (tot_int != sum_str10_int) { - cout << endl << "TEST ERROR: GFitsTableStrCol::integer() - 10"; - cout << endl << " Reference sum: " << sum_str10_int; - cout << endl << " Derived sum: " << tot_int << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableStringCol::integer() - 10"; + std::cout << std::endl << " Reference sum: " << sum_str10_int; + std::cout << std::endl << " Derived sum: " << tot_int << std::endl; throw; } - cout << "."; + std::cout << "."; // Check string table (string access) tot_str.clear(); @@ -1857,12 +1877,12 @@ void test_bintable_string(void) tot_str += ":"+col_str10.string(i,j); } if (tot_str != sum_str10) { - cout << endl << "TEST ERROR: GFitsTableStrCol::string() - 10"; - cout << endl << " Reference sum: " << sum_str10; - cout << endl << " Derived sum: " << tot_str << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableStringCol::string() - 10"; + std::cout << std::endl << " Reference sum: " << sum_str10; + std::cout << std::endl << " Derived sum: " << tot_str << std::endl; throw; } - cout << "."; + std::cout << "."; // // ===== W R I T E T A B L E ===== @@ -1879,14 +1899,14 @@ void test_bintable_string(void) // Save FITS file fits.save(); - cout << "."; + std::cout << "."; } - catch (exception &e) { - cout << endl << "TEST ERROR: Unable to build tables." << endl; - cout << e.what() << endl; + catch (std::exception &e) { + std::cout << std::endl << "TEST ERROR: Unable to build tables." << std::endl; + std::cout << e.what() << std::endl; throw; } - cout << "."; + std::cout << "."; //================================================================ @@ -1916,64 +1936,64 @@ void test_bintable_string(void) // // Get column - GFitsTableStrCol* col_str = - (GFitsTableStrCol*)fits.hdu(1)->column("STRING"); + GFitsTableStringCol* col_str = + (GFitsTableStringCol*)fits.hdu(1)->column("STRING"); // Check string table (operator access) tot_str.clear(); for (int i = 0; i < nrows; ++i) tot_str += ":" + (*col_str)(i); if (tot_str != sum_str) { - cout << endl << "TEST ERROR: GFitsTableStrCol::operator()"; - cout << endl << " Reference sum: " << sum_str; - cout << endl << " Derived sum: " << tot_str << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableStringCol::operator()"; + std::cout << std::endl << " Reference sum: " << sum_str; + std::cout << std::endl << " Derived sum: " << tot_str << std::endl; throw; } - cout << "."; + std::cout << "."; // Check string table (real access) tot_dbl = 0.0; for (int i = 0; i < nrows; ++i) tot_dbl += col_str->real(i); if (!equal(tot_dbl, sum_str_dbl, 1.0e-4)) { - cout << endl << "TEST ERROR: GFitsTableStrCol::real()"; - cout << endl << " Reference sum: " << sum_str_dbl; - cout << endl << " Derived sum: " << tot_dbl << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableStringCol::real()"; + std::cout << std::endl << " Reference sum: " << sum_str_dbl; + std::cout << std::endl << " Derived sum: " << tot_dbl << std::endl; throw; } - cout << "."; + std::cout << "."; // Check string table (int access) tot_int = 0; for (int i = 0; i < nrows; ++i) tot_int += col_str->integer(i); if (tot_int != sum_str_int) { - cout << endl << "TEST ERROR: GFitsTableStrCol::integer()"; - cout << endl << " Reference sum: " << sum_str_int; - cout << endl << " Derived sum: " << tot_int << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableStringCol::integer()"; + std::cout << std::endl << " Reference sum: " << sum_str_int; + std::cout << std::endl << " Derived sum: " << tot_int << std::endl; throw; } - cout << "."; + std::cout << "."; // Check string table (string access) tot_str.clear(); for (int i = 0; i < nrows; ++i) tot_str += ":"+col_str->string(i); if (tot_str != sum_str) { - cout << endl << "TEST ERROR: GFitsTableStrCol::string()"; - cout << endl << " Reference sum: " << sum_str; - cout << endl << " Derived sum: " << tot_str << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableStringCol::string()"; + std::cout << std::endl << " Reference sum: " << sum_str; + std::cout << std::endl << " Derived sum: " << tot_str << std::endl; throw; } - cout << "."; + std::cout << "."; // // ===== S T R I N G 1 0 ===== // // Get column - GFitsTableStrCol* col_str10 = - (GFitsTableStrCol*)fits.hdu(1)->column("STRING10"); + GFitsTableStringCol* col_str10 = + (GFitsTableStringCol*)fits.hdu(1)->column("STRING10"); // Check string table (operator access) tot_str.clear(); @@ -1982,12 +2002,12 @@ void test_bintable_string(void) tot_str += ":" + (*col_str10)(i,j); } if (tot_str != sum_str10) { - cout << endl << "TEST ERROR: GFitsTableStrCol::operator() - 10"; - cout << endl << " Reference sum: " << sum_str10; - cout << endl << " Derived sum: " << tot_str << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableStringCol::operator() - 10"; + std::cout << std::endl << " Reference sum: " << sum_str10; + std::cout << std::endl << " Derived sum: " << tot_str << std::endl; throw; } - cout << "."; + std::cout << "."; // Check string table (real access) tot_dbl = 0.0; @@ -1996,12 +2016,12 @@ void test_bintable_string(void) tot_dbl += col_str10->real(i,j); } if (!equal(tot_dbl, sum_str10_dbl, 1.0e-4)) { - cout << endl << "TEST ERROR: GFitsTableStrCol::real() - 10"; - cout << endl << " Reference sum: " << sum_str10_dbl; - cout << endl << " Derived sum: " << tot_dbl << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableStringCol::real() - 10"; + std::cout << std::endl << " Reference sum: " << sum_str10_dbl; + std::cout << std::endl << " Derived sum: " << tot_dbl << std::endl; throw; } - cout << "."; + std::cout << "."; // Check string table (int access) tot_int = 0; @@ -2010,12 +2030,12 @@ void test_bintable_string(void) tot_int += col_str10->integer(i,j); } if (tot_int != sum_str10_int) { - cout << endl << "TEST ERROR: GFitsTableStrCol::integer() - 10"; - cout << endl << " Reference sum: " << sum_str10_int; - cout << endl << " Derived sum: " << tot_int << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableStringCol::integer() - 10"; + std::cout << std::endl << " Reference sum: " << sum_str10_int; + std::cout << std::endl << " Derived sum: " << tot_int << std::endl; throw; } - cout << "."; + std::cout << "."; // Check string table (string access) tot_str.clear(); @@ -2024,20 +2044,20 @@ void test_bintable_string(void) tot_str += ":"+col_str10->string(i,j); } if (tot_str != sum_str10) { - cout << endl << "TEST ERROR: GFitsTableStrCol::string() - 10"; - cout << endl << " Reference sum: " << sum_str10; - cout << endl << " Derived sum: " << tot_str << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableStringCol::string() - 10"; + std::cout << std::endl << " Reference sum: " << sum_str10; + std::cout << std::endl << " Derived sum: " << tot_str << std::endl; throw; } - cout << "."; + std::cout << "."; } - catch (exception &e) { - cout << endl << "TEST ERROR: Unable to read tables." << endl; - cout << e.what() << endl; + catch (std::exception &e) { + std::cout << std::endl << "TEST ERROR: Unable to read tables." << std::endl; + std::cout << e.what() << std::endl; throw; } - cout << ". ok." << endl; + std::cout << ". ok." << std::endl; } @@ -2051,7 +2071,7 @@ void test_bintable_logical(void) std::string filename = "test_bintable_logical.fits"; // Dump header - cout << "Test GFitsTableLogCol: "; + std::cout << "Test GFitsTableBoolCol: "; // Remove FITS file std::string cmd = "rm -rf "+ filename; @@ -2087,9 +2107,9 @@ void test_bintable_logical(void) // // Set table - GFitsTableLogCol col = GFitsTableLogCol("LOGICAL", nrows); + GFitsTableBoolCol col = GFitsTableBoolCol("LOGICAL", nrows); for (int i = 0; i < nrows; ++i) { - char val = (i % 2) ? 1 : 0; + bool val = (i % 2) ? true : false; col(i) = val; sum += val; sum_int += int(val); @@ -2098,62 +2118,62 @@ void test_bintable_logical(void) else sum_str += ":F"; } - cout << "."; + std::cout << "."; // Check table (operator access) tot_int = 0; for (int i = 0; i < nrows; ++i) tot_int += col(i); if (tot_int != sum) { - cout << endl << "TEST ERROR: GFitsTableLogCol::operator()"; - cout << endl << " Reference sum: " << sum; - cout << endl << " Derived sum: " << tot_int << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableBoolCol::operator()"; + std::cout << std::endl << " Reference sum: " << sum; + std::cout << std::endl << " Derived sum: " << tot_int << std::endl; throw; } - cout << "."; + std::cout << "."; // Check table (real access) tot_dbl = 0.0; for (int i = 0; i < nrows; ++i) tot_dbl += col.real(i); if (!dequal(tot_dbl, double(sum))) { - cout << endl << "TEST ERROR: GFitsTableLogCol::real()"; - cout << endl << " Reference sum: " << sum; - cout << endl << " Derived sum: " << tot_dbl << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableBoolCol::real()"; + std::cout << std::endl << " Reference sum: " << sum; + std::cout << std::endl << " Derived sum: " << tot_dbl << std::endl; throw; } - cout << "."; + std::cout << "."; // Check table (int access) tot_int = 0; for (int i = 0; i < nrows; ++i) tot_int += col.integer(i); if (tot_int != sum_int) { - cout << endl << "TEST ERROR: GFitsTableLogCol::integer()"; - cout << endl << " Reference sum: " << sum_int; - cout << endl << " Derived sum: " << tot_int << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableBoolCol::integer()"; + std::cout << std::endl << " Reference sum: " << sum_int; + std::cout << std::endl << " Derived sum: " << tot_int << std::endl; throw; } - cout << "."; + std::cout << "."; // Check table (string access) tot_str.clear(); for (int i = 0; i < nrows; ++i) tot_str += ":"+col.string(i); if (tot_str != sum_str) { - cout << endl << "TEST ERROR: GFitsTableLogCol::string()"; - cout << endl << " Reference sum: " << sum_str; - cout << endl << " Derived sum: " << tot_str << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableBoolCol::string()"; + std::cout << std::endl << " Reference sum: " << sum_str; + std::cout << std::endl << " Derived sum: " << tot_str << std::endl; throw; } - cout << "."; + std::cout << "."; // // ===== L O G I C A L 1 0 ===== // // Set table - GFitsTableLogCol col10 = GFitsTableLogCol("LOGICAL10", nrows, nvec); + GFitsTableBoolCol col10 = GFitsTableBoolCol("LOGICAL10", nrows, nvec); for (int i = 0; i < nrows; ++i) { for (int j = 0; j < nvec; ++j) { char val = (i % 2) * (j % 2); @@ -2166,7 +2186,7 @@ void test_bintable_logical(void) sum10_str += ":F"; } } - cout << "."; + std::cout << "."; // Check table (operator access) tot_int = 0; @@ -2175,12 +2195,12 @@ void test_bintable_logical(void) tot_int += col10(i,j); } if (tot_int != sum10) { - cout << endl << "TEST ERROR: GFitsTableLogCol::operator() - 10"; - cout << endl << " Reference sum: " << sum10; - cout << endl << " Derived sum: " << tot_int << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableBoolCol::operator() - 10"; + std::cout << std::endl << " Reference sum: " << sum10; + std::cout << std::endl << " Derived sum: " << tot_int << std::endl; throw; } - cout << "."; + std::cout << "."; // Check table (real access) tot_dbl = 0.0; @@ -2189,12 +2209,12 @@ void test_bintable_logical(void) tot_dbl += col10.real(i,j); } if (!dequal(tot_dbl, sum10)) { - cout << endl << "TEST ERROR: GFitsTableLogCol::real() - 10"; - cout << endl << " Reference sum: " << sum10; - cout << endl << " Derived sum: " << tot_dbl << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableBoolCol::real() - 10"; + std::cout << std::endl << " Reference sum: " << sum10; + std::cout << std::endl << " Derived sum: " << tot_dbl << std::endl; throw; } - cout << "."; + std::cout << "."; // Check table (int access) tot_int = 0; @@ -2203,12 +2223,12 @@ void test_bintable_logical(void) tot_int += col10.integer(i,j); } if (tot_int != sum10_int) { - cout << endl << "TEST ERROR: GFitsTableLogCol::integer() - 10"; - cout << endl << " Reference sum: " << sum10_int; - cout << endl << " Derived sum: " << tot_int << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableBoolCol::integer() - 10"; + std::cout << std::endl << " Reference sum: " << sum10_int; + std::cout << std::endl << " Derived sum: " << tot_int << std::endl; throw; } - cout << "."; + std::cout << "."; // Check table (string access) tot_str.clear(); @@ -2217,12 +2237,12 @@ void test_bintable_logical(void) tot_str += ":"+col10.string(i,j); } if (tot_str != sum10_str) { - cout << endl << "TEST ERROR: GFitsTableLogCol::string() - 10"; - cout << endl << " Reference sum: " << sum10_str; - cout << endl << " Derived sum: " << tot_str << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableBoolCol::string() - 10"; + std::cout << std::endl << " Reference sum: " << sum10_str; + std::cout << std::endl << " Derived sum: " << tot_str << std::endl; throw; } - cout << "."; + std::cout << "."; // // ===== W R I T E T A B L E ===== @@ -2239,15 +2259,15 @@ void test_bintable_logical(void) // Save FITS file fits.save(); - cout << "."; + std::cout << "."; } - catch (exception &e) { - cout << endl << "TEST ERROR: Unable to build tables." << endl; - cout << e.what() << endl; + catch (std::exception &e) { + std::cout << std::endl << "TEST ERROR: Unable to build tables." << std::endl; + std::cout << e.what() << std::endl; throw; } - cout << "."; + std::cout << "."; //================================================================ @@ -2278,64 +2298,64 @@ void test_bintable_logical(void) // // Get column - GFitsTableLogCol* col = - (GFitsTableLogCol*)fits.hdu(1)->column("LOGICAL"); + GFitsTableBoolCol* col = + (GFitsTableBoolCol*)fits.hdu(1)->column("LOGICAL"); // Check table (operator access) tot_int = 0; for (int i = 0; i < nrows; ++i) tot_int += (*col)(i); if (tot_int != sum) { - cout << endl << "TEST ERROR: GFitsTableLogCol::operator()"; - cout << endl << " Reference sum: " << sum; - cout << endl << " Derived sum: " << tot_int << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableBoolCol::operator()"; + std::cout << std::endl << " Reference sum: " << sum; + std::cout << std::endl << " Derived sum: " << tot_int << std::endl; throw; } - cout << "."; + std::cout << "."; // Check table (real access) tot_dbl = 0.0; for (int i = 0; i < nrows; ++i) tot_dbl += col->real(i); if (!dequal(tot_dbl, double(sum))) { - cout << endl << "TEST ERROR: GFitsTableLogCol::real()"; - cout << endl << " Reference sum: " << sum; - cout << endl << " Derived sum: " << tot_dbl << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableBoolCol::real()"; + std::cout << std::endl << " Reference sum: " << sum; + std::cout << std::endl << " Derived sum: " << tot_dbl << std::endl; throw; } - cout << "."; + std::cout << "."; // Check table (int access) tot_int = 0; for (int i = 0; i < nrows; ++i) tot_int += col->integer(i); if (tot_int != sum_int) { - cout << endl << "TEST ERROR: GFitsTableLogCol::integer()"; - cout << endl << " Reference sum: " << sum_int; - cout << endl << " Derived sum: " << tot_int << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableBoolCol::integer()"; + std::cout << std::endl << " Reference sum: " << sum_int; + std::cout << std::endl << " Derived sum: " << tot_int << std::endl; throw; } - cout << "."; + std::cout << "."; // Check single precision table (string access) tot_str.clear(); for (int i = 0; i < nrows; ++i) tot_str += ":"+col->string(i); if (tot_str != sum_str) { - cout << endl << "TEST ERROR: GFitsTableLogCol::string()"; - cout << endl << " Reference sum: " << sum_str; - cout << endl << " Derived sum: " << tot_str << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableBoolCol::string()"; + std::cout << std::endl << " Reference sum: " << sum_str; + std::cout << std::endl << " Derived sum: " << tot_str << std::endl; throw; } - cout << "."; + std::cout << "."; // // ===== L O G I C A L 1 0 ===== // // Get column - GFitsTableLogCol* col10 = - (GFitsTableLogCol*)fits.hdu(1)->column("LOGICAL10"); + GFitsTableBoolCol* col10 = + (GFitsTableBoolCol*)fits.hdu(1)->column("LOGICAL10"); // Check table (operator access) tot_int = 0; @@ -2344,12 +2364,12 @@ void test_bintable_logical(void) tot_int += (*col10)(i,j); } if (tot_int != sum10) { - cout << endl << "TEST ERROR: GFitsTableLogCol::operator() - 10"; - cout << endl << " Reference sum: " << sum10; - cout << endl << " Derived sum: " << tot_int << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableBoolCol::operator() - 10"; + std::cout << std::endl << " Reference sum: " << sum10; + std::cout << std::endl << " Derived sum: " << tot_int << std::endl; throw; } - cout << "."; + std::cout << "."; // Check table (real access) tot_dbl = 0.0; @@ -2358,12 +2378,12 @@ void test_bintable_logical(void) tot_dbl += col10->real(i,j); } if (!dequal(tot_dbl, sum10)) { - cout << endl << "TEST ERROR: GFitsTableLogCol::real() - 10"; - cout << endl << " Reference sum: " << sum10; - cout << endl << " Derived sum: " << tot_dbl << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableBoolCol::real() - 10"; + std::cout << std::endl << " Reference sum: " << sum10; + std::cout << std::endl << " Derived sum: " << tot_dbl << std::endl; throw; } - cout << "."; + std::cout << "."; // Check table (int access) tot_int = 0; @@ -2372,12 +2392,12 @@ void test_bintable_logical(void) tot_int += col10->integer(i,j); } if (tot_int != sum10_int) { - cout << endl << "TEST ERROR: GFitsTableLogCol::integer() - 10"; - cout << endl << " Reference sum: " << sum10_int; - cout << endl << " Derived sum: " << tot_int << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableBoolCol::integer() - 10"; + std::cout << std::endl << " Reference sum: " << sum10_int; + std::cout << std::endl << " Derived sum: " << tot_int << std::endl; throw; } - cout << "."; + std::cout << "."; // Check single precision table (string access) tot_str.clear(); @@ -2386,19 +2406,19 @@ void test_bintable_logical(void) tot_str += ":"+col10->string(i,j); } if (tot_str != sum10_str) { - cout << endl << "TEST ERROR: GFitsTableLogCol::string() - 10"; - cout << endl << " Reference sum: " << sum10_str; - cout << endl << " Derived sum: " << tot_str << endl; + std::cout << std::endl << "TEST ERROR: GFitsTableBoolCol::string() - 10"; + std::cout << std::endl << " Reference sum: " << sum10_str; + std::cout << std::endl << " Derived sum: " << tot_str << std::endl; throw; } - cout << "."; + std::cout << "."; } - catch (exception &e) { - cout << endl << "TEST ERROR: Unable to build tables." << endl; - cout << e.what() << endl; + catch (std::exception &e) { + std::cout << std::endl << "TEST ERROR: Unable to build tables." << std::endl; + std::cout << e.what() << std::endl; throw; } - cout << ". ok." << endl; + std::cout << ". ok." << std::endl; } -- libgit2 0.21.4