From e8755e1cd0b5b6efb5d1c71dc761af2ea7f1967d Mon Sep 17 00:00:00 2001 From: knodlseder <> Date: Thu, 4 Aug 2011 21:46:35 +0000 Subject: [PATCH] add insert and remove methods --- include/GFitsTableBitCol.hpp | 34 +++++++++++++++++++++++----------- include/GFitsTableBoolCol.hpp | 42 +++++++++++++++++++++++++++--------------- include/GFitsTableByteCol.hpp | 37 +++++++++++++++++++++++++------------ include/GFitsTableCDoubleCol.hpp | 36 ++++++++++++++++++++++++------------ include/GFitsTableCFloatCol.hpp | 36 ++++++++++++++++++++++++------------ include/GFitsTableCol.hpp | 22 ++++++++++++++++------ include/GFitsTableDoubleCol.hpp | 40 ++++++++++++++++++++++++++-------------- include/GFitsTableFloatCol.hpp | 40 ++++++++++++++++++++++++++-------------- include/GFitsTableLongCol.hpp | 40 ++++++++++++++++++++++++++-------------- include/GFitsTableLongLongCol.hpp | 36 ++++++++++++++++++++++++------------ include/GFitsTableShortCol.hpp | 40 ++++++++++++++++++++++++++-------------- include/GFitsTableStringCol.hpp | 32 ++++++++++++++++++++++---------- include/GFitsTableULongCol.hpp | 34 +++++++++++++++++++++++----------- include/GFitsTableUShortCol.hpp | 34 +++++++++++++++++++++++----------- pyext/GFitsTableBitCol.i | 43 ++++++++++++++++++++++++++++++------------- pyext/GFitsTableBoolCol.i | 45 +++++++++++++++++++++++++++++++-------------- pyext/GFitsTableByteCol.i | 43 ++++++++++++++++++++++++++++++------------- pyext/GFitsTableCDoubleCol.i | 45 +++++++++++++++++++++++++++++++-------------- pyext/GFitsTableCFloatCol.i | 45 +++++++++++++++++++++++++++++++-------------- pyext/GFitsTableCol.i | 22 ++++++++++++++++------ pyext/GFitsTableDoubleCol.i | 47 ++++++++++++++++++++++++++++++++--------------- pyext/GFitsTableFloatCol.i | 45 +++++++++++++++++++++++++++++++-------------- pyext/GFitsTableLongCol.i | 45 +++++++++++++++++++++++++++++++-------------- pyext/GFitsTableLongLongCol.i | 43 ++++++++++++++++++++++++++++++------------- pyext/GFitsTableShortCol.i | 45 +++++++++++++++++++++++++++++++-------------- pyext/GFitsTableStringCol.i | 45 +++++++++++++++++++++++++++++++-------------- pyext/GFitsTableULongCol.i | 43 ++++++++++++++++++++++++++++++------------- pyext/GFitsTableUShortCol.i | 43 ++++++++++++++++++++++++++++++------------- src/fits/GFitsTableBitCol.cpp | 206 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------ src/fits/GFitsTableBoolCol.cpp | 180 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- src/fits/GFitsTableByteCol.cpp | 180 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- src/fits/GFitsTableCDoubleCol.cpp | 183 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- src/fits/GFitsTableCFloatCol.cpp | 183 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- src/fits/GFitsTableDoubleCol.cpp | 180 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- src/fits/GFitsTableFloatCol.cpp | 180 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- src/fits/GFitsTableLongCol.cpp | 180 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- src/fits/GFitsTableLongLongCol.cpp | 180 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- src/fits/GFitsTableShortCol.cpp | 180 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- src/fits/GFitsTableStringCol.cpp | 184 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- src/fits/GFitsTableULongCol.cpp | 180 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- src/fits/GFitsTableUShortCol.cpp | 180 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 41 files changed, 3071 insertions(+), 407 deletions(-) diff --git a/include/GFitsTableBitCol.hpp b/include/GFitsTableBitCol.hpp index 3588683..1b1833d 100644 --- a/include/GFitsTableBitCol.hpp +++ b/include/GFitsTableBitCol.hpp @@ -1,18 +1,26 @@ /*************************************************************************** * GFitsTableBitCol.hpp - FITS table bit column class * * ----------------------------------------------------------------------- * - * copyright (C) 2010 by Jurgen Knodlseder * + * copyright (C) 2008-2011 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. * + * 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 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * * * ***************************************************************************/ /** * @file GFitsTableBitCol.hpp - * @brief GFitsTableBitCol class definition. + * @brief FITS table bit column class interface definition * @author J. Knodlseder */ @@ -27,7 +35,7 @@ /***********************************************************************//** * @class GFitsTableBitCol * - * @brief Interface for FITS table Bit column + * @brief FITS table Bit column * * This class implements a FITS table Bit column. Bits are stored internally * in an array of type char and is transferred to the file in junks of @@ -48,10 +56,14 @@ public: 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); + // Implement virtual methods + virtual std::string string(const int& row, const int& col = 0); + virtual double real(const int& row, const int& col = 0); + virtual int integer(const int& row, const int& col = 0); + virtual void insert(const int& rownum, const int& nrows); + virtual void remove(const int& rownum, const int& nrows); + + // Other methods unsigned char* data(void) { return m_data; } void nulval(const unsigned char* value); unsigned char* nulval(void) { return m_nulval; } diff --git a/include/GFitsTableBoolCol.hpp b/include/GFitsTableBoolCol.hpp index 924496c..867649f 100644 --- a/include/GFitsTableBoolCol.hpp +++ b/include/GFitsTableBoolCol.hpp @@ -1,18 +1,26 @@ /*************************************************************************** * GFitsTableBoolCol.hpp - FITS table boolean column class * * ----------------------------------------------------------------------- * - * copyright (C) 2010 by Jurgen Knodlseder * + * copyright (C) 2008-2011 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. * + * 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 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * * * ***************************************************************************/ /** * @file GFitsTableBoolCol.hpp - * @brief GFitsTableBoolCol class definition. + * @brief FITS table Boolean column class interface definition * @author J. Knodlseder */ @@ -27,12 +35,12 @@ /***********************************************************************//** * @class GFitsTableBoolCol * - * @brief Interface for FITS table Boolean column + * @brief 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. + * compact storage scheme should be implemented. ***************************************************************************/ class GFitsTableBoolCol : public GFitsTableCol { @@ -49,13 +57,17 @@ public: 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 nulval(const bool* value); - bool* nulval(void) { return m_nulval; } + // Implement virtual methods + virtual std::string string(const int& row, const int& col = 0); + virtual double real(const int& row, const int& col = 0); + virtual int integer(const int& row, const int& col = 0); + virtual void insert(const int& rownum, const int& nrows); + virtual void remove(const int& rownum, const int& nrows); + + // Other methods + bool* data(void) { return m_data; } + void nulval(const bool* value); + bool* nulval(void) { return m_nulval; } private: // Private methods diff --git a/include/GFitsTableByteCol.hpp b/include/GFitsTableByteCol.hpp index b99ed4e..fe392c4 100644 --- a/include/GFitsTableByteCol.hpp +++ b/include/GFitsTableByteCol.hpp @@ -1,18 +1,26 @@ /*************************************************************************** * GFitsTableByteCol.hpp - FITS table Byte column class * * ----------------------------------------------------------------------- * - * copyright (C) 2010 by Jurgen Knodlseder * + * copyright (C) 2008-2011 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. * + * 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 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * * * ***************************************************************************/ /** * @file GFitsTableByteCol.hpp - * @brief GFitsTableByteCol class definition. + * @brief FITS table Byte column class interface definition * @author J. Knodlseder */ @@ -27,7 +35,7 @@ /***********************************************************************//** * @class GFitsTableByteCol * - * @brief Interface for FITS table Byte column + * @brief FITS table Byte column * * This class implements a FITS table Byte column. ***************************************************************************/ @@ -36,7 +44,8 @@ class GFitsTableByteCol : public GFitsTableCol { public: // Constructors and destructors GFitsTableByteCol(void); - GFitsTableByteCol(const std::string& name, const int& length, const int& size = 1); + GFitsTableByteCol(const std::string& name, const int& length, + const int& size = 1); GFitsTableByteCol(const GFitsTableByteCol& column); virtual ~GFitsTableByteCol(void); @@ -45,10 +54,14 @@ public: unsigned char& operator() (const int& row, const int& inx = 0); const unsigned 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); + // Implement virtual methods + virtual std::string string(const int& row, const int& col = 0); + virtual double real(const int& row, const int& col = 0); + virtual int integer(const int& row, const int& col = 0); + virtual void insert(const int& rownum, const int& nrows); + virtual void remove(const int& rownum, const int& nrows); + + // Other methods unsigned char* data(void) { return m_data; } void nulval(const unsigned char* value); unsigned char* nulval(void) { return m_nulval; } diff --git a/include/GFitsTableCDoubleCol.hpp b/include/GFitsTableCDoubleCol.hpp index cab68a1..c01e328 100644 --- a/include/GFitsTableCDoubleCol.hpp +++ b/include/GFitsTableCDoubleCol.hpp @@ -1,18 +1,26 @@ /*************************************************************************** * GFitsTableCDoubleCol.hpp - FITS table double precision complex column * * ----------------------------------------------------------------------- * - * copyright (C) 2010 by Jurgen Knodlseder * + * copyright (C) 2008-2011 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. * + * 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 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * * * ***************************************************************************/ /** * @file GFitsTableCDoubleCol.hpp - * @brief GFitsTableCDoubleCol class definition. + * @brief FITS table double complex column class interface definition * @author J. Knodlseder */ @@ -28,9 +36,9 @@ /***********************************************************************//** * @class GFitsTableCDoubleCol * - * @brief Interface for FITS table float column + * @brief FITS table double complex column * - * This class implements a FITS table float column. + * This class implements a FITS table double complex column. ***************************************************************************/ class GFitsTableCDoubleCol : public GFitsTableCol { @@ -47,10 +55,14 @@ public: 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); + // Implement virtual methods + virtual std::string string(const int& row, const int& col = 0); + virtual double real(const int& row, const int& col = 0); + virtual int integer(const int& row, const int& col = 0); + virtual void insert(const int& rownum, const int& nrows); + virtual void remove(const int& rownum, const int& nrows); + + // Other methods GFits::cdouble* data(void) { return m_data; } void nulval(const GFits::cdouble* value); GFits::cdouble* nulval(void) { return m_nulval; } diff --git a/include/GFitsTableCFloatCol.hpp b/include/GFitsTableCFloatCol.hpp index 976c5a4..ce958d4 100644 --- a/include/GFitsTableCFloatCol.hpp +++ b/include/GFitsTableCFloatCol.hpp @@ -1,18 +1,26 @@ /*************************************************************************** * GFitsTableCFloatCol.hpp - FITS table single precision complex column * * ----------------------------------------------------------------------- * - * copyright (C) 2010 by Jurgen Knodlseder * + * copyright (C) 2008-2011 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. * + * 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 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * * * ***************************************************************************/ /** * @file GFitsTableCFloatCol.hpp - * @brief GFitsTableCFloatCol class definition. + * @brief FITS table float complex column class interface definition * @author J. Knodlseder */ @@ -28,9 +36,9 @@ /***********************************************************************//** * @class GFitsTableCFloatCol * - * @brief Interface for FITS table float column + * @brief FITS table float complex column * - * This class implements a FITS table float column. + * This class implements a FITS table float complex column. ***************************************************************************/ class GFitsTableCFloatCol : public GFitsTableCol { @@ -47,10 +55,14 @@ public: 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); + // Implement virtual methods + virtual std::string string(const int& row, const int& col = 0); + virtual double real(const int& row, const int& col = 0); + virtual int integer(const int& row, const int& col = 0); + virtual void insert(const int& rownum, const int& nrows); + virtual void remove(const int& rownum, const int& nrows); + + // Other methods GFits::cfloat* data(void) { return m_data; } void nulval(const GFits::cfloat* value); GFits::cfloat* nulval(void) { return m_nulval; } diff --git a/include/GFitsTableCol.hpp b/include/GFitsTableCol.hpp index bc5eb66..ca3ab6f 100644 --- a/include/GFitsTableCol.hpp +++ b/include/GFitsTableCol.hpp @@ -1,18 +1,26 @@ /*************************************************************************** * GFitsTableCol.hpp - FITS table column abstract base class * * ----------------------------------------------------------------------- * - * copyright (C) 2008-2010 by Jurgen Knodlseder * + * copyright (C) 2008-2011 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. * + * 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 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * * * ***************************************************************************/ /** * @file GFitsTableCol.hpp - * @brief GFitsTableCol class definition. + * @brief FITS table column abstract base class definition * @author J. Knodlseder */ @@ -56,6 +64,8 @@ public: virtual std::string string(const int& row, const int& inx = 0) = 0; virtual double real(const int& row, const int& inx = 0) = 0; virtual int integer(const int& row, const int& inx = 0) = 0; + virtual void insert(const int& rownum, const int& nrows) = 0; + virtual void remove(const int& rownum, const int& nrows) = 0; // Base class Methods void name(const std::string& name); diff --git a/include/GFitsTableDoubleCol.hpp b/include/GFitsTableDoubleCol.hpp index 22b7bb7..415f66b 100644 --- a/include/GFitsTableDoubleCol.hpp +++ b/include/GFitsTableDoubleCol.hpp @@ -1,18 +1,26 @@ /*************************************************************************** * GFitsTableDoubleCol.hpp - FITS table double column class * * ----------------------------------------------------------------------- * - * copyright (C) 2010 by Jurgen Knodlseder * + * copyright (C) 2010-2011 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. * + * 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 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * * * ***************************************************************************/ /** * @file GFitsTableDoubleCol.hpp - * @brief GFitsTableDoubleCol class definition. + * @brief FITS table double column class interface definition * @author J. Knodlseder */ @@ -27,7 +35,7 @@ /***********************************************************************//** * @class GFitsTableDoubleCol * - * @brief Interface for FITS table double column + * @brief FITS table double column * * This class implements a FITS table double column. ***************************************************************************/ @@ -46,13 +54,17 @@ public: 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 nulval(const double* value); - double* nulval(void) { return m_nulval; } + // Implement virtual methods + virtual std::string string(const int& row, const int& col = 0); + virtual double real(const int& row, const int& col = 0); + virtual int integer(const int& row, const int& col = 0); + virtual void insert(const int& rownum, const int& nrows); + virtual void remove(const int& rownum, const int& nrows); + + // Other methods + double* data(void) { return m_data; } + void nulval(const double* value); + double* nulval(void) { return m_nulval; } private: // Private methods diff --git a/include/GFitsTableFloatCol.hpp b/include/GFitsTableFloatCol.hpp index 50986ce..a7a99e2 100644 --- a/include/GFitsTableFloatCol.hpp +++ b/include/GFitsTableFloatCol.hpp @@ -1,18 +1,26 @@ /*************************************************************************** * GFitsTableFloatCol.hpp - FITS table float column class * * ----------------------------------------------------------------------- * - * copyright (C) 2010 by Jurgen Knodlseder * + * copyright (C) 2010-2011 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. * + * 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 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * * * ***************************************************************************/ /** * @file GFitsTableFloatCol.hpp - * @brief GFitsTableFloatCol class definition. + * @brief FITS table float column class interface definition * @author J. Knodlseder */ @@ -27,7 +35,7 @@ /***********************************************************************//** * @class GFitsTableFloatCol * - * @brief Interface for FITS table float column + * @brief FITS table float column * * This class implements a FITS table float column. ***************************************************************************/ @@ -46,13 +54,17 @@ public: 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 nulval(const float* value); - float* nulval(void) { return m_nulval; } + // Implement virtual methods + virtual std::string string(const int& row, const int& col = 0); + virtual double real(const int& row, const int& col = 0); + virtual int integer(const int& row, const int& col = 0); + virtual void insert(const int& rownum, const int& nrows); + virtual void remove(const int& rownum, const int& nrows); + + // Other methods + float* data(void) { return m_data; } + void nulval(const float* value); + float* nulval(void) { return m_nulval; } private: // Private methods diff --git a/include/GFitsTableLongCol.hpp b/include/GFitsTableLongCol.hpp index c75543f..ebd9652 100644 --- a/include/GFitsTableLongCol.hpp +++ b/include/GFitsTableLongCol.hpp @@ -1,18 +1,26 @@ /*************************************************************************** * GFitsTableLongCol.hpp - FITS table long column class * * ----------------------------------------------------------------------- * - * copyright (C) 2010 by Jurgen Knodlseder * + * copyright (C) 2010-2011 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. * + * 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 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * * * ***************************************************************************/ /** * @file GFitsTableLongCol.hpp - * @brief GFitsTableLongCol class definition. + * @brief FITS table long integer column class interface definition * @author J. Knodlseder */ @@ -27,7 +35,7 @@ /***********************************************************************//** * @class GFitsTableLongCol * - * @brief Interface for FITS table long integer column + * @brief FITS table long integer column * * This class implements a FITS table long integer column. ***************************************************************************/ @@ -46,13 +54,17 @@ public: 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 nulval(const long* value); - long* nulval(void) { return m_nulval; } + // Implement virtual methods + virtual std::string string(const int& row, const int& col = 0); + virtual double real(const int& row, const int& col = 0); + virtual int integer(const int& row, const int& col = 0); + virtual void insert(const int& rownum, const int& nrows); + virtual void remove(const int& rownum, const int& nrows); + + // Other methods + long* data(void) { return m_data; } + void nulval(const long* value); + long* nulval(void) { return m_nulval; } private: // Private methods diff --git a/include/GFitsTableLongLongCol.hpp b/include/GFitsTableLongLongCol.hpp index 2ad8b9a..f2ce22a 100644 --- a/include/GFitsTableLongLongCol.hpp +++ b/include/GFitsTableLongLongCol.hpp @@ -1,18 +1,26 @@ /*************************************************************************** * GFitsTableLongLongCol.hpp - FITS table long long column class * * ----------------------------------------------------------------------- * - * copyright (C) 2010 by Jurgen Knodlseder * + * copyright (C) 2010-2011 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. * + * 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 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * * * ***************************************************************************/ /** * @file GFitsTableLongLongCol.hpp - * @brief GFitsTableLongLongCol class definition. + * @brief FITS table long long integer column class interface definition * @author J. Knodlseder */ @@ -27,9 +35,9 @@ /***********************************************************************//** * @class GFitsTableLongLongCol * - * @brief Interface for FITS table long integer column + * @brief FITS table long long integer column * - * This class implements a FITS table long integer column. + * This class implements a FITS table long long integer column. ***************************************************************************/ class GFitsTableLongLongCol : public GFitsTableCol { @@ -46,10 +54,14 @@ public: 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); + // Implement virtual methods + virtual std::string string(const int& row, const int& col = 0); + virtual double real(const int& row, const int& col = 0); + virtual int integer(const int& row, const int& col = 0); + virtual void insert(const int& rownum, const int& nrows); + virtual void remove(const int& rownum, const int& nrows); + + // Other methods long long* data(void) { return m_data; } void nulval(const long long* value); long long* nulval(void) { return m_nulval; } diff --git a/include/GFitsTableShortCol.hpp b/include/GFitsTableShortCol.hpp index 3ddeb79..8fa8db7 100644 --- a/include/GFitsTableShortCol.hpp +++ b/include/GFitsTableShortCol.hpp @@ -1,18 +1,26 @@ /*************************************************************************** * GFitsTableShortCol.hpp - FITS table short column class * * ----------------------------------------------------------------------- * - * copyright (C) 2010 by Jurgen Knodlseder * + * copyright (C) 2010-2011 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. * + * 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 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * * * ***************************************************************************/ /** * @file GFitsTableShortCol.hpp - * @brief GFitsTableShortCol class definition. + * @brief FITS table short integer column class interface definition * @author J. Knodlseder */ @@ -27,7 +35,7 @@ /***********************************************************************//** * @class GFitsTableShortCol * - * @brief Interface for FITS table short integer column + * @brief FITS table short integer column * * This class implements a FITS table short integer column. ***************************************************************************/ @@ -46,13 +54,17 @@ public: 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 nulval(const short* value); - short* nulval(void) { return m_nulval; } + // Implement virtual methods + virtual std::string string(const int& row, const int& col = 0); + virtual double real(const int& row, const int& col = 0); + virtual int integer(const int& row, const int& col = 0); + virtual void insert(const int& rownum, const int& nrows); + virtual void remove(const int& rownum, const int& nrows); + + // Other methods + short* data(void) { return m_data; } + void nulval(const short* value); + short* nulval(void) { return m_nulval; } private: // Private methods diff --git a/include/GFitsTableStringCol.hpp b/include/GFitsTableStringCol.hpp index 8c93878..880dcf1 100644 --- a/include/GFitsTableStringCol.hpp +++ b/include/GFitsTableStringCol.hpp @@ -4,15 +4,23 @@ * 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. * + * 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 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * * * ***************************************************************************/ /** * @file GFitsTableStringCol.hpp - * @brief GFitsTableStringCol class definition. + * @brief FITS table string column class interface definition * @author J. Knodlseder */ @@ -27,7 +35,7 @@ /***********************************************************************//** * @class GFitsTableStringCol * - * @brief Interface for FITS table string column + * @brief FITS table string column * * This class implements a FITS table string column. ***************************************************************************/ @@ -46,10 +54,14 @@ public: 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); + // Implement virtual methods + virtual std::string string(const int& row, const int& col = 0); + virtual double real(const int& row, const int& col = 0); + virtual int integer(const int& row, const int& col = 0); + virtual void insert(const int& rownum, const int& nrows); + virtual void remove(const int& rownum, const int& nrows); + + // Other methods std::string* data(void) { return m_data; } void nulval(const std::string& value); char* nulval(void) { return m_nulval; } diff --git a/include/GFitsTableULongCol.hpp b/include/GFitsTableULongCol.hpp index 66127fc..9dcbbcb 100644 --- a/include/GFitsTableULongCol.hpp +++ b/include/GFitsTableULongCol.hpp @@ -1,18 +1,26 @@ /*************************************************************************** * GFitsTableULongCol.hpp - FITS table unsigned long column class * * ----------------------------------------------------------------------- * - * copyright (C) 2010 by Jurgen Knodlseder * + * copyright (C) 2010-2011 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. * + * 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 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * * * ***************************************************************************/ /** * @file GFitsTableULongCol.hpp - * @brief GFitsTableULongCol class definition. + * @brief FITS table unsigned long integer column class interface definition * @author J. Knodlseder */ @@ -27,7 +35,7 @@ /***********************************************************************//** * @class GFitsTableULongCol * - * @brief Interface for FITS table unsigned long integer column + * @brief FITS table unsigned long integer column * * This class implements a FITS table unsigned long integer column. ***************************************************************************/ @@ -46,10 +54,14 @@ public: 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); + // Implement virtual methods + virtual std::string string(const int& row, const int& col = 0); + virtual double real(const int& row, const int& col = 0); + virtual int integer(const int& row, const int& col = 0); + virtual void insert(const int& rownum, const int& nrows); + virtual void remove(const int& rownum, const int& nrows); + + // Other methods unsigned long* data(void) { return m_data; } void nulval(const unsigned long* value); unsigned long* nulval(void) { return m_nulval; } diff --git a/include/GFitsTableUShortCol.hpp b/include/GFitsTableUShortCol.hpp index c4914d0..e54260a 100644 --- a/include/GFitsTableUShortCol.hpp +++ b/include/GFitsTableUShortCol.hpp @@ -1,18 +1,26 @@ /*************************************************************************** * GFitsTableUShortCol.hpp - FITS table unsigned short column class * * ----------------------------------------------------------------------- * - * copyright (C) 2010 by Jurgen Knodlseder * + * copyright (C) 2010-2011 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. * + * 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 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * * * ***************************************************************************/ /** * @file GFitsTableUShortCol.hpp - * @brief GFitsTableUShortCol class definition. + * @brief FITS table unsigned short integer column class interface definition * @author J. Knodlseder */ @@ -27,7 +35,7 @@ /***********************************************************************//** * @class GFitsTableUShortCol * - * @brief Interface for FITS table unsigned short integer column + * @brief FITS table unsigned short integer column * * This class implements a FITS table unsigned short integer column. ***************************************************************************/ @@ -46,10 +54,14 @@ public: 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); + // Implement virtual methods + virtual std::string string(const int& row, const int& col = 0); + virtual double real(const int& row, const int& col = 0); + virtual int integer(const int& row, const int& col = 0); + virtual void insert(const int& rownum, const int& nrows); + virtual void remove(const int& rownum, const int& nrows); + + // Other methods unsigned short* data(void) { return m_data; } void nulval(const unsigned short* value); unsigned short* nulval(void) { return m_nulval; } diff --git a/pyext/GFitsTableBitCol.i b/pyext/GFitsTableBitCol.i index 6c765f1..3445ab9 100644 --- a/pyext/GFitsTableBitCol.i +++ b/pyext/GFitsTableBitCol.i @@ -1,18 +1,26 @@ /*************************************************************************** * GFitsTableBitCol.i - FITS table bit column class SWIG definition * * ----------------------------------------------------------------------- * - * copyright : (C) 2010 by Jurgen Knodlseder * + * copyright (C) 2008-2011 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. * + * 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 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * * * ***************************************************************************/ /** * @file GFitsTableBitCol.i - * @brief GFitsTableBitCol class SWIG file. + * @brief FITS table bit column class Python interface definition * @author J. Knodlseder */ %{ @@ -24,7 +32,7 @@ /***********************************************************************//** * @class GFitsTableBitCol * - * @brief SWIG interface for FITS table logical column + * @brief FITS table bit column Python interface definition ***************************************************************************/ class GFitsTableBitCol : public GFitsTableCol { public: @@ -35,18 +43,27 @@ public: 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); - unsigned char* data(void) { return m_data; } + // Implement virtual methods + virtual std::string string(const int& row, const int& col = 0); + virtual double real(const int& row, const int& col = 0); + virtual int integer(const int& row, const int& col = 0); + virtual void insert(const int& rownum, const int& nrows); + virtual void remove(const int& rownum, const int& nrows); + + // Other methods + unsigned char* data(void); void nulval(const unsigned char* value); - unsigned char* nulval(void) { return m_nulval; } + unsigned char* nulval(void); }; /***********************************************************************//** * @brief GFitsTableBitCol class extension + * + * @todo We would like to return a reference in __getitem__ so that we can + * set the elements in an iterator. Declaring simply a reference + * shows an object pointer instead of the content. I still have to + * find out how to implement this (e.g. via typemaps). ***************************************************************************/ %extend GFitsTableBitCol { bool __getitem__(int GFitsTableColInx[]) { diff --git a/pyext/GFitsTableBoolCol.i b/pyext/GFitsTableBoolCol.i index 7788ee9..a878a8b 100644 --- a/pyext/GFitsTableBoolCol.i +++ b/pyext/GFitsTableBoolCol.i @@ -1,18 +1,26 @@ /*************************************************************************** * GFitsTableBoolCol.i - FITS table boolean column class SWIG definition * * ----------------------------------------------------------------------- * - * copyright : (C) 2008-2010 by Jurgen Knodlseder * + * copyright (C) 2008-2011 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. * + * 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 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * * * ***************************************************************************/ /** * @file GFitsTableBoolCol.i - * @brief GFitsTableBoolCol class SWIG file. + * @brief FITS table Boolean column class Python interface definition * @author J. Knodlseder */ %{ @@ -24,7 +32,7 @@ /***********************************************************************//** * @class GFitsTableBoolCol * - * @brief SWIG interface for FITS table logical column + * @brief FITS table Boolean column Python interface definition ***************************************************************************/ class GFitsTableBoolCol : public GFitsTableCol { public: @@ -35,18 +43,27 @@ public: 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 nulval(const bool* value); - bool* nulval(void) { return m_nulval; } + // Implement virtual methods + virtual std::string string(const int& row, const int& col = 0); + virtual double real(const int& row, const int& col = 0); + virtual int integer(const int& row, const int& col = 0); + virtual void insert(const int& rownum, const int& nrows); + virtual void remove(const int& rownum, const int& nrows); + + // Other methods + bool* data(void); + void nulval(const bool* value); + bool* nulval(void); }; /***********************************************************************//** * @brief GFitsTableBoolCol class extension + * + * @todo We would like to return a reference in __getitem__ so that we can + * set the elements in an iterator. Declaring simply a reference + * shows an object pointer instead of the content. I still have to + * find out how to implement this (e.g. via typemaps). ***************************************************************************/ %extend GFitsTableBoolCol { bool __getitem__(int GFitsTableColInx[]) { diff --git a/pyext/GFitsTableByteCol.i b/pyext/GFitsTableByteCol.i index 37b13f5..4f10f8a 100644 --- a/pyext/GFitsTableByteCol.i +++ b/pyext/GFitsTableByteCol.i @@ -1,18 +1,26 @@ /*************************************************************************** * GFitsTableByteCol.i - FITS table Byte column class SWIG definition * * ----------------------------------------------------------------------- * - * copyright : (C) 2008-2010 by Jurgen Knodlseder * + * copyright (C) 2008-2011 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. * + * 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 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * * * ***************************************************************************/ /** * @file GFitsTableByteCol.i - * @brief GFitsTableByteCol class SWIG file. + * @brief FITS table Byte column class Python interface definition * @author J. Knodlseder */ %{ @@ -24,7 +32,7 @@ /***********************************************************************//** * @class GFitsTableByteCol * - * @brief SWIG interface for FITS table short integer column + * @brief FITS table Byte column Python interface definition ***************************************************************************/ class GFitsTableByteCol : public GFitsTableCol { public: @@ -34,18 +42,27 @@ public: 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; } + // Implement virtual methods + virtual std::string string(const int& row, const int& col = 0); + virtual double real(const int& row, const int& col = 0); + virtual int integer(const int& row, const int& col = 0); + virtual void insert(const int& rownum, const int& nrows); + virtual void remove(const int& rownum, const int& nrows); + + // Other methods + unsigned char* data(void); void nulval(const unsigned char* value); - unsigned char* nulval(void) { return m_nulval; } + unsigned char* nulval(void); }; /***********************************************************************//** * @brief GFitsTableByteCol class extension + * + * @todo We would like to return a reference in __getitem__ so that we can + * set the elements in an iterator. Declaring simply a reference + * shows an object pointer instead of the content. I still have to + * find out how to implement this (e.g. via typemaps). ***************************************************************************/ %extend GFitsTableByteCol { unsigned char __getitem__(int GFitsTableColInx[]) { diff --git a/pyext/GFitsTableCDoubleCol.i b/pyext/GFitsTableCDoubleCol.i index 1a948c6..7a2b68d 100644 --- a/pyext/GFitsTableCDoubleCol.i +++ b/pyext/GFitsTableCDoubleCol.i @@ -1,18 +1,26 @@ /*************************************************************************** * GFitsTableCDoubleCol.i - FITS table double precision complex column * * ----------------------------------------------------------------------- * - * copyright (C) 2010 by Jurgen Knodlseder * + * copyright (C) 2008-2011 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. * + * 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 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * * * ***************************************************************************/ /** * @file GFitsTableCDoubleCol.i - * @brief GFitsTableCDoubleCol class SWIG file. + * @brief FITS table double complex column class Python interface definition * @author J. Knodlseder */ %{ @@ -24,7 +32,7 @@ /***********************************************************************//** * @class GFitsTableCDoubleCol * - * @brief SWIG interface for FITS table floating point column + * @brief FITS table double complex column Python interface definition ***************************************************************************/ class GFitsTableCDoubleCol : public GFitsTableCol { public: @@ -35,13 +43,17 @@ public: 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; } + // Implement virtual methods + virtual std::string string(const int& row, const int& col = 0); + virtual double real(const int& row, const int& col = 0); + virtual int integer(const int& row, const int& col = 0); + virtual void insert(const int& rownum, const int& nrows); + virtual void remove(const int& rownum, const int& nrows); + + // Other methods + GFits::cdouble* data(void); void nulval(const GFits::cdouble* value); - GFits::cdouble* nulval(void) { return m_nulval; } + GFits::cdouble* nulval(void); }; @@ -49,7 +61,12 @@ public: * @brief GFitsTableCDoubleCol class extension * * @todo Implement __getitem__ correctly. This probably means that a real - * cdouble class is needed. + * cdouble class is needed. + * + * @todo We would like to return a reference in __getitem__ so that we can + * set the elements in an iterator. Declaring simply a reference + * shows an object pointer instead of the content. I still have to + * find out how to implement this (e.g. via typemaps). ***************************************************************************/ %extend GFitsTableCDoubleCol { /* diff --git a/pyext/GFitsTableCFloatCol.i b/pyext/GFitsTableCFloatCol.i index 2799791..0b83f03 100644 --- a/pyext/GFitsTableCFloatCol.i +++ b/pyext/GFitsTableCFloatCol.i @@ -1,18 +1,26 @@ /*************************************************************************** * GFitsTableCFloatCol.i - FITS table single precision complex column * * ----------------------------------------------------------------------- * - * copyright (C) 2010 by Jurgen Knodlseder * + * copyright (C) 2008-2011 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. * + * 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 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * * * ***************************************************************************/ /** * @file GFitsTableCFloatCol.i - * @brief GFitsTableCFloatCol class SWIG file. + * @brief FITS table float complex column class Python interface definition * @author J. Knodlseder */ %{ @@ -24,7 +32,7 @@ /***********************************************************************//** * @class GFitsTableCFloatCol * - * @brief SWIG interface for FITS table floating point column + * @brief FITS table float complex column Python interface definition ***************************************************************************/ class GFitsTableCFloatCol : public GFitsTableCol { public: @@ -35,13 +43,17 @@ public: 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; } + // Implement virtual methods + virtual std::string string(const int& row, const int& col = 0); + virtual double real(const int& row, const int& col = 0); + virtual int integer(const int& row, const int& col = 0); + virtual void insert(const int& rownum, const int& nrows); + virtual void remove(const int& rownum, const int& nrows); + + // Other methods + GFits::cfloat* data(void); void nulval(const GFits::cfloat* value); - GFits::cfloat* nulval(void) { return m_nulval; } + GFits::cfloat* nulval(void); }; @@ -49,7 +61,12 @@ public: * @brief GFitsTableCFloatCol class extension * * @todo Implement __getitem__ method. This probably means that a real - * cfloat class is needed. + * cfloat class is needed. + * + * @todo We would like to return a reference in __getitem__ so that we can + * set the elements in an iterator. Declaring simply a reference + * shows an object pointer instead of the content. I still have to + * find out how to implement this (e.g. via typemaps). ***************************************************************************/ %extend GFitsTableCFloatCol { /* diff --git a/pyext/GFitsTableCol.i b/pyext/GFitsTableCol.i index 00bcbb3..44da1bd 100644 --- a/pyext/GFitsTableCol.i +++ b/pyext/GFitsTableCol.i @@ -4,15 +4,23 @@ * copyright : (C) 2008-2011 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. * + * 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 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * * * ***************************************************************************/ /** * @file GFitsTableCol.i - * @brief GFitsTableCol class SWIG file. + * @brief FITS table column abstract Python base class definition * @author J. Knodlseder */ %{ @@ -25,7 +33,7 @@ /***********************************************************************//** * @class GFitsTableCol * - * @brief Abstract SWIG interface for FITS table column + * @brief FITS table column abstract Python base class definition ***************************************************************************/ class GFitsTableCol { public: @@ -40,6 +48,8 @@ public: virtual std::string string(const int& row, const int& inx = 0) = 0; virtual double real(const int& row, const int& inx = 0) = 0; virtual int integer(const int& row, const int& inx = 0) = 0; + virtual void insert(const int& rownum, const int& nrows) = 0; + virtual void remove(const int& rownum, const int& nrows) = 0; // Base class Methods void name(const std::string& name); diff --git a/pyext/GFitsTableDoubleCol.i b/pyext/GFitsTableDoubleCol.i index 2d139e7..c41b18b 100644 --- a/pyext/GFitsTableDoubleCol.i +++ b/pyext/GFitsTableDoubleCol.i @@ -1,18 +1,26 @@ /*************************************************************************** * GFitsTableDoubleCol.i - FITS table double column class SWIG definiton * * ----------------------------------------------------------------------- * - * copyright (C) 2008-2010 by Jurgen Knodlseder * + * copyright (C) 2008-2011 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. * + * 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 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * * * ***************************************************************************/ /** * @file GFitsTableDoubleCol.i - * @brief GFitsTableDoubleCol class SWIG file. + * @brief FITS table double column class Python interface definition * @author J. Knodlseder */ %{ @@ -24,7 +32,7 @@ /***********************************************************************//** * @class GFitsTableDoubleCol * - * @brief SWIG interface for FITS table double precision column + * @brief FITS table double column Python interface definition ***************************************************************************/ class GFitsTableDoubleCol : public GFitsTableCol { public: @@ -35,21 +43,30 @@ public: 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 nulval(const double* value); - double* nulval(void) { return m_nulval; } + // Implement virtual methods + virtual std::string string(const int& row, const int& col = 0); + virtual double real(const int& row, const int& col = 0); + virtual int integer(const int& row, const int& col = 0); + virtual void insert(const int& rownum, const int& nrows); + virtual void remove(const int& rownum, const int& nrows); + + // Other methods + double* data(void); + void nulval(const double* value); + double* nulval(void); }; /***********************************************************************//** * @brief GFitsTableDoubleCol class extension + * + * @todo We would like to return a reference in __getitem__ so that we can + * set the elements in an iterator. Declaring simply a reference + * shows an object pointer instead of the content. I still have to + * find out how to implement this (e.g. via typemaps). ***************************************************************************/ %extend GFitsTableDoubleCol { - double __getitem__(int GFitsTableColInx[]) { + double __getitem__(int GFitsTableColInx[]) { if (GFitsTableColInx[0] == 1) return (*self)(GFitsTableColInx[1]); else diff --git a/pyext/GFitsTableFloatCol.i b/pyext/GFitsTableFloatCol.i index 104001e..2ca9da5 100644 --- a/pyext/GFitsTableFloatCol.i +++ b/pyext/GFitsTableFloatCol.i @@ -1,18 +1,26 @@ /*************************************************************************** * GFitsTableFloatCol.i - FITS table float column class SWIG definition * * ----------------------------------------------------------------------- * - * copyright (C) 2008-2010 by Jurgen Knodlseder * + * copyright (C) 2008-2011 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. * + * 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 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * * * ***************************************************************************/ /** * @file GFitsTableFloatCol.i - * @brief GFitsTableFloatCol class SWIG file. + * @brief FITS table float column class Python interface definition * @author J. Knodlseder */ %{ @@ -24,7 +32,7 @@ /***********************************************************************//** * @class GFitsTableFloatCol * - * @brief SWIG interface for FITS table floating point column + * @brief FITS table float column Python interface definition ***************************************************************************/ class GFitsTableFloatCol : public GFitsTableCol { public: @@ -35,18 +43,27 @@ public: 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 nulval(const float* value); - float* nulval(void) { return m_nulval; } + // Implement virtual methods + virtual std::string string(const int& row, const int& col = 0); + virtual double real(const int& row, const int& col = 0); + virtual int integer(const int& row, const int& col = 0); + virtual void insert(const int& rownum, const int& nrows); + virtual void remove(const int& rownum, const int& nrows); + + // Other methods + float* data(void); + void nulval(const float* value); + float* nulval(void); }; /***********************************************************************//** * @brief GFitsTableFloatCol class extension + * + * @todo We would like to return a reference in __getitem__ so that we can + * set the elements in an iterator. Declaring simply a reference + * shows an object pointer instead of the content. I still have to + * find out how to implement this (e.g. via typemaps). ***************************************************************************/ %extend GFitsTableFloatCol { float __getitem__(int GFitsTableColInx[]) { diff --git a/pyext/GFitsTableLongCol.i b/pyext/GFitsTableLongCol.i index f7db85c..9073e1a 100644 --- a/pyext/GFitsTableLongCol.i +++ b/pyext/GFitsTableLongCol.i @@ -1,18 +1,26 @@ /*************************************************************************** * GFitsTableLongCol.i - FITS table long column class SWIG definiton * * ----------------------------------------------------------------------- * - * copyright : (C) 2008-2010 by Jurgen Knodlseder * + * copyright (C) 2008-2011 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. * + * 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 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * * * ***************************************************************************/ /** * @file GFitsTableLongCol.i - * @brief GFitsTableLongCol class SWIG file. + * @brief FITS table long integer column class Python interface definition * @author J. Knodlseder */ %{ @@ -24,7 +32,7 @@ /***********************************************************************//** * @class GFitsTableLongCol * - * @brief SWIG interface for FITS table long integer column + * @brief FITS table long integer column Python interface definition ***************************************************************************/ class GFitsTableLongCol : public GFitsTableCol { public: @@ -35,18 +43,27 @@ public: 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 nulval(const long* value); - long* nulval(void) { return m_nulval; } + // Implement virtual methods + virtual std::string string(const int& row, const int& col = 0); + virtual double real(const int& row, const int& col = 0); + virtual int integer(const int& row, const int& col = 0); + virtual void insert(const int& rownum, const int& nrows); + virtual void remove(const int& rownum, const int& nrows); + + // Other methods + long* data(void); + void nulval(const long* value); + long* nulval(void); }; /***********************************************************************//** * @brief GFitsTableLongCol class extension + * + * @todo We would like to return a reference in __getitem__ so that we can + * set the elements in an iterator. Declaring simply a reference + * shows an object pointer instead of the content. I still have to + * find out how to implement this (e.g. via typemaps). ***************************************************************************/ %extend GFitsTableLongCol { long __getitem__(int GFitsTableColInx[]) { diff --git a/pyext/GFitsTableLongLongCol.i b/pyext/GFitsTableLongLongCol.i index c57c676..03c3813 100644 --- a/pyext/GFitsTableLongLongCol.i +++ b/pyext/GFitsTableLongLongCol.i @@ -1,18 +1,26 @@ /*************************************************************************** * GFitsTableLongLongCol.i - FITS table long long column class SWIG def. * * ----------------------------------------------------------------------- * - * copyright : (C) 2008-2010 by Jurgen Knodlseder * + * copyright (C) 2008-2011 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. * + * 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 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * * * ***************************************************************************/ /** * @file GFitsTableLongLongCol.i - * @brief GFitsTableLongLongCol class SWIG file. + * @brief FITS table long long integer column class Python interface definition * @author J. Knodlseder */ %{ @@ -24,7 +32,7 @@ /***********************************************************************//** * @class GFitsTableLongLongCol * - * @brief SWIG interface for FITS table long integer column + * @brief FITS table long long integer column Python interface definition ***************************************************************************/ class GFitsTableLongLongCol : public GFitsTableCol { public: @@ -35,18 +43,27 @@ public: 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; } + // Implement virtual methods + virtual std::string string(const int& row, const int& col = 0); + virtual double real(const int& row, const int& col = 0); + virtual int integer(const int& row, const int& col = 0); + virtual void insert(const int& rownum, const int& nrows); + virtual void remove(const int& rownum, const int& nrows); + + // Other methods + long long* data(void); void nulval(const long long* value); - long long* nulval(void) { return m_nulval; } + long long* nulval(void); }; /***********************************************************************//** * @brief GFitsTableLongLongCol class extension + * + * @todo We would like to return a reference in __getitem__ so that we can + * set the elements in an iterator. Declaring simply a reference + * shows an object pointer instead of the content. I still have to + * find out how to implement this (e.g. via typemaps). ***************************************************************************/ %extend GFitsTableLongLongCol { long long __getitem__(int GFitsTableColInx[]) { diff --git a/pyext/GFitsTableShortCol.i b/pyext/GFitsTableShortCol.i index 1b55d9c..1d84ba5 100644 --- a/pyext/GFitsTableShortCol.i +++ b/pyext/GFitsTableShortCol.i @@ -1,18 +1,26 @@ /*************************************************************************** * GFitsTableShortCol.i - FITS table short column class SWIG definition * * ----------------------------------------------------------------------- * - * copyright : (C) 2008-2010 by Jurgen Knodlseder * + * copyright (C) 2008-2011 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. * + * 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 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * * * ***************************************************************************/ /** * @file GFitsTableShortCol.i - * @brief GFitsTableShortCol class SWIG file. + * @brief FITS table short integer column class Python interface definition * @author J. Knodlseder */ %{ @@ -24,7 +32,7 @@ /***********************************************************************//** * @class GFitsTableShortCol * - * @brief SWIG interface for FITS table short integer column + * @brief FITS table short integer column Python interface definition ***************************************************************************/ class GFitsTableShortCol : public GFitsTableCol { public: @@ -35,18 +43,27 @@ public: 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 nulval(const short* value); - short* nulval(void) { return m_nulval; } + // Implement virtual methods + virtual std::string string(const int& row, const int& col = 0); + virtual double real(const int& row, const int& col = 0); + virtual int integer(const int& row, const int& col = 0); + virtual void insert(const int& rownum, const int& nrows); + virtual void remove(const int& rownum, const int& nrows); + + // Other methods + short* data(void); + void nulval(const short* value); + short* nulval(void); }; /***********************************************************************//** * @brief GFitsTableShortCol class extension + * + * @todo We would like to return a reference in __getitem__ so that we can + * set the elements in an iterator. Declaring simply a reference + * shows an object pointer instead of the content. I still have to + * find out how to implement this (e.g. via typemaps). ***************************************************************************/ %extend GFitsTableShortCol { short __getitem__(int GFitsTableColInx[]) { diff --git a/pyext/GFitsTableStringCol.i b/pyext/GFitsTableStringCol.i index 247a5a8..e3fb6f2 100644 --- a/pyext/GFitsTableStringCol.i +++ b/pyext/GFitsTableStringCol.i @@ -1,18 +1,26 @@ /*************************************************************************** * GFitsTableStringCol.i - FITS table string column class SWIG definition * * ----------------------------------------------------------------------- * - * copyright : (C) 2008-2010 by Jurgen Knodlseder * + * copyright (C) 2008-2011 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. * + * 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 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * * * ***************************************************************************/ /** * @file GFitsTableStringCol.i - * @brief GFitsTableStringCol class SWIG file. + * @brief FITS table string column class Python interface definition * @author J. Knodlseder */ %{ @@ -24,7 +32,7 @@ /***********************************************************************//** * @class GFitsTableStringCol * - * @brief SWIG interface for FITS table string column + * @brief FITS table string column Python interface definition ***************************************************************************/ class GFitsTableStringCol : public GFitsTableCol { public: @@ -35,18 +43,27 @@ public: 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 nulval(const std::string value); - char* nulval(void) { return m_nulval; } + // Implement virtual methods + virtual std::string string(const int& row, const int& col = 0); + virtual double real(const int& row, const int& col = 0); + virtual int integer(const int& row, const int& col = 0); + virtual void insert(const int& rownum, const int& nrows); + virtual void remove(const int& rownum, const int& nrows); + + // Other methods + std::string* data(void); + void nulval(const std::string& value); + char* nulval(void); }; /***********************************************************************//** * @brief GFitsTableStringCol class extension + * + * @todo We would like to return a reference in __getitem__ so that we can + * set the elements in an iterator. Declaring simply a reference + * shows an object pointer instead of the content. I still have to + * find out how to implement this (e.g. via typemaps). ***************************************************************************/ %extend GFitsTableStringCol { std::string __getitem__(int GFitsTableColInx[]) { diff --git a/pyext/GFitsTableULongCol.i b/pyext/GFitsTableULongCol.i index a0f0f74..131af10 100644 --- a/pyext/GFitsTableULongCol.i +++ b/pyext/GFitsTableULongCol.i @@ -1,18 +1,26 @@ /*************************************************************************** * GFitsTableULongCol.i - FITS table unsigned long column class SWIG def. * * ----------------------------------------------------------------------- * - * copyright : (C) 2010 by Jurgen Knodlseder * + * copyright (C) 2010-2011 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. * + * 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 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * * * ***************************************************************************/ /** * @file GFitsTableULongCol.i - * @brief GFitsTableULongCol class SWIG file. + * @brief FITS table unsigned long integer column class Python interface definition * @author J. Knodlseder */ %{ @@ -24,7 +32,7 @@ /***********************************************************************//** * @class GFitsTableULongCol * - * @brief SWIG interface for FITS table long integer column + * @brief FITS table unsigned long integer column Python interface definition ***************************************************************************/ class GFitsTableULongCol : public GFitsTableCol { public: @@ -35,18 +43,27 @@ public: 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; } + // Implement virtual methods + virtual std::string string(const int& row, const int& col = 0); + virtual double real(const int& row, const int& col = 0); + virtual int integer(const int& row, const int& col = 0); + virtual void insert(const int& rownum, const int& nrows); + virtual void remove(const int& rownum, const int& nrows); + + // Other methods + unsigned long* data(void); void nulval(const unsigned long* value); - unsigned long* nulval(void) { return m_nulval; } + unsigned long* nulval(void); }; /***********************************************************************//** * @brief GFitsTableULongCol class extension + * + * @todo We would like to return a reference in __getitem__ so that we can + * set the elements in an iterator. Declaring simply a reference + * shows an object pointer instead of the content. I still have to + * find out how to implement this (e.g. via typemaps). ***************************************************************************/ %extend GFitsTableULongCol { unsigned long __getitem__(int GFitsTableColInx[]) { diff --git a/pyext/GFitsTableUShortCol.i b/pyext/GFitsTableUShortCol.i index e6f9fde..f85b411 100644 --- a/pyext/GFitsTableUShortCol.i +++ b/pyext/GFitsTableUShortCol.i @@ -1,18 +1,26 @@ /*************************************************************************** * GFitsTableUShortCol.i - FITS table unsigned short column class SWIG def* * ----------------------------------------------------------------------- * - * copyright : (C) 2008-2010 by Jurgen Knodlseder * + * copyright (C) 2008-2011 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. * + * 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 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * * * ***************************************************************************/ /** * @file GFitsTableUShortCol.i - * @brief GFitsTableUShortCol class SWIG file. + * @brief FITS table unsigend short integer column class Python interface definition * @author J. Knodlseder */ %{ @@ -24,7 +32,7 @@ /***********************************************************************//** * @class GFitsTableUShortCol * - * @brief SWIG interface for FITS table short integer column + * @brief FITS table unsigned short integer column Python interface definition ***************************************************************************/ class GFitsTableUShortCol : public GFitsTableCol { public: @@ -35,18 +43,27 @@ public: 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; } + // Implement virtual methods + virtual std::string string(const int& row, const int& col = 0); + virtual double real(const int& row, const int& col = 0); + virtual int integer(const int& row, const int& col = 0); + virtual void insert(const int& rownum, const int& nrows); + virtual void remove(const int& rownum, const int& nrows); + + // Other methods + unsigned short* data(void); void nulval(const unsigned short* value); - unsigned short* nulval(void) { return m_nulval; } + unsigned short* nulval(void); }; /***********************************************************************//** * @brief GFitsTableUShortCol class extension + * + * @todo We would like to return a reference in __getitem__ so that we can + * set the elements in an iterator. Declaring simply a reference + * shows an object pointer instead of the content. I still have to + * find out how to implement this (e.g. via typemaps). ***************************************************************************/ %extend GFitsTableUShortCol { unsigned short __getitem__(int GFitsTableColInx[]) { diff --git a/src/fits/GFitsTableBitCol.cpp b/src/fits/GFitsTableBitCol.cpp index e093dd5..b6efe0c 100644 --- a/src/fits/GFitsTableBitCol.cpp +++ b/src/fits/GFitsTableBitCol.cpp @@ -4,10 +4,18 @@ * copyright (C) 2008-2011 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. * + * 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 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * * * ***************************************************************************/ /** @@ -27,6 +35,8 @@ #include "GFitsTableBitCol.hpp" /* __ Method name definitions ____________________________________________ */ +#define G_INSERT "GFitsTableBitCol::insert(int&, int&)" +#define G_REMOVE "GFitsTableBitCol::remove(int&, int&)" #define G_LOAD_COLUMN "GFitsTableBitCol::load_column()" #define G_SAVE_COLUMN "GFitsTableBitCol::save_column()" #define G_GET_BIT "GFitsTableBitCol::get_bit(int&,int&)" @@ -269,6 +279,188 @@ int GFitsTableBitCol::integer(const int& row, const int& inx) /***********************************************************************//** + * @brief Insert rows in column + * + * @param[in] rownum Row after which rows should be inserted (0=first row). + * @param[in] nrows Number of rows to be inserted. + * + * @exception GException::fits_invalid_row + * Specified rownum is invalid. + * + * This method inserts rows into a FITS table. This implies that the column + * will be loaded into memory. + ***************************************************************************/ +void GFitsTableBitCol::insert(const int& rownum, const int& nrows) +{ + // Make sure that rownum is valid + if (rownum < 0 || rownum > m_length) + throw GException::fits_invalid_row(G_INSERT, rownum, m_length); + + // Continue only if there are rows to be inserted + if (nrows > 0) { + + // If we have no rows yet then simply set the length to the + // number of rows to be inserted + if (m_length == 0) { + m_length = nrows; + } + + // ... otherwise fetch data, allocate new data and copy over + // the existing items + else { + + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Set any pending Bit + set_pending(); + + // Compute new column length + int length = m_length + nrows; + + // Compute total number of Bits in column + m_bits = m_number * length; + + // Compute number of Bytes and Bits per row + m_bytes_per_row = (m_number > 0) ? ((m_number-1) / 8) + 1 : 0; + m_bits_per_row = m_bytes_per_row * 8; + + // Compute length of memory array + m_size = m_bytes_per_row * length; + + // Allocate new data to hold the column + unsigned char* new_data = new unsigned char[m_size]; + + // Compute the number of elements before the insertion point, + // the number of elements that get inserted, and the total + // number of elements after the insertion point + int n_before = m_bytes_per_row * rownum; + int n_insert = m_bytes_per_row * nrows; + int n_after = m_bytes_per_row * (m_length - rownum); + + // Copy and initialise data + unsigned char* src = m_data; + unsigned char* dst = new_data; + for (int i = 0; i < n_before; ++i) + *dst++ = *src++; + for (int i = 0; i < n_insert; ++i) + *dst++ = 0; + for (int i = 0; i < n_after; ++i) + *dst++ = *src++; + + // Free old data + if (m_data != NULL) delete [] m_data; + + // Set pointer to new data and store length + m_data = new_data; + m_length = length; + + } // endelse: there were already data + + } // endfor: there were rows to be inserted + + // Return + return; +} + + +/***********************************************************************//** + * @brief Remove rows from column + * + * @param[in] rownum Row after which rows should be removed (0=first row). + * @param[in] nrows Number of rows to be removed. + * + * @exception GException::fits_invalid_row + * Specified rownum is invalid. + * @exception GException::fits_invalid_nrows + * Invalid number of rows specified. + * + * This method removes rows from a FITS table. This implies that the column + * will be loaded into memory. + ***************************************************************************/ +void GFitsTableBitCol::remove(const int& rownum, const int& nrows) +{ + // Make sure that rownum is valid + if (rownum < 0 || rownum >= m_length) + throw GException::fits_invalid_row(G_REMOVE, rownum, m_length-1); + + // Make sure that we don't remove beyond the limit + if (nrows < 0 || nrows > m_length-rownum) + throw GException::fits_invalid_nrows(G_REMOVE, nrows, m_length-rownum); + + // Continue only if there are rows to be removed + if (nrows > 0) { + + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Set any pending Bit + set_pending(); + + // Compute new column length + int length = m_length - nrows; + + // Compute total number of Bits in column + m_bits = m_number * length; + + // Compute number of Bytes and Bits per row + m_bytes_per_row = (m_number > 0) ? ((m_number-1) / 8) + 1 : 0; + m_bits_per_row = m_bytes_per_row * 8; + + // Compute length of memory array + m_size = m_bytes_per_row * length; + + // If we have rows remaining then allocate new data to hold + // the column + if (m_size > 0) { + + // Allocate new data to hold the column + unsigned char* new_data = new unsigned char[m_size]; + + // Compute the number of elements before the removal point, + // the number of elements that get removed, and the total + // number of elements after the removal point + int n_before = m_bytes_per_row * rownum; + int n_remove = m_bytes_per_row * nrows; + int n_after = m_bytes_per_row * (length - rownum); + + // Copy data + unsigned char* src = m_data; + unsigned char* dst = new_data; + for (int i = 0; i < n_before; ++i) + *dst++ = *src++; + src += n_remove; + for (int i = 0; i < n_after; ++i) + *dst++ = *src++; + + // Free old data + if (m_data != NULL) delete [] m_data; + + // Set pointer to new data and store length + m_data = new_data; + m_length = length; + + } // endif: there are still elements after removal + + // ... otherwise just remove all data + else { + + // Free old data + if (m_data != NULL) delete [] m_data; + + // Set pointer to new data and store length + m_data = NULL; + m_length = length; + } + + } // endfor: there were rows to be removed + + // Return + return; +} + + +/***********************************************************************//** * @brief Set nul value * * @param[in] value Nul value. @@ -614,8 +806,10 @@ void GFitsTableBitCol::save_column(void) * @param[in] row Row of column. * @param[in] inx Vector index in column row. * + * @exception GException::fits_invalid_row + * Table row out of valid range. * @exception GException::out_of_range - * Table row or vector index are out of valid range. + * Table vector index out of valid range. * * Set the Bit for boolean data access. Note that this method assumes that * the data have already been loaded. @@ -625,7 +819,7 @@ void GFitsTableBitCol::get_bit(const int& row, const int& inx) // Check row value #if defined(G_RANGE_CHECK) if (row < 0 || row >= m_length) - throw GException::out_of_range(G_GET_BIT, row, 0, m_length-1); + throw GException::fits_invalid_row(G_GET_BIT, row, m_length-1); #endif // Check inx value diff --git a/src/fits/GFitsTableBoolCol.cpp b/src/fits/GFitsTableBoolCol.cpp index 6655ef5..87a5078 100644 --- a/src/fits/GFitsTableBoolCol.cpp +++ b/src/fits/GFitsTableBoolCol.cpp @@ -4,10 +4,18 @@ * copyright (C) 2010-2011 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. * + * 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 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * * * ***************************************************************************/ /** @@ -27,6 +35,8 @@ #include "GFitsTableBoolCol.hpp" /* __ Method name definitions ____________________________________________ */ +#define G_INSERT "GFitsTableBoolCol::insert(int&, int&)" +#define G_REMOVE "GFitsTableBoolCol::remove(int&, int&)" /* __ Macros _____________________________________________________________ */ @@ -247,6 +257,168 @@ int GFitsTableBoolCol::integer(const int& row, const int& inx) /***********************************************************************//** + * @brief Insert rows in column + * + * @param[in] rownum Row after which rows should be inserted (0=first row). + * @param[in] nrows Number of rows to be inserted. + * + * @exception GException::fits_invalid_row + * Specified rownum is invalid. + * + * This method inserts rows into a FITS table. This implies that the column + * will be loaded into memory. + ***************************************************************************/ +void GFitsTableBoolCol::insert(const int& rownum, const int& nrows) +{ + // Make sure that rownum is valid + if (rownum < 0 || rownum > m_length) + throw GException::fits_invalid_row(G_INSERT, rownum, m_length); + + // Continue only if there are rows to be inserted + if (nrows > 0) { + + // If we have no rows yet then simply set the length to the + // number of rows to be inserted + if (m_length == 0) { + m_length = nrows; + } + + // ... otherwise fetch data, allocate new data and copy over + // the existing items + else { + + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Compute new column length + int length = m_length + nrows; + + // Calculate size of new memory + m_size = m_number * length; + + // Allocate new data to hold the column + bool* new_data = new bool[m_size]; + + // Compute the number of elements before the insertion point, + // the number of elements that get inserted, and the total + // number of elements after the insertion point + int n_before = m_number * rownum; + int n_insert = m_number * nrows; + int n_after = m_number * (m_length - rownum); + + // Copy and initialise data + bool* src = m_data; + bool* dst = new_data; + for (int i = 0; i < n_before; ++i) + *dst++ = *src++; + for (int i = 0; i < n_insert; ++i) + *dst++ = 0; + for (int i = 0; i < n_after; ++i) + *dst++ = *src++; + + // Free old data + if (m_data != NULL) delete [] m_data; + + // Set pointer to new data and store length + m_data = new_data; + m_length = length; + + } // endelse: there were already data + + } // endfor: there were rows to be inserted + + // Return + return; +} + + +/***********************************************************************//** + * @brief Remove rows from column + * + * @param[in] rownum Row after which rows should be removed (0=first row). + * @param[in] nrows Number of rows to be removed. + * + * @exception GException::fits_invalid_row + * Specified rownum is invalid. + * @exception GException::fits_invalid_nrows + * Invalid number of rows specified. + * + * This method removes rows from a FITS table. This implies that the column + * will be loaded into memory. + ***************************************************************************/ +void GFitsTableBoolCol::remove(const int& rownum, const int& nrows) +{ + // Make sure that rownum is valid + if (rownum < 0 || rownum >= m_length) + throw GException::fits_invalid_row(G_REMOVE, rownum, m_length-1); + + // Make sure that we don't remove beyond the limit + if (nrows < 0 || nrows > m_length-rownum) + throw GException::fits_invalid_nrows(G_REMOVE, nrows, m_length-rownum); + + // Continue only if there are rows to be removed + if (nrows > 0) { + + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Compute new column length + int length = m_length - nrows; + + // Calculate size of new memory + m_size = m_number * length; + + // If we have rows remaining then allocate new data to hold + // the column + if (m_size > 0) { + + // Allocate new data to hold the column + bool* new_data = new bool[m_size]; + + // Compute the number of elements before the removal point, + // the number of elements that get removed, and the total + // number of elements after the removal point + int n_before = m_number * rownum; + int n_remove = m_number * nrows; + int n_after = m_number * (length - rownum); + + // Copy data + bool* src = m_data; + bool* dst = new_data; + for (int i = 0; i < n_before; ++i) + *dst++ = *src++; + src += n_remove; + for (int i = 0; i < n_after; ++i) + *dst++ = *src++; + + // Free old data + if (m_data != NULL) delete [] m_data; + + // Set pointer to new data and store length + m_data = new_data; + m_length = length; + + } // endif: there are still elements after removal + + // ... otherwise just remove all data + else { + + // Free old data + if (m_data != NULL) delete [] m_data; + + // Set pointer to new data and store length + m_data = NULL; + m_length = length; + } + + } // endfor: there were rows to be removed + + // Return + return; +} + + +/***********************************************************************//** * @brief Set nul value * * @param[in] value Nul value. diff --git a/src/fits/GFitsTableByteCol.cpp b/src/fits/GFitsTableByteCol.cpp index 071edd0..c365c5a 100644 --- a/src/fits/GFitsTableByteCol.cpp +++ b/src/fits/GFitsTableByteCol.cpp @@ -4,10 +4,18 @@ * copyright (C) 2010-2011 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. * + * 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 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * * * ***************************************************************************/ /** @@ -27,6 +35,8 @@ #include "GFitsTableByteCol.hpp" /* __ Method name definitions ____________________________________________ */ +#define G_INSERT "GFitsTableByteCol::insert(int&, int&)" +#define G_REMOVE "GFitsTableByteCol::remove(int&, int&)" /* __ Macros _____________________________________________________________ */ @@ -248,6 +258,168 @@ int GFitsTableByteCol::integer(const int& row, const int& inx) /***********************************************************************//** + * @brief Insert rows in column + * + * @param[in] rownum Row after which rows should be inserted (0=first row). + * @param[in] nrows Number of rows to be inserted. + * + * @exception GException::fits_invalid_row + * Specified rownum is invalid. + * + * This method inserts rows into a FITS table. This implies that the column + * will be loaded into memory. + ***************************************************************************/ +void GFitsTableByteCol::insert(const int& rownum, const int& nrows) +{ + // Make sure that rownum is valid + if (rownum < 0 || rownum > m_length) + throw GException::fits_invalid_row(G_INSERT, rownum, m_length); + + // Continue only if there are rows to be inserted + if (nrows > 0) { + + // If we have no rows yet then simply set the length to the + // number of rows to be inserted + if (m_length == 0) { + m_length = nrows; + } + + // ... otherwise fetch data, allocate new data and copy over + // the existing items + else { + + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Compute new column length + int length = m_length + nrows; + + // Calculate size of new memory + m_size = m_number * length; + + // Allocate new data to hold the column + unsigned char* new_data = new unsigned char[m_size]; + + // Compute the number of elements before the insertion point, + // the number of elements that get inserted, and the total + // number of elements after the insertion point + int n_before = m_number * rownum; + int n_insert = m_number * nrows; + int n_after = m_number * (m_length - rownum); + + // Copy and initialise data + unsigned char* src = m_data; + unsigned char* dst = new_data; + for (int i = 0; i < n_before; ++i) + *dst++ = *src++; + for (int i = 0; i < n_insert; ++i) + *dst++ = 0; + for (int i = 0; i < n_after; ++i) + *dst++ = *src++; + + // Free old data + if (m_data != NULL) delete [] m_data; + + // Set pointer to new data and store length + m_data = new_data; + m_length = length; + + } // endelse: there were already data + + } // endfor: there were rows to be inserted + + // Return + return; +} + + +/***********************************************************************//** + * @brief Remove rows from column + * + * @param[in] rownum Row after which rows should be removed (0=first row). + * @param[in] nrows Number of rows to be removed. + * + * @exception GException::fits_invalid_row + * Specified rownum is invalid. + * @exception GException::fits_invalid_nrows + * Invalid number of rows specified. + * + * This method removes rows from a FITS table. This implies that the column + * will be loaded into memory. + ***************************************************************************/ +void GFitsTableByteCol::remove(const int& rownum, const int& nrows) +{ + // Make sure that rownum is valid + if (rownum < 0 || rownum >= m_length) + throw GException::fits_invalid_row(G_REMOVE, rownum, m_length-1); + + // Make sure that we don't remove beyond the limit + if (nrows < 0 || nrows > m_length-rownum) + throw GException::fits_invalid_nrows(G_REMOVE, nrows, m_length-rownum); + + // Continue only if there are rows to be removed + if (nrows > 0) { + + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Compute new column length + int length = m_length - nrows; + + // Calculate size of new memory + m_size = m_number * length; + + // If we have rows remaining then allocate new data to hold + // the column + if (m_size > 0) { + + // Allocate new data to hold the column + unsigned char* new_data = new unsigned char[m_size]; + + // Compute the number of elements before the removal point, + // the number of elements that get removed, and the total + // number of elements after the removal point + int n_before = m_number * rownum; + int n_remove = m_number * nrows; + int n_after = m_number * (length - rownum); + + // Copy data + unsigned char* src = m_data; + unsigned char* dst = new_data; + for (int i = 0; i < n_before; ++i) + *dst++ = *src++; + src += n_remove; + for (int i = 0; i < n_after; ++i) + *dst++ = *src++; + + // Free old data + if (m_data != NULL) delete [] m_data; + + // Set pointer to new data and store length + m_data = new_data; + m_length = length; + + } // endif: there are still elements after removal + + // ... otherwise just remove all data + else { + + // Free old data + if (m_data != NULL) delete [] m_data; + + // Set pointer to new data and store length + m_data = NULL; + m_length = length; + } + + } // endfor: there were rows to be removed + + // Return + return; +} + + +/***********************************************************************//** * @brief Set nul value * * @param[in] value Nul value. diff --git a/src/fits/GFitsTableCDoubleCol.cpp b/src/fits/GFitsTableCDoubleCol.cpp index d59b780..ff4091f 100644 --- a/src/fits/GFitsTableCDoubleCol.cpp +++ b/src/fits/GFitsTableCDoubleCol.cpp @@ -4,10 +4,18 @@ * copyright (C) 2010-2011 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. * + * 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 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * * * ***************************************************************************/ /** @@ -27,6 +35,8 @@ #include "GFitsTableCDoubleCol.hpp" /* __ Method name definitions ____________________________________________ */ +#define G_INSERT "GFitsTableCDoubleCol::insert(int&, int&)" +#define G_REMOVE "GFitsTableCDoubleCol::remove(int&, int&)" /* __ Macros _____________________________________________________________ */ @@ -248,6 +258,171 @@ int GFitsTableCDoubleCol::integer(const int& row, const int& inx) /***********************************************************************//** + * @brief Insert rows in column + * + * @param[in] rownum Row after which rows should be inserted (0=first row). + * @param[in] nrows Number of rows to be inserted. + * + * @exception GException::fits_invalid_row + * Specified rownum is invalid. + * + * This method inserts rows into a FITS table. This implies that all columns + * will be loaded into memory. + ***************************************************************************/ +void GFitsTableCDoubleCol::insert(const int& rownum, const int& nrows) +{ + // Make sure that rownum is valid + if (rownum < 0 || rownum > m_length) + throw GException::fits_invalid_row(G_INSERT, rownum, m_length); + + // Continue only if there are rows to be inserted + if (nrows > 0) { + + // If we have no rows yet then simply set the length to the + // number of rows to be inserted + if (m_length == 0) { + m_length = nrows; + } + + // ... otherwise fetch data, allocate new data and copy over + // the existing items + else { + + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Compute new column length + int length = m_length + nrows; + + // Calculate size of new memory + m_size = m_number * length; + + // Allocate new data to hold the column + GFits::cdouble* new_data = new GFits::cdouble[m_size]; + + // Compute the number of elements before the insertion point, + // the number of elements that get inserted, and the total + // number of elements after the insertion point + int n_before = m_number * rownum; + int n_insert = m_number * nrows; + int n_after = m_number * (m_length - rownum); + + // Copy and initialise data + GFits::cdouble* src = m_data; + GFits::cdouble* dst = new_data; + for (int i = 0; i < n_before; ++i) + *dst++ = *src++; + for (int i = 0; i < n_insert; ++i) { + dst->re = 0.0; + dst->im = 0.0; + dst++; + } + for (int i = 0; i < n_after; ++i) + *dst++ = *src++; + + // Free old data + if (m_data != NULL) delete [] m_data; + + // Set pointer to new data and store length + m_data = new_data; + m_length = length; + + } // endelse: there were already data + + } // endfor: there were rows to be inserted + + // Return + return; +} + + +/***********************************************************************//** + * @brief Remove rows from column + * + * @param[in] rownum Row after which rows should be removed (0=first row). + * @param[in] nrows Number of rows to be removed. + * + * @exception GException::fits_invalid_row + * Specified rownum is invalid. + * @exception GException::fits_invalid_nrows + * Invalid number of rows specified. + * + * This method removes rows from a FITS table. This implies that the column + * will be loaded into memory. + ***************************************************************************/ +void GFitsTableCDoubleCol::remove(const int& rownum, const int& nrows) +{ + // Make sure that rownum is valid + if (rownum < 0 || rownum >= m_length) + throw GException::fits_invalid_row(G_REMOVE, rownum, m_length-1); + + // Make sure that we don't remove beyond the limit + if (nrows < 0 || nrows > m_length-rownum) + throw GException::fits_invalid_nrows(G_REMOVE, nrows, m_length-rownum); + + // Continue only if there are rows to be removed + if (nrows > 0) { + + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Compute new column length + int length = m_length - nrows; + + // Calculate size of new memory + m_size = m_number * length; + + // If we have rows remaining then allocate new data to hold + // the column + if (m_size > 0) { + + // Allocate new data to hold the column + GFits::cdouble* new_data = new GFits::cdouble[m_size]; + + // Compute the number of elements before the removal point, + // the number of elements that get removed, and the total + // number of elements after the removal point + int n_before = m_number * rownum; + int n_remove = m_number * nrows; + int n_after = m_number * (length - rownum); + + // Copy data + GFits::cdouble* src = m_data; + GFits::cdouble* dst = new_data; + for (int i = 0; i < n_before; ++i) + *dst++ = *src++; + src += n_remove; + for (int i = 0; i < n_after; ++i) + *dst++ = *src++; + + // Free old data + if (m_data != NULL) delete [] m_data; + + // Set pointer to new data and store length + m_data = new_data; + m_length = length; + + } // endif: there are still elements after removal + + // ... otherwise just remove all data + else { + + // Free old data + if (m_data != NULL) delete [] m_data; + + // Set pointer to new data and store length + m_data = NULL; + m_length = length; + } + + } // endfor: there were rows to be removed + + // Return + return; +} + + +/***********************************************************************//** * @brief Set nul value * * @param[in] value Nul value. diff --git a/src/fits/GFitsTableCFloatCol.cpp b/src/fits/GFitsTableCFloatCol.cpp index b2044d0..420e3a6 100644 --- a/src/fits/GFitsTableCFloatCol.cpp +++ b/src/fits/GFitsTableCFloatCol.cpp @@ -4,10 +4,18 @@ * copyright (C) 2010-2011 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. * + * 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 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * * * ***************************************************************************/ /** @@ -27,6 +35,8 @@ #include "GFitsTableCFloatCol.hpp" /* __ Method name definitions ____________________________________________ */ +#define G_INSERT "GFitsTableCFloatCol::insert(int&, int&)" +#define G_REMOVE "GFitsTableCFloatCol::remove(int&, int&)" /* __ Macros _____________________________________________________________ */ @@ -248,6 +258,171 @@ int GFitsTableCFloatCol::integer(const int& row, const int& inx) /***********************************************************************//** + * @brief Insert rows in column + * + * @param[in] rownum Row after which rows should be inserted (0=first row). + * @param[in] nrows Number of rows to be inserted. + * + * @exception GException::fits_invalid_row + * Specified rownum is invalid. + * + * This method inserts rows into a FITS table. This implies that all columns + * will be loaded into memory. + ***************************************************************************/ +void GFitsTableCFloatCol::insert(const int& rownum, const int& nrows) +{ + // Make sure that rownum is valid + if (rownum < 0 || rownum > m_length) + throw GException::fits_invalid_row(G_INSERT, rownum, m_length); + + // Continue only if there are rows to be inserted + if (nrows > 0) { + + // If we have no rows yet then simply set the length to the + // number of rows to be inserted + if (m_length == 0) { + m_length = nrows; + } + + // ... otherwise fetch data, allocate new data and copy over + // the existing items + else { + + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Compute new column length + int length = m_length + nrows; + + // Calculate size of new memory + m_size = m_number * length; + + // Allocate new data to hold the column + GFits::cfloat* new_data = new GFits::cfloat[m_size]; + + // Compute the number of elements before the insertion point, + // the number of elements that get inserted, and the total + // number of elements after the insertion point + int n_before = m_number * rownum; + int n_insert = m_number * nrows; + int n_after = m_number * (m_length - rownum); + + // Copy and initialise data + GFits::cfloat* src = m_data; + GFits::cfloat* dst = new_data; + for (int i = 0; i < n_before; ++i) + *dst++ = *src++; + for (int i = 0; i < n_insert; ++i) { + dst->re = 0.0; + dst->im = 0.0; + dst++; + } + for (int i = 0; i < n_after; ++i) + *dst++ = *src++; + + // Free old data + if (m_data != NULL) delete [] m_data; + + // Set pointer to new data and store length + m_data = new_data; + m_length = length; + + } // endelse: there were already data + + } // endfor: there were rows to be inserted + + // Return + return; +} + + +/***********************************************************************//** + * @brief Remove rows from column + * + * @param[in] rownum Row after which rows should be removed (0=first row). + * @param[in] nrows Number of rows to be removed. + * + * @exception GException::fits_invalid_row + * Specified rownum is invalid. + * @exception GException::fits_invalid_nrows + * Invalid number of rows specified. + * + * This method removes rows from a FITS table. This implies that the column + * will be loaded into memory. + ***************************************************************************/ +void GFitsTableCFloatCol::remove(const int& rownum, const int& nrows) +{ + // Make sure that rownum is valid + if (rownum < 0 || rownum >= m_length) + throw GException::fits_invalid_row(G_REMOVE, rownum, m_length-1); + + // Make sure that we don't remove beyond the limit + if (nrows < 0 || nrows > m_length-rownum) + throw GException::fits_invalid_nrows(G_REMOVE, nrows, m_length-rownum); + + // Continue only if there are rows to be removed + if (nrows > 0) { + + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Compute new column length + int length = m_length - nrows; + + // Calculate size of new memory + m_size = m_number * length; + + // If we have rows remaining then allocate new data to hold + // the column + if (m_size > 0) { + + // Allocate new data to hold the column + GFits::cfloat* new_data = new GFits::cfloat[m_size]; + + // Compute the number of elements before the removal point, + // the number of elements that get removed, and the total + // number of elements after the removal point + int n_before = m_number * rownum; + int n_remove = m_number * nrows; + int n_after = m_number * (length - rownum); + + // Copy data + GFits::cfloat* src = m_data; + GFits::cfloat* dst = new_data; + for (int i = 0; i < n_before; ++i) + *dst++ = *src++; + src += n_remove; + for (int i = 0; i < n_after; ++i) + *dst++ = *src++; + + // Free old data + if (m_data != NULL) delete [] m_data; + + // Set pointer to new data and store length + m_data = new_data; + m_length = length; + + } // endif: there are still elements after removal + + // ... otherwise just remove all data + else { + + // Free old data + if (m_data != NULL) delete [] m_data; + + // Set pointer to new data and store length + m_data = NULL; + m_length = length; + } + + } // endfor: there were rows to be removed + + // Return + return; +} + + +/***********************************************************************//** * @brief Set nul value * * @param[in] value Nul value. diff --git a/src/fits/GFitsTableDoubleCol.cpp b/src/fits/GFitsTableDoubleCol.cpp index ad9d5c6..ccec325 100644 --- a/src/fits/GFitsTableDoubleCol.cpp +++ b/src/fits/GFitsTableDoubleCol.cpp @@ -4,10 +4,18 @@ * copyright (C) 2010-2011 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. * + * 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 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * * * ***************************************************************************/ /** @@ -27,6 +35,8 @@ #include "GFitsTableDoubleCol.hpp" /* __ Method name definitions ____________________________________________ */ +#define G_INSERT "GFitsTableDoubleCol::insert(int&, int&)" +#define G_REMOVE "GFitsTableDoubleCol::remove(int&, int&)" /* __ Macros _____________________________________________________________ */ @@ -248,6 +258,168 @@ int GFitsTableDoubleCol::integer(const int& row, const int& inx) /***********************************************************************//** + * @brief Insert rows in column + * + * @param[in] rownum Row after which rows should be inserted (0=first row). + * @param[in] nrows Number of rows to be inserted. + * + * @exception GException::fits_invalid_row + * Specified rownum is invalid. + * + * This method inserts rows into a FITS table. This implies that the column + * will be loaded into memory. + ***************************************************************************/ +void GFitsTableDoubleCol::insert(const int& rownum, const int& nrows) +{ + // Make sure that rownum is valid + if (rownum < 0 || rownum > m_length) + throw GException::fits_invalid_row(G_INSERT, rownum, m_length); + + // Continue only if there are rows to be inserted + if (nrows > 0) { + + // If we have no rows yet then simply set the length to the + // number of rows to be inserted + if (m_length == 0) { + m_length = nrows; + } + + // ... otherwise fetch data, allocate new data and copy over + // the existing items + else { + + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Compute new column length + int length = m_length + nrows; + + // Calculate size of new memory + m_size = m_number * length; + + // Allocate new data to hold the column + double* new_data = new double[m_size]; + + // Compute the number of elements before the insertion point, + // the number of elements that get inserted, and the total + // number of elements after the insertion point + int n_before = m_number * rownum; + int n_insert = m_number * nrows; + int n_after = m_number * (m_length - rownum); + + // Copy and initialise data + double* src = m_data; + double* dst = new_data; + for (int i = 0; i < n_before; ++i) + *dst++ = *src++; + for (int i = 0; i < n_insert; ++i) + *dst++ = 0.0; + for (int i = 0; i < n_after; ++i) + *dst++ = *src++; + + // Free old data + if (m_data != NULL) delete [] m_data; + + // Set pointer to new data and store length + m_data = new_data; + m_length = length; + + } // endelse: there were already data + + } // endfor: there were rows to be inserted + + // Return + return; +} + + +/***********************************************************************//** + * @brief Remove rows from column + * + * @param[in] rownum Row after which rows should be removed (0=first row). + * @param[in] nrows Number of rows to be removed. + * + * @exception GException::fits_invalid_row + * Specified rownum is invalid. + * @exception GException::fits_invalid_nrows + * Invalid number of rows specified. + * + * This method removes rows from a FITS table. This implies that the column + * will be loaded into memory. + ***************************************************************************/ +void GFitsTableDoubleCol::remove(const int& rownum, const int& nrows) +{ + // Make sure that rownum is valid + if (rownum < 0 || rownum >= m_length) + throw GException::fits_invalid_row(G_REMOVE, rownum, m_length-1); + + // Make sure that we don't remove beyond the limit + if (nrows < 0 || nrows > m_length-rownum) + throw GException::fits_invalid_nrows(G_REMOVE, nrows, m_length-rownum); + + // Continue only if there are rows to be removed + if (nrows > 0) { + + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Compute new column length + int length = m_length - nrows; + + // Calculate size of new memory + m_size = m_number * length; + + // If we have rows remaining then allocate new data to hold + // the column + if (m_size > 0) { + + // Allocate new data to hold the column + double* new_data = new double[m_size]; + + // Compute the number of elements before the removal point, + // the number of elements that get removed, and the total + // number of elements after the removal point + int n_before = m_number * rownum; + int n_remove = m_number * nrows; + int n_after = m_number * (length - rownum); + + // Copy data + double* src = m_data; + double* dst = new_data; + for (int i = 0; i < n_before; ++i) + *dst++ = *src++; + src += n_remove; + for (int i = 0; i < n_after; ++i) + *dst++ = *src++; + + // Free old data + if (m_data != NULL) delete [] m_data; + + // Set pointer to new data and store length + m_data = new_data; + m_length = length; + + } // endif: there are still elements after removal + + // ... otherwise just remove all data + else { + + // Free old data + if (m_data != NULL) delete [] m_data; + + // Set pointer to new data and store length + m_data = NULL; + m_length = length; + } + + } // endfor: there were rows to be removed + + // Return + return; +} + + +/***********************************************************************//** * @brief Set nul value * * @param[in] value Nul value. diff --git a/src/fits/GFitsTableFloatCol.cpp b/src/fits/GFitsTableFloatCol.cpp index e76462d..6719844 100644 --- a/src/fits/GFitsTableFloatCol.cpp +++ b/src/fits/GFitsTableFloatCol.cpp @@ -4,10 +4,18 @@ * copyright (C) 2010-2011 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. * + * 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 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * * * ***************************************************************************/ /** @@ -27,6 +35,8 @@ #include "GFitsTableFloatCol.hpp" /* __ Method name definitions ____________________________________________ */ +#define G_INSERT "GFitsTableFloatCol::insert(int&, int&)" +#define G_REMOVE "GFitsTableFloatCol::remove(int&, int&)" /* __ Macros _____________________________________________________________ */ @@ -248,6 +258,168 @@ int GFitsTableFloatCol::integer(const int& row, const int& inx) /***********************************************************************//** + * @brief Insert rows in column + * + * @param[in] rownum Row after which rows should be inserted (0=first row). + * @param[in] nrows Number of rows to be inserted. + * + * @exception GException::fits_invalid_row + * Specified rownum is invalid. + * + * This method inserts rows into a FITS table. This implies that all columns + * will be loaded into memory. + ***************************************************************************/ +void GFitsTableFloatCol::insert(const int& rownum, const int& nrows) +{ + // Make sure that rownum is valid + if (rownum < 0 || rownum > m_length) + throw GException::fits_invalid_row(G_INSERT, rownum, m_length); + + // Continue only if there are rows to be inserted + if (nrows > 0) { + + // If we have no rows yet then simply set the length to the + // number of rows to be inserted + if (m_length == 0) { + m_length = nrows; + } + + // ... otherwise fetch data, allocate new data and copy over + // the existing items + else { + + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Compute new column length + int length = m_length + nrows; + + // Calculate size of new memory + m_size = m_number * length; + + // Allocate new data to hold the column + float* new_data = new float[m_size]; + + // Compute the number of elements before the insertion point, + // the number of elements that get inserted, and the total + // number of elements after the insertion point + int n_before = m_number * rownum; + int n_insert = m_number * nrows; + int n_after = m_number * (m_length - rownum); + + // Copy and initialise data + float* src = m_data; + float* dst = new_data; + for (int i = 0; i < n_before; ++i) + *dst++ = *src++; + for (int i = 0; i < n_insert; ++i) + *dst++ = 0.0; + for (int i = 0; i < n_after; ++i) + *dst++ = *src++; + + // Free old data + if (m_data != NULL) delete [] m_data; + + // Set pointer to new data and store length + m_data = new_data; + m_length = length; + + } // endelse: there were already data + + } // endfor: there were rows to be inserted + + // Return + return; +} + + +/***********************************************************************//** + * @brief Remove rows from column + * + * @param[in] rownum Row after which rows should be removed (0=first row). + * @param[in] nrows Number of rows to be removed. + * + * @exception GException::fits_invalid_row + * Specified rownum is invalid. + * @exception GException::fits_invalid_nrows + * Invalid number of rows specified. + * + * This method removes rows from a FITS table. This implies that the column + * will be loaded into memory. + ***************************************************************************/ +void GFitsTableFloatCol::remove(const int& rownum, const int& nrows) +{ + // Make sure that rownum is valid + if (rownum < 0 || rownum >= m_length) + throw GException::fits_invalid_row(G_REMOVE, rownum, m_length-1); + + // Make sure that we don't remove beyond the limit + if (nrows < 0 || nrows > m_length-rownum) + throw GException::fits_invalid_nrows(G_REMOVE, nrows, m_length-rownum); + + // Continue only if there are rows to be removed + if (nrows > 0) { + + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Compute new column length + int length = m_length - nrows; + + // Calculate size of new memory + m_size = m_number * length; + + // If we have rows remaining then allocate new data to hold + // the column + if (m_size > 0) { + + // Allocate new data to hold the column + float* new_data = new float[m_size]; + + // Compute the number of elements before the removal point, + // the number of elements that get removed, and the total + // number of elements after the removal point + int n_before = m_number * rownum; + int n_remove = m_number * nrows; + int n_after = m_number * (length - rownum); + + // Copy data + float* src = m_data; + float* dst = new_data; + for (int i = 0; i < n_before; ++i) + *dst++ = *src++; + src += n_remove; + for (int i = 0; i < n_after; ++i) + *dst++ = *src++; + + // Free old data + if (m_data != NULL) delete [] m_data; + + // Set pointer to new data and store length + m_data = new_data; + m_length = length; + + } // endif: there are still elements after removal + + // ... otherwise just remove all data + else { + + // Free old data + if (m_data != NULL) delete [] m_data; + + // Set pointer to new data and store length + m_data = NULL; + m_length = length; + } + + } // endfor: there were rows to be removed + + // Return + return; +} + + +/***********************************************************************//** * @brief Set nul value * * @param[in] value Nul value. diff --git a/src/fits/GFitsTableLongCol.cpp b/src/fits/GFitsTableLongCol.cpp index d3ff958..76e7d96 100644 --- a/src/fits/GFitsTableLongCol.cpp +++ b/src/fits/GFitsTableLongCol.cpp @@ -4,10 +4,18 @@ * copyright (C) 2010-2011 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. * + * 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 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * * * ***************************************************************************/ /** @@ -27,6 +35,8 @@ #include "GFitsTableLongCol.hpp" /* __ Method name definitions ____________________________________________ */ +#define G_INSERT "GFitsTableLongCol::insert(int&, int&)" +#define G_REMOVE "GFitsTableLongCol::remove(int&, int&)" /* __ Macros _____________________________________________________________ */ @@ -248,6 +258,168 @@ int GFitsTableLongCol::integer(const int& row, const int& inx) /***********************************************************************//** + * @brief Insert rows in column + * + * @param[in] rownum Row after which rows should be inserted (0=first row). + * @param[in] nrows Number of rows to be inserted. + * + * @exception GException::fits_invalid_row + * Specified rownum is invalid. + * + * This method inserts rows into a FITS table. This implies that all columns + * will be loaded into memory. + ***************************************************************************/ +void GFitsTableLongCol::insert(const int& rownum, const int& nrows) +{ + // Make sure that rownum is valid + if (rownum < 0 || rownum > m_length) + throw GException::fits_invalid_row(G_INSERT, rownum, m_length); + + // Continue only if there are rows to be inserted + if (nrows > 0) { + + // If we have no rows yet then simply set the length to the + // number of rows to be inserted + if (m_length == 0) { + m_length = nrows; + } + + // ... otherwise fetch data, allocate new data and copy over + // the existing items + else { + + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Compute new column length + int length = m_length + nrows; + + // Calculate size of new memory + m_size = m_number * length; + + // Allocate new data to hold the column + long* new_data = new long[m_size]; + + // Compute the number of elements before the insertion point, + // the number of elements that get inserted, and the total + // number of elements after the insertion point + int n_before = m_number * rownum; + int n_insert = m_number * nrows; + int n_after = m_number * (m_length - rownum); + + // Copy and initialise data + long* src = m_data; + long* dst = new_data; + for (int i = 0; i < n_before; ++i) + *dst++ = *src++; + for (int i = 0; i < n_insert; ++i) + *dst++ = 0.0; + for (int i = 0; i < n_after; ++i) + *dst++ = *src++; + + // Free old data + if (m_data != NULL) delete [] m_data; + + // Set pointer to new data and store length + m_data = new_data; + m_length = length; + + } // endelse: there were already data + + } // endfor: there were rows to be inserted + + // Return + return; +} + + +/***********************************************************************//** + * @brief Remove rows from column + * + * @param[in] rownum Row after which rows should be removed (0=first row). + * @param[in] nrows Number of rows to be removed. + * + * @exception GException::fits_invalid_row + * Specified rownum is invalid. + * @exception GException::fits_invalid_nrows + * Invalid number of rows specified. + * + * This method removes rows from a FITS table. This implies that the column + * will be loaded into memory. + ***************************************************************************/ +void GFitsTableLongCol::remove(const int& rownum, const int& nrows) +{ + // Make sure that rownum is valid + if (rownum < 0 || rownum >= m_length) + throw GException::fits_invalid_row(G_REMOVE, rownum, m_length-1); + + // Make sure that we don't remove beyond the limit + if (nrows < 0 || nrows > m_length-rownum) + throw GException::fits_invalid_nrows(G_REMOVE, nrows, m_length-rownum); + + // Continue only if there are rows to be removed + if (nrows > 0) { + + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Compute new column length + int length = m_length - nrows; + + // Calculate size of new memory + m_size = m_number * length; + + // If we have rows remaining then allocate new data to hold + // the column + if (m_size > 0) { + + // Allocate new data to hold the column + long* new_data = new long[m_size]; + + // Compute the number of elements before the removal point, + // the number of elements that get removed, and the total + // number of elements after the removal point + int n_before = m_number * rownum; + int n_remove = m_number * nrows; + int n_after = m_number * (length - rownum); + + // Copy data + long* src = m_data; + long* dst = new_data; + for (int i = 0; i < n_before; ++i) + *dst++ = *src++; + src += n_remove; + for (int i = 0; i < n_after; ++i) + *dst++ = *src++; + + // Free old data + if (m_data != NULL) delete [] m_data; + + // Set pointer to new data and store length + m_data = new_data; + m_length = length; + + } // endif: there are still elements after removal + + // ... otherwise just remove all data + else { + + // Free old data + if (m_data != NULL) delete [] m_data; + + // Set pointer to new data and store length + m_data = NULL; + m_length = length; + } + + } // endfor: there were rows to be removed + + // Return + return; +} + + +/***********************************************************************//** * @brief Set nul value * * @param[in] value Nul value. diff --git a/src/fits/GFitsTableLongLongCol.cpp b/src/fits/GFitsTableLongLongCol.cpp index 3087f0d..38f735f 100644 --- a/src/fits/GFitsTableLongLongCol.cpp +++ b/src/fits/GFitsTableLongLongCol.cpp @@ -4,10 +4,18 @@ * copyright (C) 2010-2011 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. * + * 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 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * * * ***************************************************************************/ /** @@ -27,6 +35,8 @@ #include "GFitsTableLongLongCol.hpp" /* __ Method name definitions ____________________________________________ */ +#define G_INSERT "GFitsTableLongLongCol::insert(int&, int&)" +#define G_REMOVE "GFitsTableLongLongCol::remove(int&, int&)" /* __ Macros _____________________________________________________________ */ @@ -248,6 +258,168 @@ int GFitsTableLongLongCol::integer(const int& row, const int& inx) /***********************************************************************//** + * @brief Insert rows in column + * + * @param[in] rownum Row after which rows should be inserted (0=first row). + * @param[in] nrows Number of rows to be inserted. + * + * @exception GException::fits_invalid_row + * Specified rownum is invalid. + * + * This method inserts rows into a FITS table. This implies that all columns + * will be loaded into memory. + ***************************************************************************/ +void GFitsTableLongLongCol::insert(const int& rownum, const int& nrows) +{ + // Make sure that rownum is valid + if (rownum < 0 || rownum > m_length) + throw GException::fits_invalid_row(G_INSERT, rownum, m_length); + + // Continue only if there are rows to be inserted + if (nrows > 0) { + + // If we have no rows yet then simply set the length to the + // number of rows to be inserted + if (m_length == 0) { + m_length = nrows; + } + + // ... otherwise fetch data, allocate new data and copy over + // the existing items + else { + + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Compute new column length + int length = m_length + nrows; + + // Calculate size of new memory + m_size = m_number * length; + + // Allocate new data to hold the column + long long* new_data = new long long[m_size]; + + // Compute the number of elements before the insertion point, + // the number of elements that get inserted, and the total + // number of elements after the insertion point + int n_before = m_number * rownum; + int n_insert = m_number * nrows; + int n_after = m_number * (m_length - rownum); + + // Copy and initialise data + long long* src = m_data; + long long* dst = new_data; + for (int i = 0; i < n_before; ++i) + *dst++ = *src++; + for (int i = 0; i < n_insert; ++i) + *dst++ = 0.0; + for (int i = 0; i < n_after; ++i) + *dst++ = *src++; + + // Free old data + if (m_data != NULL) delete [] m_data; + + // Set pointer to new data and store length + m_data = new_data; + m_length = length; + + } // endelse: there were already data + + } // endfor: there were rows to be inserted + + // Return + return; +} + + +/***********************************************************************//** + * @brief Remove rows from column + * + * @param[in] rownum Row after which rows should be removed (0=first row). + * @param[in] nrows Number of rows to be removed. + * + * @exception GException::fits_invalid_row + * Specified rownum is invalid. + * @exception GException::fits_invalid_nrows + * Invalid number of rows specified. + * + * This method removes rows from a FITS table. This implies that the column + * will be loaded into memory. + ***************************************************************************/ +void GFitsTableLongLongCol::remove(const int& rownum, const int& nrows) +{ + // Make sure that rownum is valid + if (rownum < 0 || rownum >= m_length) + throw GException::fits_invalid_row(G_REMOVE, rownum, m_length-1); + + // Make sure that we don't remove beyond the limit + if (nrows < 0 || nrows > m_length-rownum) + throw GException::fits_invalid_nrows(G_REMOVE, nrows, m_length-rownum); + + // Continue only if there are rows to be removed + if (nrows > 0) { + + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Compute new column length + int length = m_length - nrows; + + // Calculate size of new memory + m_size = m_number * length; + + // If we have rows remaining then allocate new data to hold + // the column + if (m_size > 0) { + + // Allocate new data to hold the column + long long* new_data = new long long[m_size]; + + // Compute the number of elements before the removal point, + // the number of elements that get removed, and the total + // number of elements after the removal point + int n_before = m_number * rownum; + int n_remove = m_number * nrows; + int n_after = m_number * (length - rownum); + + // Copy data + long long* src = m_data; + long long* dst = new_data; + for (int i = 0; i < n_before; ++i) + *dst++ = *src++; + src += n_remove; + for (int i = 0; i < n_after; ++i) + *dst++ = *src++; + + // Free old data + if (m_data != NULL) delete [] m_data; + + // Set pointer to new data and store length + m_data = new_data; + m_length = length; + + } // endif: there are still elements after removal + + // ... otherwise just remove all data + else { + + // Free old data + if (m_data != NULL) delete [] m_data; + + // Set pointer to new data and store length + m_data = NULL; + m_length = length; + } + + } // endfor: there were rows to be removed + + // Return + return; +} + + +/***********************************************************************//** * @brief Set nul value * * @param[in] value Nul value. diff --git a/src/fits/GFitsTableShortCol.cpp b/src/fits/GFitsTableShortCol.cpp index 7dd97f5..d7f4b5b 100644 --- a/src/fits/GFitsTableShortCol.cpp +++ b/src/fits/GFitsTableShortCol.cpp @@ -4,10 +4,18 @@ * copyright (C) 2010-2011 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. * + * 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 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * * * ***************************************************************************/ /** @@ -27,6 +35,8 @@ #include "GFitsTableShortCol.hpp" /* __ Method name definitions ____________________________________________ */ +#define G_INSERT "GFitsTableShortCol::insert(int&, int&)" +#define G_REMOVE "GFitsTableShortCol::remove(int&, int&)" /* __ Macros _____________________________________________________________ */ @@ -248,6 +258,168 @@ int GFitsTableShortCol::integer(const int& row, const int& inx) /***********************************************************************//** + * @brief Insert rows in column + * + * @param[in] rownum Row after which rows should be inserted (0=first row). + * @param[in] nrows Number of rows to be inserted. + * + * @exception GException::fits_invalid_row + * Specified rownum is invalid. + * + * This method inserts rows into a FITS table. This implies that all columns + * will be loaded into memory. + ***************************************************************************/ +void GFitsTableShortCol::insert(const int& rownum, const int& nrows) +{ + // Make sure that rownum is valid + if (rownum < 0 || rownum > m_length) + throw GException::fits_invalid_row(G_INSERT, rownum, m_length); + + // Continue only if there are rows to be inserted + if (nrows > 0) { + + // If we have no rows yet then simply set the length to the + // number of rows to be inserted + if (m_length == 0) { + m_length = nrows; + } + + // ... otherwise fetch data, allocate new data and copy over + // the existing items + else { + + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Compute new column length + int length = m_length + nrows; + + // Calculate size of new memory + m_size = m_number * length; + + // Allocate new data to hold the column + short* new_data = new short[m_size]; + + // Compute the number of elements before the insertion point, + // the number of elements that get inserted, and the total + // number of elements after the insertion point + int n_before = m_number * rownum; + int n_insert = m_number * nrows; + int n_after = m_number * (m_length - rownum); + + // Copy and initialise data + short* src = m_data; + short* dst = new_data; + for (int i = 0; i < n_before; ++i) + *dst++ = *src++; + for (int i = 0; i < n_insert; ++i) + *dst++ = 0.0; + for (int i = 0; i < n_after; ++i) + *dst++ = *src++; + + // Free old data + if (m_data != NULL) delete [] m_data; + + // Set pointer to new data and store length + m_data = new_data; + m_length = length; + + } // endelse: there were already data + + } // endfor: there were rows to be inserted + + // Return + return; +} + + +/***********************************************************************//** + * @brief Remove rows from column + * + * @param[in] rownum Row after which rows should be removed (0=first row). + * @param[in] nrows Number of rows to be removed. + * + * @exception GException::fits_invalid_row + * Specified rownum is invalid. + * @exception GException::fits_invalid_nrows + * Invalid number of rows specified. + * + * This method removes rows from a FITS table. This implies that the column + * will be loaded into memory. + ***************************************************************************/ +void GFitsTableShortCol::remove(const int& rownum, const int& nrows) +{ + // Make sure that rownum is valid + if (rownum < 0 || rownum >= m_length) + throw GException::fits_invalid_row(G_REMOVE, rownum, m_length-1); + + // Make sure that we don't remove beyond the limit + if (nrows < 0 || nrows > m_length-rownum) + throw GException::fits_invalid_nrows(G_REMOVE, nrows, m_length-rownum); + + // Continue only if there are rows to be removed + if (nrows > 0) { + + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Compute new column length + int length = m_length - nrows; + + // Calculate size of new memory + m_size = m_number * length; + + // If we have rows remaining then allocate new data to hold + // the column + if (m_size > 0) { + + // Allocate new data to hold the column + short* new_data = new short[m_size]; + + // Compute the number of elements before the removal point, + // the number of elements that get removed, and the total + // number of elements after the removal point + int n_before = m_number * rownum; + int n_remove = m_number * nrows; + int n_after = m_number * (length - rownum); + + // Copy data + short* src = m_data; + short* dst = new_data; + for (int i = 0; i < n_before; ++i) + *dst++ = *src++; + src += n_remove; + for (int i = 0; i < n_after; ++i) + *dst++ = *src++; + + // Free old data + if (m_data != NULL) delete [] m_data; + + // Set pointer to new data and store length + m_data = new_data; + m_length = length; + + } // endif: there are still elements after removal + + // ... otherwise just remove all data + else { + + // Free old data + if (m_data != NULL) delete [] m_data; + + // Set pointer to new data and store length + m_data = NULL; + m_length = length; + } + + } // endfor: there were rows to be removed + + // Return + return; +} + + +/***********************************************************************//** * @brief Set nul value * * @param[in] value Nul value. diff --git a/src/fits/GFitsTableStringCol.cpp b/src/fits/GFitsTableStringCol.cpp index 782412f..08045c3 100644 --- a/src/fits/GFitsTableStringCol.cpp +++ b/src/fits/GFitsTableStringCol.cpp @@ -1,13 +1,21 @@ /*************************************************************************** * GFitsTableStringCol.cpp - FITS table string column class * * ----------------------------------------------------------------------- * - * copyright (C) 2008-2011 by Jurgen Knodlseder * + * copyright (C) 2010-2011 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. * + * 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 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * * * ***************************************************************************/ /** @@ -28,6 +36,8 @@ #include "GFitsTableStringCol.hpp" /* __ Method name definitions ____________________________________________ */ +#define G_INSERT "GFitsTableStringCol::insert(int&, int&)" +#define G_REMOVE "GFitsTableStringCol::remove(int&, int&)" /* __ Macros _____________________________________________________________ */ @@ -247,6 +257,170 @@ int GFitsTableStringCol::integer(const int& row, const int& inx) /***********************************************************************//** + * @brief Insert rows in column + * + * @param[in] rownum Row after which rows should be inserted (0=first row). + * @param[in] nrows Number of rows to be inserted. + * + * @exception GException::fits_invalid_row + * Specified rownum is invalid. + * + * This method inserts rows into a FITS table. This implies that all columns + * will be loaded into memory. + ***************************************************************************/ +void GFitsTableStringCol::insert(const int& rownum, const int& nrows) +{ + // Make sure that rownum is valid + if (rownum < 0 || rownum > m_length) + throw GException::fits_invalid_row(G_INSERT, rownum, m_length); + + // Continue only if there are rows to be inserted + if (nrows > 0) { + + // If we have no rows yet then simply set the length to the + // number of rows to be inserted + if (m_length == 0) { + m_length = nrows; + } + + // ... otherwise fetch data, allocate new data and copy over + // the existing items + else { + + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Compute new column length + int length = m_length + nrows; + + // Calculate size of new memory + m_size = m_number * length; + + // Allocate new data to hold the column + std::string* new_data = new std::string[m_size]; + + // Compute the number of elements before the insertion point, + // the number of elements that get inserted, and the total + // number of elements after the insertion point + int n_before = m_number * rownum; + int n_insert = m_number * nrows; + int n_after = m_number * (m_length - rownum); + + // Copy and initialise data + std::string* src = m_data; + std::string* dst = new_data; + for (int i = 0; i < n_before; ++i) + *dst++ = *src++; + for (int i = 0; i < n_insert; ++i) { + dst->clear(); + dst++; + } + for (int i = 0; i < n_after; ++i) + *dst++ = *src++; + + // Free old data + if (m_data != NULL) delete [] m_data; + + // Set pointer to new data and store length + m_data = new_data; + m_length = length; + + } // endelse: there were already data + + } // endfor: there were rows to be inserted + + // Return + return; +} + + +/***********************************************************************//** + * @brief Remove rows from column + * + * @param[in] rownum Row after which rows should be removed (0=first row). + * @param[in] nrows Number of rows to be removed. + * + * @exception GException::fits_invalid_row + * Specified rownum is invalid. + * @exception GException::fits_invalid_nrows + * Invalid number of rows specified. + * + * This method removes rows from a FITS table. This implies that the column + * will be loaded into memory. + ***************************************************************************/ +void GFitsTableStringCol::remove(const int& rownum, const int& nrows) +{ + // Make sure that rownum is valid + if (rownum < 0 || rownum >= m_length) + throw GException::fits_invalid_row(G_REMOVE, rownum, m_length-1); + + // Make sure that we don't remove beyond the limit + if (nrows < 0 || nrows > m_length-rownum) + throw GException::fits_invalid_nrows(G_REMOVE, nrows, m_length-rownum); + + // Continue only if there are rows to be removed + if (nrows > 0) { + + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Compute new column length + int length = m_length - nrows; + + // Calculate size of new memory + m_size = m_number * length; + + // If we have rows remaining then allocate new data to hold + // the column + if (m_size > 0) { + + // Allocate new data to hold the column + std::string* new_data = new std::string[m_size]; + + // Compute the number of elements before the removal point, + // the number of elements that get removed, and the total + // number of elements after the removal point + int n_before = m_number * rownum; + int n_remove = m_number * nrows; + int n_after = m_number * (length - rownum); + + // Copy data + std::string* src = m_data; + std::string* dst = new_data; + for (int i = 0; i < n_before; ++i) + *dst++ = *src++; + src += n_remove; + for (int i = 0; i < n_after; ++i) + *dst++ = *src++; + + // Free old data + if (m_data != NULL) delete [] m_data; + + // Set pointer to new data and store length + m_data = new_data; + m_length = length; + + } // endif: there are still elements after removal + + // ... otherwise just remove all data + else { + + // Free old data + if (m_data != NULL) delete [] m_data; + + // Set pointer to new data and store length + m_data = NULL; + m_length = length; + } + + } // endfor: there were rows to be removed + + // Return + return; +} + + +/***********************************************************************//** * @brief Set nul value * * @param[in] value Nul value string. diff --git a/src/fits/GFitsTableULongCol.cpp b/src/fits/GFitsTableULongCol.cpp index f427f3c..a0e4bde 100644 --- a/src/fits/GFitsTableULongCol.cpp +++ b/src/fits/GFitsTableULongCol.cpp @@ -4,10 +4,18 @@ * copyright (C) 2010-2011 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. * + * 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 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * * * ***************************************************************************/ /** @@ -27,6 +35,8 @@ #include "GFitsTableULongCol.hpp" /* __ Method name definitions ____________________________________________ */ +#define G_INSERT "GFitsTableLongCol::insert(int&, int&)" +#define G_REMOVE "GFitsTableLongCol::remove(int&, int&)" /* __ Macros _____________________________________________________________ */ @@ -248,6 +258,168 @@ int GFitsTableULongCol::integer(const int& row, const int& inx) /***********************************************************************//** + * @brief Insert rows in column + * + * @param[in] rownum Row after which rows should be inserted (0=first row). + * @param[in] nrows Number of rows to be inserted. + * + * @exception GException::fits_invalid_row + * Specified rownum is invalid. + * + * This method inserts rows into a FITS table. This implies that all columns + * will be loaded into memory. + ***************************************************************************/ +void GFitsTableULongCol::insert(const int& rownum, const int& nrows) +{ + // Make sure that rownum is valid + if (rownum < 0 || rownum > m_length) + throw GException::fits_invalid_row(G_INSERT, rownum, m_length); + + // Continue only if there are rows to be inserted + if (nrows > 0) { + + // If we have no rows yet then simply set the length to the + // number of rows to be inserted + if (m_length == 0) { + m_length = nrows; + } + + // ... otherwise fetch data, allocate new data and copy over + // the existing items + else { + + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Compute new column length + int length = m_length + nrows; + + // Calculate size of new memory + m_size = m_number * length; + + // Allocate new data to hold the column + unsigned long* new_data = new unsigned long[m_size]; + + // Compute the number of elements before the insertion point, + // the number of elements that get inserted, and the total + // number of elements after the insertion point + int n_before = m_number * rownum; + int n_insert = m_number * nrows; + int n_after = m_number * (m_length - rownum); + + // Copy and initialise data + unsigned long* src = m_data; + unsigned long* dst = new_data; + for (int i = 0; i < n_before; ++i) + *dst++ = *src++; + for (int i = 0; i < n_insert; ++i) + *dst++ = 0.0; + for (int i = 0; i < n_after; ++i) + *dst++ = *src++; + + // Free old data + if (m_data != NULL) delete [] m_data; + + // Set pointer to new data and store length + m_data = new_data; + m_length = length; + + } // endelse: there were already data + + } // endfor: there were rows to be inserted + + // Return + return; +} + + +/***********************************************************************//** + * @brief Remove rows from column + * + * @param[in] rownum Row after which rows should be removed (0=first row). + * @param[in] nrows Number of rows to be removed. + * + * @exception GException::fits_invalid_row + * Specified rownum is invalid. + * @exception GException::fits_invalid_nrows + * Invalid number of rows specified. + * + * This method removes rows from a FITS table. This implies that the column + * will be loaded into memory. + ***************************************************************************/ +void GFitsTableULongCol::remove(const int& rownum, const int& nrows) +{ + // Make sure that rownum is valid + if (rownum < 0 || rownum >= m_length) + throw GException::fits_invalid_row(G_REMOVE, rownum, m_length-1); + + // Make sure that we don't remove beyond the limit + if (nrows < 0 || nrows > m_length-rownum) + throw GException::fits_invalid_nrows(G_REMOVE, nrows, m_length-rownum); + + // Continue only if there are rows to be removed + if (nrows > 0) { + + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Compute new column length + int length = m_length - nrows; + + // Calculate size of new memory + m_size = m_number * length; + + // If we have rows remaining then allocate new data to hold + // the column + if (m_size > 0) { + + // Allocate new data to hold the column + unsigned long* new_data = new unsigned long[m_size]; + + // Compute the number of elements before the removal point, + // the number of elements that get removed, and the total + // number of elements after the removal point + int n_before = m_number * rownum; + int n_remove = m_number * nrows; + int n_after = m_number * (length - rownum); + + // Copy data + unsigned long* src = m_data; + unsigned long* dst = new_data; + for (int i = 0; i < n_before; ++i) + *dst++ = *src++; + src += n_remove; + for (int i = 0; i < n_after; ++i) + *dst++ = *src++; + + // Free old data + if (m_data != NULL) delete [] m_data; + + // Set pointer to new data and store length + m_data = new_data; + m_length = length; + + } // endif: there are still elements after removal + + // ... otherwise just remove all data + else { + + // Free old data + if (m_data != NULL) delete [] m_data; + + // Set pointer to new data and store length + m_data = NULL; + m_length = length; + } + + } // endfor: there were rows to be removed + + // Return + return; +} + + +/***********************************************************************//** * @brief Set nul value * * @param[in] value Nul value. diff --git a/src/fits/GFitsTableUShortCol.cpp b/src/fits/GFitsTableUShortCol.cpp index ea69edb..8c61bd7 100644 --- a/src/fits/GFitsTableUShortCol.cpp +++ b/src/fits/GFitsTableUShortCol.cpp @@ -4,10 +4,18 @@ * copyright (C) 2010-2011 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. * + * 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 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * * * ***************************************************************************/ /** @@ -27,6 +35,8 @@ #include "GFitsTableUShortCol.hpp" /* __ Method name definitions ____________________________________________ */ +#define G_INSERT "GFitsTableUShortCol::insert(int&, int&)" +#define G_REMOVE "GFitsTableUShortCol::remove(int&, int&)" /* __ Macros _____________________________________________________________ */ @@ -248,6 +258,168 @@ int GFitsTableUShortCol::integer(const int& row, const int& inx) /***********************************************************************//** + * @brief Insert rows in column + * + * @param[in] rownum Row after which rows should be inserted (0=first row). + * @param[in] nrows Number of rows to be inserted. + * + * @exception GException::fits_invalid_row + * Specified rownum is invalid. + * + * This method inserts rows into a FITS table. This implies that all columns + * will be loaded into memory. + ***************************************************************************/ +void GFitsTableUShortCol::insert(const int& rownum, const int& nrows) +{ + // Make sure that rownum is valid + if (rownum < 0 || rownum > m_length) + throw GException::fits_invalid_row(G_INSERT, rownum, m_length); + + // Continue only if there are rows to be inserted + if (nrows > 0) { + + // If we have no rows yet then simply set the length to the + // number of rows to be inserted + if (m_length == 0) { + m_length = nrows; + } + + // ... otherwise fetch data, allocate new data and copy over + // the existing items + else { + + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Compute new column length + int length = m_length + nrows; + + // Calculate size of new memory + m_size = m_number * length; + + // Allocate new data to hold the column + unsigned short* new_data = new unsigned short[m_size]; + + // Compute the number of elements before the insertion point, + // the number of elements that get inserted, and the total + // number of elements after the insertion point + int n_before = m_number * rownum; + int n_insert = m_number * nrows; + int n_after = m_number * (m_length - rownum); + + // Copy and initialise data + unsigned short* src = m_data; + unsigned short* dst = new_data; + for (int i = 0; i < n_before; ++i) + *dst++ = *src++; + for (int i = 0; i < n_insert; ++i) + *dst++ = 0.0; + for (int i = 0; i < n_after; ++i) + *dst++ = *src++; + + // Free old data + if (m_data != NULL) delete [] m_data; + + // Set pointer to new data and store length + m_data = new_data; + m_length = length; + + } // endelse: there were already data + + } // endfor: there were rows to be inserted + + // Return + return; +} + + +/***********************************************************************//** + * @brief Remove rows from column + * + * @param[in] rownum Row after which rows should be removed (0=first row). + * @param[in] nrows Number of rows to be removed. + * + * @exception GException::fits_invalid_row + * Specified rownum is invalid. + * @exception GException::fits_invalid_nrows + * Invalid number of rows specified. + * + * This method removes rows from a FITS table. This implies that the column + * will be loaded into memory. + ***************************************************************************/ +void GFitsTableUShortCol::remove(const int& rownum, const int& nrows) +{ + // Make sure that rownum is valid + if (rownum < 0 || rownum >= m_length) + throw GException::fits_invalid_row(G_REMOVE, rownum, m_length-1); + + // Make sure that we don't remove beyond the limit + if (nrows < 0 || nrows > m_length-rownum) + throw GException::fits_invalid_nrows(G_REMOVE, nrows, m_length-rownum); + + // Continue only if there are rows to be removed + if (nrows > 0) { + + // If data are not available then load them now + if (m_data == NULL) fetch_data(); + + // Compute new column length + int length = m_length - nrows; + + // Calculate size of new memory + m_size = m_number * length; + + // If we have rows remaining then allocate new data to hold + // the column + if (m_size > 0) { + + // Allocate new data to hold the column + unsigned short* new_data = new unsigned short[m_size]; + + // Compute the number of elements before the removal point, + // the number of elements that get removed, and the total + // number of elements after the removal point + int n_before = m_number * rownum; + int n_remove = m_number * nrows; + int n_after = m_number * (length - rownum); + + // Copy data + unsigned short* src = m_data; + unsigned short* dst = new_data; + for (int i = 0; i < n_before; ++i) + *dst++ = *src++; + src += n_remove; + for (int i = 0; i < n_after; ++i) + *dst++ = *src++; + + // Free old data + if (m_data != NULL) delete [] m_data; + + // Set pointer to new data and store length + m_data = new_data; + m_length = length; + + } // endif: there are still elements after removal + + // ... otherwise just remove all data + else { + + // Free old data + if (m_data != NULL) delete [] m_data; + + // Set pointer to new data and store length + m_data = NULL; + m_length = length; + } + + } // endfor: there were rows to be removed + + // Return + return; +} + + +/***********************************************************************//** * @brief Set nul value * * @param[in] value Nul value. -- libgit2 0.21.4