From d935e46e088e70b6ee2c99740e1da72e22dff25e Mon Sep 17 00:00:00 2001 From: knodlseder <> Date: Sat, 20 Nov 2010 21:24:38 +0000 Subject: [PATCH] initial version --- include/GFitsTableCDoubleCol.hpp | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/GFitsTableCFloatCol.hpp | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ pyext/GFitsTableByteCol.i | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ pyext/GFitsTableCDoubleCol.i | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ pyext/GFitsTableCFloatCol.i | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 364 insertions(+), 0 deletions(-) create mode 100644 include/GFitsTableCDoubleCol.hpp create mode 100644 include/GFitsTableCFloatCol.hpp create mode 100644 pyext/GFitsTableByteCol.i create mode 100644 pyext/GFitsTableCDoubleCol.i create mode 100644 pyext/GFitsTableCFloatCol.i diff --git a/include/GFitsTableCDoubleCol.hpp b/include/GFitsTableCDoubleCol.hpp new file mode 100644 index 0000000..cab68a1 --- /dev/null +++ b/include/GFitsTableCDoubleCol.hpp @@ -0,0 +1,78 @@ +/*************************************************************************** + * GFitsTableCDoubleCol.hpp - FITS table double precision complex column * + * ----------------------------------------------------------------------- * + * 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 GFitsTableCDoubleCol.hpp + * @brief GFitsTableCDoubleCol class definition. + * @author J. Knodlseder + */ + +#ifndef GFITSTABLECDOUBLECOL_HPP +#define GFITSTABLECDOUBLECOL_HPP + +/* __ Includes ___________________________________________________________ */ +#include +#include "GFits.hpp" +#include "GFitsTableCol.hpp" + + +/***********************************************************************//** + * @class GFitsTableCDoubleCol + * + * @brief Interface for FITS table float column + * + * This class implements a FITS table float column. + ***************************************************************************/ +class GFitsTableCDoubleCol : public GFitsTableCol { + +public: + // Constructors and destructors + GFitsTableCDoubleCol(void); + GFitsTableCDoubleCol(const std::string& name, const int& length, + const int& size = 1); + GFitsTableCDoubleCol(const GFitsTableCDoubleCol& column); + virtual ~GFitsTableCDoubleCol(void); + + // Operators + GFitsTableCDoubleCol& operator= (const GFitsTableCDoubleCol& column); + GFits::cdouble& operator() (const int& row, const int& inx = 0); + const GFits::cdouble& 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); + GFits::cdouble* data(void) { return m_data; } + void nulval(const GFits::cdouble* value); + GFits::cdouble* nulval(void) { return m_nulval; } + +private: + // Private methods + void init_members(void); + void copy_members(const GFitsTableCDoubleCol& column); + void free_members(void); + GFitsTableCDoubleCol* 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 GFits::cdouble* value); + void init_data(void); + void* ptr_data(void) { return m_data; } + void* ptr_nulval(void) { return m_nulval; } + + // Private data area + GFits::cdouble* m_data; //!< Data vector + GFits::cdouble* m_nulval; //!< NULL value +}; + +#endif /* GFITSTABLECDOUBLECOL_HPP */ diff --git a/include/GFitsTableCFloatCol.hpp b/include/GFitsTableCFloatCol.hpp new file mode 100644 index 0000000..976c5a4 --- /dev/null +++ b/include/GFitsTableCFloatCol.hpp @@ -0,0 +1,78 @@ +/*************************************************************************** + * GFitsTableCFloatCol.hpp - FITS table single precision complex column * + * ----------------------------------------------------------------------- * + * 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 GFitsTableCFloatCol.hpp + * @brief GFitsTableCFloatCol class definition. + * @author J. Knodlseder + */ + +#ifndef GFITSTABLECFLOATCOL_HPP +#define GFITSTABLECFLOATCOL_HPP + +/* __ Includes ___________________________________________________________ */ +#include +#include "GFits.hpp" +#include "GFitsTableCol.hpp" + + +/***********************************************************************//** + * @class GFitsTableCFloatCol + * + * @brief Interface for FITS table float column + * + * This class implements a FITS table float column. + ***************************************************************************/ +class GFitsTableCFloatCol : public GFitsTableCol { + +public: + // Constructors and destructors + GFitsTableCFloatCol(void); + GFitsTableCFloatCol(const std::string& name, const int& length, + const int& size = 1); + GFitsTableCFloatCol(const GFitsTableCFloatCol& column); + virtual ~GFitsTableCFloatCol(void); + + // Operators + GFitsTableCFloatCol& operator= (const GFitsTableCFloatCol& column); + GFits::cfloat& operator() (const int& row, const int& inx = 0); + const GFits::cfloat& 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); + GFits::cfloat* data(void) { return m_data; } + void nulval(const GFits::cfloat* value); + GFits::cfloat* nulval(void) { return m_nulval; } + +private: + // Private methods + void init_members(void); + void copy_members(const GFitsTableCFloatCol& column); + void free_members(void); + GFitsTableCFloatCol* 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 GFits::cfloat* value); + void init_data(void); + void* ptr_data(void) { return m_data; } + void* ptr_nulval(void) { return m_nulval; } + + // Private data area + GFits::cfloat* m_data; //!< Data vector + GFits::cfloat* m_nulval; //!< NULL value +}; + +#endif /* GFITSTABLECFLOATCOL_HPP */ diff --git a/pyext/GFitsTableByteCol.i b/pyext/GFitsTableByteCol.i new file mode 100644 index 0000000..8a6b1d9 --- /dev/null +++ b/pyext/GFitsTableByteCol.i @@ -0,0 +1,74 @@ +/*************************************************************************** + * GFitsTableByteCol.i - FITS table Byte 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 GFitsTableByteCol.i + * @brief GFitsTableByteCol class SWIG file. + * @author J. Knodlseder + */ +%{ +/* Put headers and other declarations here that are needed for compilation */ +#include "GFitsTableByteCol.hpp" +%} + + +/***********************************************************************//** + * @class GFitsTableByteCol + * + * @brief SWIG interface for FITS table short integer column + ***************************************************************************/ +class GFitsTableByteCol : public GFitsTableCol { +public: + // Constructors and destructors + GFitsTableByteCol(void); + GFitsTableByteCol(const std::string& name, const int& length, const int& size = 1); + GFitsTableByteCol(const GFitsTableByteCol& column); + virtual ~GFitsTableByteCol(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 char* data(void) { return m_data; } + void nulval(const unsigned char* value); + unsigned char* nulval(void) { return m_nulval; } +}; + + +/***********************************************************************//** + * @brief GFitsTableByteCol class extension + ***************************************************************************/ +%extend GFitsTableByteCol { + unsigned char __getitem__(int GFitsTableColInx[]) { + if (GFitsTableColInx[0] == 1) + return (*self)(GFitsTableColInx[1]); + else if (GFitsTableColInx[0] == 2) + return (*self)(GFitsTableColInx[1], GFitsTableColInx[2]); + else { + PyErr_SetString(PyExc_ValueError,"Too many arguments in tuple"); + return NULL; + } + } + void __setitem__(int GFitsTableColInx[], unsigned char value) { + if (GFitsTableColInx[0] == 1) + (*self)(GFitsTableColInx[1]) = value; + else if (GFitsTableColInx[0] == 2) + (*self)(GFitsTableColInx[1], GFitsTableColInx[2]) = value; + else { + PyErr_SetString(PyExc_ValueError,"Too many arguments in tuple"); + return; + } + } + GFitsTableByteCol copy() { + return (*self); + } +}; diff --git a/pyext/GFitsTableCDoubleCol.i b/pyext/GFitsTableCDoubleCol.i new file mode 100644 index 0000000..ad450f1 --- /dev/null +++ b/pyext/GFitsTableCDoubleCol.i @@ -0,0 +1,67 @@ +/*************************************************************************** + * GFitsTableCDoubleCol.i - FITS table double precision complex column * + * ----------------------------------------------------------------------- * + * 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 GFitsTableCDoubleCol.i + * @brief GFitsTableCDoubleCol class SWIG file. + * @author J. Knodlseder + */ +%{ +/* Put headers and other declarations here that are needed for compilation */ +#include "GFitsTableCDoubleCol.hpp" +%} + + +/***********************************************************************//** + * @class GFitsTableCDoubleCol + * + * @brief SWIG interface for FITS table floating point column + ***************************************************************************/ +class GFitsTableCDoubleCol : public GFitsTableCol { +public: + // Constructors and destructors + GFitsTableCDoubleCol(void); + GFitsTableCDoubleCol(const std::string& name, const int& length, + const int& size = 1); + GFitsTableCDoubleCol(const GFitsTableCDoubleCol& column); + virtual ~GFitsTableCDoubleCol(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); + GFits::cdouble* data(void) { return m_data; } + void nulval(const GFits::cdouble* value); + GFits::cdouble* nulval(void) { return m_nulval; } +}; + + +/***********************************************************************//** + * @brief GFitsTableCDoubleCol class extension + ***************************************************************************/ +%extend GFitsTableCDoubleCol { + GFits::cdouble get(const int& row) { + return (*self)(row); + } + GFits::cdouble get(const int& row, const int& col) { + return (*self)(row, col); + } + void set(const int& row, const GFits::cdouble& value) { + (*self)(row) = value; + } + void set(const int& row, const int& col, const GFits::cdouble& value) { + (*self)(row, col) = value; + } + GFitsTableCDoubleCol copy() { + return (*self); + } +}; diff --git a/pyext/GFitsTableCFloatCol.i b/pyext/GFitsTableCFloatCol.i new file mode 100644 index 0000000..6cbecb6 --- /dev/null +++ b/pyext/GFitsTableCFloatCol.i @@ -0,0 +1,67 @@ +/*************************************************************************** + * GFitsTableCFloatCol.i - FITS table single precision complex column * + * ----------------------------------------------------------------------- * + * 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 GFitsTableCFloatCol.i + * @brief GFitsTableCFloatCol class SWIG file. + * @author J. Knodlseder + */ +%{ +/* Put headers and other declarations here that are needed for compilation */ +#include "GFitsTableCFloatCol.hpp" +%} + + +/***********************************************************************//** + * @class GFitsTableCFloatCol + * + * @brief SWIG interface for FITS table floating point column + ***************************************************************************/ +class GFitsTableCFloatCol : public GFitsTableCol { +public: + // Constructors and destructors + GFitsTableCFloatCol(void); + GFitsTableCFloatCol(const std::string& name, const int& length, + const int& size = 1); + GFitsTableCFloatCol(const GFitsTableCFloatCol& column); + virtual ~GFitsTableCFloatCol(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); + GFits::cfloat* data(void) { return m_data; } + void nulval(const GFits::cfloat* value); + GFits::cfloat* nulval(void) { return m_nulval; } +}; + + +/***********************************************************************//** + * @brief GFitsTableCFloatCol class extension + ***************************************************************************/ +%extend GFitsTableCFloatCol { + GFits::cfloat get(const int& row) { + return (*self)(row); + } + GFits::cfloat get(const int& row, const int& col) { + return (*self)(row, col); + } + void set(const int& row, const GFits::cfloat& value) { + (*self)(row) = value; + } + void set(const int& row, const int& col, const GFits::cfloat& value) { + (*self)(row, col) = value; + } + GFitsTableCFloatCol copy() { + return (*self); + } +}; -- libgit2 0.21.4