Commit 6bed2c93bb179fa09ce5b23dfd90090c46d78245

Authored by knodlseder
1 parent e9d2f7e5

use new FITS table column classes

Showing 43 changed files with 5976 additions and 1570 deletions
include/GFitsTableBitCol.hpp
... ... @@ -30,8 +30,8 @@
30 30 *
31 31 * This class implements a FITS table Bit column.
32 32 *
33   - * TODO: Each Bit is actually stored in one Byte. To save memory a more
34   - * compact storage scheme should be implemented.
  33 + * @todo Each Bit is actually stored in one Byte. To save memory a more
  34 + * compact storage scheme could be implemented.
35 35 ***************************************************************************/
36 36 class GFitsTableBitCol : public GFitsTableCol {
37 37  
... ... @@ -55,21 +55,22 @@ public:
55 55 std::string string(const int& row, const int& col = 0);
56 56 double real(const int& row, const int& col = 0);
57 57 int integer(const int& row, const int& col = 0);
58   - char* data(void);
59   - void set_nullval(const char* value);
  58 + char* data(void) { return m_data; }
  59 + void nullval(const char* value);
  60 + char* nullval(void) { return m_nulval; }
60 61  
61 62 private:
62 63 // Private methods
63 64 void init_members(void);
64 65 void copy_members(const GFitsTableBitCol& column);
65 66 void free_members(void);
66   - void save(void);
67 67 GFitsTableBitCol* clone(void) const;
68 68 std::string ascii_format(void) const;
69 69 std::string binary_format(void) const;
70 70 void alloc_data(void);
  71 + void release_data(void);
  72 + void alloc_nulval(const char* value);
71 73 void init_data(void);
72   - void fetch_data(void);
73 74 void* ptr_data(void) { return m_data; }
74 75 void* ptr_nulval(void) { return m_nulval; }
75 76  
... ...
include/GFitsTableBoolCol.hpp 0 → 100644
  1 +/***************************************************************************
  2 + * GFitsTableBoolCol.hpp - FITS table boolean column class *
  3 + * ----------------------------------------------------------------------- *
  4 + * copyright (C) 2010 by Jurgen Knodlseder *
  5 + * ----------------------------------------------------------------------- *
  6 + * *
  7 + * This program is free software; you can redistribute it and/or modify *
  8 + * it under the terms of the GNU General Public License as published by *
  9 + * the Free Software Foundation; either version 2 of the License, or *
  10 + * (at your option) any later version. *
  11 + * *
  12 + ***************************************************************************/
  13 +/**
  14 + * @file GFitsTableBoolCol.hpp
  15 + * @brief GFitsTableBoolCol class definition.
  16 + * @author J. Knodlseder
  17 + */
  18 +
  19 +#ifndef GFITSTABLEBOOLCOL_HPP
  20 +#define GFITSTABLEBOOLCOL_HPP
  21 +
  22 +/* __ Includes ___________________________________________________________ */
  23 +#include "GFitsTableCol.hpp"
  24 +
  25 +
  26 +/***********************************************************************//**
  27 + * @class GFitsTableBoolCol
  28 + *
  29 + * @brief Interface for FITS table Boolean column
  30 + *
  31 + * This class implements a FITS table Boolean column.
  32 + *
  33 + * @todo Each Bit is actually stored in one Byte. To save memory a more
  34 + * compact storage scheme should be implemented.
  35 + ***************************************************************************/
  36 +class GFitsTableBoolCol : public GFitsTableCol {
  37 +
  38 + // I/O friends
  39 + friend std::ostream& operator<< (std::ostream& os, const GFitsTableBoolCol& column);
  40 +
  41 +public:
  42 + // Constructors and destructors
  43 + GFitsTableBoolCol(void);
  44 + GFitsTableBoolCol(const std::string& name, const int& length,
  45 + const int& size = 1);
  46 + GFitsTableBoolCol(const GFitsTableBoolCol& column);
  47 + virtual ~GFitsTableBoolCol(void);
  48 +
  49 + // Operators
  50 + GFitsTableBoolCol& operator= (const GFitsTableBoolCol& column);
  51 + bool& operator() (const int& row, const int& inx = 0);
  52 + const bool& operator() (const int& row, const int& inx = 0) const;
  53 +
  54 + // Methods
  55 + std::string string(const int& row, const int& col = 0);
  56 + double real(const int& row, const int& col = 0);
  57 + int integer(const int& row, const int& col = 0);
  58 + bool* data(void) { return m_data; }
  59 + void nullval(const bool* value);
  60 + bool* nullval(void) { return m_nulval; }
  61 +
  62 +private:
  63 + // Private methods
  64 + void init_members(void);
  65 + void copy_members(const GFitsTableBoolCol& column);
  66 + void free_members(void);
  67 + void save(void);
  68 + GFitsTableBoolCol* clone(void) const;
  69 + std::string ascii_format(void) const;
  70 + std::string binary_format(void) const;
  71 + void alloc_data(void);
  72 + void release_data(void);
  73 + void alloc_nulval(const bool* value);
  74 + void init_data(void);
  75 + void fetch_data(void);
  76 + void alloc_buffer(void);
  77 + void free_buffer(void);
  78 + void* ptr_data(void) { return m_buffer; }
  79 + void* ptr_nulval(void) { return m_nulval; }
  80 +
  81 + // Private data area
  82 + bool* m_data; //!< Data area
  83 + char* m_buffer; //!< Data area for CFITSIO transfer
  84 + bool* m_nulval; //!< NULL value
  85 +};
  86 +
  87 +#endif /* GFITSTABLEBOOLCOL_HPP */
... ...
include/GFitsTableCol.hpp
... ... @@ -37,11 +37,11 @@ class GFitsTableCol {
37 37  
38 38 public:
39 39 // Constructors and destructors
40   - GFitsTableCol();
  40 + GFitsTableCol(void);
41 41 GFitsTableCol(const std::string& name, const int& length,
42 42 const int& number, const int& width);
43 43 GFitsTableCol(const GFitsTableCol& column);
44   - virtual ~GFitsTableCol();
  44 + virtual ~GFitsTableCol(void);
45 45  
46 46 // Operators
47 47 GFitsTableCol& operator= (const GFitsTableCol& column);
... ... @@ -81,20 +81,21 @@ protected:
81 81 __fitsfile m_fitsfile; //!< FITS file associated with column
82 82  
83 83 // Protected virtual methods
84   - virtual void save(void) = 0;
85 84 virtual GFitsTableCol* clone(void) const = 0;
86 85 virtual std::string ascii_format(void) const = 0;
87 86 virtual std::string binary_format(void) const = 0;
88 87 virtual void alloc_data(void) = 0;
89 88 virtual void init_data(void) = 0;
90   - virtual void fetch_data(void) = 0;
91 89 virtual void* ptr_data(void) = 0;
92 90 virtual void* ptr_nulval(void) = 0;
93 91  
94 92 // Protected methods
95   - void load_column(void);
96   - void save_column(void);
97   - void dump_column(std::ostream& os, void* data) const;
  93 + virtual void save(void);
  94 + virtual void fetch_data(void);
  95 + virtual void load_column(void);
  96 + virtual void save_column(void);
  97 + virtual void dump_column(std::ostream& os, void* data) const;
  98 + virtual int offset(const int& row, const int& inx) const;
98 99  
99 100 private:
100 101 // Private methods
... ...
include/GFitsTableDblCol.hpp deleted
1   -/***************************************************************************
2   - * GFitsTableDblCol.hpp - FITS table double column class *
3   - * ----------------------------------------------------------------------- *
4   - * copyright (C) 2008 by Jurgen Knodlseder *
5   - * ----------------------------------------------------------------------- *
6   - * *
7   - * This program is free software; you can redistribute it and/or modify *
8   - * it under the terms of the GNU General Public License as published by *
9   - * the Free Software Foundation; either version 2 of the License, or *
10   - * (at your option) any later version. *
11   - * *
12   - ***************************************************************************/
13   -/**
14   - * @file GFitsTableDblCol.hpp
15   - * @brief GFitsTableDblCol class definition.
16   - * @author J. Knodlseder
17   - */
18   -
19   -#ifndef GFITSTABLEDBLCOL_HPP
20   -#define GFITSTABLEDBLCOL_HPP
21   -
22   -/* __ Includes ___________________________________________________________ */
23   -#include "GFitsTableCol.hpp"
24   -
25   -
26   -/***********************************************************************//**
27   - * @class GFitsTableDblCol
28   - *
29   - * @brief Interface for FITS table double precision column
30   - *
31   - * This class implements a FITS table double precision column.
32   - ***************************************************************************/
33   -class GFitsTableDblCol : public GFitsTableCol {
34   -
35   - // I/O friends
36   - friend std::ostream& operator<< (std::ostream& os, const GFitsTableDblCol& column);
37   -
38   -public:
39   - // Constructors and destructors
40   - GFitsTableDblCol();
41   - GFitsTableDblCol(const std::string& name, const int& length,
42   - const int& size = 1);
43   - GFitsTableDblCol(const GFitsTableDblCol& column);
44   - virtual ~GFitsTableDblCol();
45   -
46   - // Operators
47   - GFitsTableDblCol& operator= (const GFitsTableDblCol& column);
48   - double& operator() (const int& row, const int& inx = 0);
49   - const double& operator() (const int& row, const int& inx = 0) const;
50   -
51   - // Methods
52   - std::string string(const int& row, const int& inx = 0);
53   - double real(const int& row, const int& inx = 0);
54   - int integer(const int& row, const int& inx = 0);
55   - double* data(void);
56   - void set_nullval(const double* value);
57   -
58   -private:
59   - // Private methods
60   - void init_members(void);
61   - void copy_members(const GFitsTableDblCol& column);
62   - void free_members(void);
63   - void save(void);
64   - GFitsTableDblCol* clone(void) const;
65   - std::string ascii_format(void) const;
66   - std::string binary_format(void) const;
67   - void alloc_data(void);
68   - void init_data(void);
69   - void fetch_data(void);
70   - void* ptr_data(void) { return m_data; }
71   - void* ptr_nulval(void) { return m_nulval; }
72   -
73   - // Private data area
74   - double* m_data; //!< Data area
75   - double* m_nulval; //!< NULL value
76   -};
77   -
78   -#endif /* GFITSTABLEDBLCOL_HPP */
include/GFitsTableDoubleCol.hpp 0 → 100644
  1 +/***************************************************************************
  2 + * GFitsTableDoubleCol.hpp - FITS table double column class *
  3 + * ----------------------------------------------------------------------- *
  4 + * copyright (C) 2010 by Jurgen Knodlseder *
  5 + * ----------------------------------------------------------------------- *
  6 + * *
  7 + * This program is free software; you can redistribute it and/or modify *
  8 + * it under the terms of the GNU General Public License as published by *
  9 + * the Free Software Foundation; either version 2 of the License, or *
  10 + * (at your option) any later version. *
  11 + * *
  12 + ***************************************************************************/
  13 +/**
  14 + * @file GFitsTableDoubleCol.hpp
  15 + * @brief GFitsTableDoubleCol class definition.
  16 + * @author J. Knodlseder
  17 + */
  18 +
  19 +#ifndef GFITSTABLEDOUBLECOL_HPP
  20 +#define GFITSTABLEDOUBLECOL_HPP
  21 +
  22 +/* __ Includes ___________________________________________________________ */
  23 +#include "GFitsTableCol.hpp"
  24 +
  25 +
  26 +/***********************************************************************//**
  27 + * @class GFitsTableDoubleCol
  28 + *
  29 + * @brief Interface for FITS table double column
  30 + *
  31 + * This class implements a FITS table double column.
  32 + ***************************************************************************/
  33 +class GFitsTableDoubleCol : public GFitsTableCol {
  34 +
  35 + // I/O friends
  36 + friend std::ostream& operator<< (std::ostream& os, const GFitsTableDoubleCol& column);
  37 +
  38 +public:
  39 + // Constructors and destructors
  40 + GFitsTableDoubleCol(void);
  41 + GFitsTableDoubleCol(const std::string& name, const int& length,
  42 + const int& size = 1);
  43 + GFitsTableDoubleCol(const GFitsTableDoubleCol& column);
  44 + virtual ~GFitsTableDoubleCol(void);
  45 +
  46 + // Operators
  47 + GFitsTableDoubleCol& operator= (const GFitsTableDoubleCol& column);
  48 + double& operator() (const int& row, const int& inx = 0);
  49 + const double& operator() (const int& row, const int& inx = 0) const;
  50 +
  51 + // Methods
  52 + std::string string(const int& row, const int& col = 0);
  53 + double real(const int& row, const int& col = 0);
  54 + int integer(const int& row, const int& col = 0);
  55 + double* data(void) { return m_data; }
  56 + void nullval(const double* value);
  57 + double* nullval(void) { return m_nulval; }
  58 +
  59 +private:
  60 + // Private methods
  61 + void init_members(void);
  62 + void copy_members(const GFitsTableDoubleCol& column);
  63 + void free_members(void);
  64 + GFitsTableDoubleCol* clone(void) const;
  65 + std::string ascii_format(void) const;
  66 + std::string binary_format(void) const;
  67 + void alloc_data(void);
  68 + void release_data(void);
  69 + void alloc_nulval(const double* value);
  70 + void init_data(void);
  71 + void* ptr_data(void) { return m_data; }
  72 + void* ptr_nulval(void) { return m_nulval; }
  73 +
  74 + // Private data area
  75 + double* m_data; //!< Data vector
  76 + double* m_nulval; //!< NULL value
  77 +};
  78 +
  79 +#endif /* GFITSTABLEDOUBLECOL_HPP */
... ...
include/GFitsTableFloatCol.hpp 0 → 100644
  1 +/***************************************************************************
  2 + * GFitsTableFloatCol.hpp - FITS table float column class *
  3 + * ----------------------------------------------------------------------- *
  4 + * copyright (C) 2010 by Jurgen Knodlseder *
  5 + * ----------------------------------------------------------------------- *
  6 + * *
  7 + * This program is free software; you can redistribute it and/or modify *
  8 + * it under the terms of the GNU General Public License as published by *
  9 + * the Free Software Foundation; either version 2 of the License, or *
  10 + * (at your option) any later version. *
  11 + * *
  12 + ***************************************************************************/
  13 +/**
  14 + * @file GFitsTableFloatCol.hpp
  15 + * @brief GFitsTableFloatCol class definition.
  16 + * @author J. Knodlseder
  17 + */
  18 +
  19 +#ifndef GFITSTABLEFLOATCOL_HPP
  20 +#define GFITSTABLEFLOATCOL_HPP
  21 +
  22 +/* __ Includes ___________________________________________________________ */
  23 +#include "GFitsTableCol.hpp"
  24 +
  25 +
  26 +/***********************************************************************//**
  27 + * @class GFitsTableFloatCol
  28 + *
  29 + * @brief Interface for FITS table float column
  30 + *
  31 + * This class implements a FITS table float column.
  32 + ***************************************************************************/
  33 +class GFitsTableFloatCol : public GFitsTableCol {
  34 +
  35 + // I/O friends
  36 + friend std::ostream& operator<< (std::ostream& os, const GFitsTableFloatCol& column);
  37 +
  38 +public:
  39 + // Constructors and destructors
  40 + GFitsTableFloatCol(void);
  41 + GFitsTableFloatCol(const std::string& name, const int& length,
  42 + const int& size = 1);
  43 + GFitsTableFloatCol(const GFitsTableFloatCol& column);
  44 + virtual ~GFitsTableFloatCol(void);
  45 +
  46 + // Operators
  47 + GFitsTableFloatCol& operator= (const GFitsTableFloatCol& column);
  48 + float& operator() (const int& row, const int& inx = 0);
  49 + const float& operator() (const int& row, const int& inx = 0) const;
  50 +
  51 + // Methods
  52 + std::string string(const int& row, const int& col = 0);
  53 + double real(const int& row, const int& col = 0);
  54 + int integer(const int& row, const int& col = 0);
  55 + float* data(void) { return m_data; }
  56 + void nullval(const float* value);
  57 + float* nullval(void) { return m_nulval; }
  58 +
  59 +private:
  60 + // Private methods
  61 + void init_members(void);
  62 + void copy_members(const GFitsTableFloatCol& column);
  63 + void free_members(void);
  64 + GFitsTableFloatCol* clone(void) const;
  65 + std::string ascii_format(void) const;
  66 + std::string binary_format(void) const;
  67 + void alloc_data(void);
  68 + void release_data(void);
  69 + void alloc_nulval(const float* value);
  70 + void init_data(void);
  71 + void* ptr_data(void) { return m_data; }
  72 + void* ptr_nulval(void) { return m_nulval; }
  73 +
  74 + // Private data area
  75 + float* m_data; //!< Data vector
  76 + float* m_nulval; //!< NULL value
  77 +};
  78 +
  79 +#endif /* GFITSTABLEFLOATCOL_HPP */
... ...
include/GFitsTableFltCol.hpp deleted
1   -/***************************************************************************
2   - * GFitsTableFltCol.hpp - FITS table float column class *
3   - * ----------------------------------------------------------------------- *
4   - * copyright (C) 2008 by Jurgen Knodlseder *
5   - * ----------------------------------------------------------------------- *
6   - * *
7   - * This program is free software; you can redistribute it and/or modify *
8   - * it under the terms of the GNU General Public License as published by *
9   - * the Free Software Foundation; either version 2 of the License, or *
10   - * (at your option) any later version. *
11   - * *
12   - ***************************************************************************/
13   -/**
14   - * @file GFitsTableFltCol.hpp
15   - * @brief GFitsTableFltCol class definition.
16   - * @author J. Knodlseder
17   - */
18   -
19   -#ifndef GFITSTABLEFLTCOL_HPP
20   -#define GFITSTABLEFLTCOL_HPP
21   -
22   -/* __ Includes ___________________________________________________________ */
23   -#include "GFitsTableCol.hpp"
24   -
25   -
26   -/***********************************************************************//**
27   - * @class GFitsTableFltCol
28   - *
29   - * @brief Interface for FITS table floating point column
30   - *
31   - * This class implements a FITS table floating point column.
32   - ***************************************************************************/
33   -class GFitsTableFltCol : public GFitsTableCol {
34   -
35   - // I/O friends
36   - friend std::ostream& operator<< (std::ostream& os, const GFitsTableFltCol& column);
37   -
38   -public:
39   - // Constructors and destructors
40   - GFitsTableFltCol();
41   - GFitsTableFltCol(const std::string& name, const int& length,
42   - const int& size = 1);
43   - GFitsTableFltCol(const GFitsTableFltCol& column);
44   - virtual ~GFitsTableFltCol();
45   -
46   - // Operators
47   - GFitsTableFltCol& operator= (const GFitsTableFltCol& column);
48   - float& operator() (const int& row, const int& inx = 0);
49   - const float& operator() (const int& row, const int& inx = 0) const;
50   -
51   - // Methods
52   - std::string string(const int& row, const int& col = 0);
53   - double real(const int& row, const int& col = 0);
54   - int integer(const int& row, const int& col = 0);
55   - float* data(void);
56   - void set_nullval(const float* value);
57   -
58   -private:
59   - // Private methods
60   - void init_members(void);
61   - void copy_members(const GFitsTableFltCol& column);
62   - void free_members(void);
63   - void save(void);
64   - GFitsTableFltCol* clone(void) const;
65   - std::string ascii_format(void) const;
66   - std::string binary_format(void) const;
67   - void alloc_data(void);
68   - void init_data(void);
69   - void fetch_data(void);
70   - void* ptr_data(void) { return m_data; }
71   - void* ptr_nulval(void) { return m_nulval; }
72   -
73   - // Private data area
74   - float* m_data; //!< Data area
75   - float* m_nulval; //!< NULL value
76   -};
77   -
78   -#endif /* GFITSTABLEFLTCOL_HPP */
include/GFitsTableLlgCol.hpp deleted
1   -/***************************************************************************
2   - * GFitsTableLlgCol.hpp - FITS table long long column class *
3   - * ----------------------------------------------------------------------- *
4   - * copyright (C) 2010 by Jurgen Knodlseder *
5   - * ----------------------------------------------------------------------- *
6   - * *
7   - * This program is free software; you can redistribute it and/or modify *
8   - * it under the terms of the GNU General Public License as published by *
9   - * the Free Software Foundation; either version 2 of the License, or *
10   - * (at your option) any later version. *
11   - * *
12   - ***************************************************************************/
13   -/**
14   - * @file GFitsTableLlgCol.hpp
15   - * @brief GFitsTableLlgCol class definition.
16   - * @author J. Knodlseder
17   - */
18   -
19   -#ifndef GFITSTABLELLGCOL_HPP
20   -#define GFITSTABLELLGCOL_HPP
21   -
22   -/* __ Includes ___________________________________________________________ */
23   -#include "GFitsTableCol.hpp"
24   -
25   -
26   -/***********************************************************************//**
27   - * @class GFitsTableLlgCol
28   - *
29   - * @brief Interface for FITS table long long integer column
30   - *
31   - * This class implements a FITS table long long integer column.
32   - *
33   - * TODO: integer() method returns actually a int which may lead to an
34   - * overflow. Better return long long.
35   - ***************************************************************************/
36   -class GFitsTableLlgCol : public GFitsTableCol {
37   -
38   - // I/O friends
39   - friend std::ostream& operator<< (std::ostream& os, const GFitsTableLlgCol& column);
40   -
41   -public:
42   - // Constructors and destructors
43   - GFitsTableLlgCol(void);
44   - GFitsTableLlgCol(const std::string& name, const int& length,
45   - const int& size = 1);
46   - GFitsTableLlgCol(const GFitsTableLlgCol& column);
47   - virtual ~GFitsTableLlgCol(void);
48   -
49   - // Operators
50   - GFitsTableLlgCol& operator= (const GFitsTableLlgCol& column);
51   - long long& operator() (const int& row, const int& inx = 0);
52   - const long long& operator() (const int& row, const int& inx = 0) const;
53   -
54   - // Methods
55   - std::string string(const int& row, const int& col = 0);
56   - double real(const int& row, const int& col = 0);
57   - int integer(const int& row, const int& col = 0);
58   - long long* data(void);
59   - void set_nullval(const long long* value);
60   -
61   -private:
62   - // Private methods
63   - void init_members(void);
64   - void copy_members(const GFitsTableLlgCol& column);
65   - void free_members(void);
66   - void save(void);
67   - GFitsTableLlgCol* clone(void) const;
68   - std::string ascii_format(void) const;
69   - std::string binary_format(void) const;
70   - void alloc_data(void);
71   - void init_data(void);
72   - void fetch_data(void);
73   - void* ptr_data(void) { return m_data; }
74   - void* ptr_nulval(void) { return m_nulval; }
75   -
76   - // Private data area
77   - long long* m_data; //!< Data area
78   - long long* m_nulval; //!< NULL value
79   -};
80   -
81   -#endif /* GFITSTABLELLGCOL_HPP */
include/GFitsTableLngCol.hpp deleted
1   -/***************************************************************************
2   - * GFitsTableLngCol.hpp - FITS table long column class *
3   - * ----------------------------------------------------------------------- *
4   - * copyright (C) 2008 by Jurgen Knodlseder *
5   - * ----------------------------------------------------------------------- *
6   - * *
7   - * This program is free software; you can redistribute it and/or modify *
8   - * it under the terms of the GNU General Public License as published by *
9   - * the Free Software Foundation; either version 2 of the License, or *
10   - * (at your option) any later version. *
11   - * *
12   - ***************************************************************************/
13   -/**
14   - * @file GFitsTableLngCol.hpp
15   - * @brief GFitsTableLngCol class definition.
16   - * @author J. Knodlseder
17   - */
18   -
19   -#ifndef GFITSTABLELNGCOL_HPP
20   -#define GFITSTABLELNGCOL_HPP
21   -
22   -/* __ Includes ___________________________________________________________ */
23   -#include "GFitsTableCol.hpp"
24   -
25   -
26   -/***********************************************************************//**
27   - * @class GFitsTableLngCol
28   - *
29   - * @brief Interface for FITS table long integer column
30   - *
31   - * This class implements a FITS table long integer column.
32   - ***************************************************************************/
33   -class GFitsTableLngCol : public GFitsTableCol {
34   -
35   - // I/O friends
36   - friend std::ostream& operator<< (std::ostream& os, const GFitsTableLngCol& column);
37   -
38   -public:
39   - // Constructors and destructors
40   - GFitsTableLngCol();
41   - GFitsTableLngCol(const std::string& name, const int& length,
42   - const int& size = 1);
43   - GFitsTableLngCol(const GFitsTableLngCol& column);
44   - virtual ~GFitsTableLngCol();
45   -
46   - // Operators
47   - GFitsTableLngCol& operator= (const GFitsTableLngCol& column);
48   - long& operator() (const int& row, const int& inx = 0);
49   - const long& operator() (const int& row, const int& inx = 0) const;
50   -
51   - // Methods
52   - std::string string(const int& row, const int& col = 0);
53   - double real(const int& row, const int& col = 0);
54   - int integer(const int& row, const int& col = 0);
55   - long* data(void);
56   - void set_nullval(const long* value);
57   -
58   -private:
59   - // Private methods
60   - void init_members(void);
61   - void copy_members(const GFitsTableLngCol& column);
62   - void free_members(void);
63   - void save(void);
64   - GFitsTableLngCol* clone(void) const;
65   - std::string ascii_format(void) const;
66   - std::string binary_format(void) const;
67   - void alloc_data(void);
68   - void init_data(void);
69   - void fetch_data(void);
70   - void* ptr_data(void) { return m_data; }
71   - void* ptr_nulval(void) { return m_nulval; }
72   -
73   - // Private data area
74   - long* m_data; //!< Data area
75   - long* m_nulval; //!< NULL value
76   -};
77   -
78   -#endif /* GFITSTABLELNGCOL_HPP */
include/GFitsTableLogCol.hpp deleted
1   -/***************************************************************************
2   - * GFitsTableLogCol.hpp - FITS table logical column class *
3   - * ----------------------------------------------------------------------- *
4   - * copyright (C) 2008 by Jurgen Knodlseder *
5   - * ----------------------------------------------------------------------- *
6   - * *
7   - * This program is free software; you can redistribute it and/or modify *
8   - * it under the terms of the GNU General Public License as published by *
9   - * the Free Software Foundation; either version 2 of the License, or *
10   - * (at your option) any later version. *
11   - * *
12   - ***************************************************************************/
13   -/**
14   - * @file GFitsTableLogCol.hpp
15   - * @brief GFitsTableLogCol class definition.
16   - * @author J. Knodlseder
17   - */
18   -
19   -#ifndef GFITSTABLELOGCOL_HPP
20   -#define GFITSTABLELOGCOL_HPP
21   -
22   -/* __ Includes ___________________________________________________________ */
23   -//#include "GFitsCfitsio.hpp"
24   -#include "GFitsTableCol.hpp"
25   -
26   -
27   -/***********************************************************************//**
28   - * @class GFitsTableLogCol
29   - *
30   - * @brief Interface for FITS table logical column
31   - *
32   - * This class implements a FITS table logical column.
33   - ***************************************************************************/
34   -class GFitsTableLogCol : public GFitsTableCol {
35   -
36   - // I/O friends
37   - friend std::ostream& operator<< (std::ostream& os, const GFitsTableLogCol& column);
38   -
39   -public:
40   - // Constructors and destructors
41   - GFitsTableLogCol();
42   - GFitsTableLogCol(const std::string& name, const int& length,
43   - const int& size = 1);
44   - GFitsTableLogCol(const GFitsTableLogCol& column);
45   - virtual ~GFitsTableLogCol();
46   -
47   - // Operators
48   - GFitsTableLogCol& operator= (const GFitsTableLogCol& column);
49   - char& operator() (const int& row, const int& inx = 0);
50   - const char& operator() (const int& row, const int& inx = 0) const;
51   -
52   - // Methods
53   - std::string string(const int& row, const int& col = 0);
54   - double real(const int& row, const int& col = 0);
55   - int integer(const int& row, const int& col = 0);
56   - char* data(void);
57   - void set_nullval(const char* value);
58   -
59   -private:
60   - // Private methods
61   - void init_members(void);
62   - void copy_members(const GFitsTableLogCol& column);
63   - void free_members(void);
64   - void save(void);
65   - GFitsTableLogCol* clone(void) const;
66   - std::string ascii_format(void) const;
67   - std::string binary_format(void) const;
68   - void alloc_data(void);
69   - void init_data(void);
70   - void fetch_data(void);
71   - void* ptr_data(void) { return m_data; }
72   - void* ptr_nulval(void) { return m_nulval; }
73   -
74   - // Private data area
75   - char* m_data; //!< Data area
76   - char* m_nulval; //!< NULL value
77   -};
78   -
79   -#endif /* GFITSTABLELOGCOL_HPP */
include/GFitsTableLongCol.hpp 0 → 100644
  1 +/***************************************************************************
  2 + * GFitsTableLongCol.hpp - FITS table long column class *
  3 + * ----------------------------------------------------------------------- *
  4 + * copyright (C) 2010 by Jurgen Knodlseder *
  5 + * ----------------------------------------------------------------------- *
  6 + * *
  7 + * This program is free software; you can redistribute it and/or modify *
  8 + * it under the terms of the GNU General Public License as published by *
  9 + * the Free Software Foundation; either version 2 of the License, or *
  10 + * (at your option) any later version. *
  11 + * *
  12 + ***************************************************************************/
  13 +/**
  14 + * @file GFitsTableLongCol.hpp
  15 + * @brief GFitsTableLongCol class definition.
  16 + * @author J. Knodlseder
  17 + */
  18 +
  19 +#ifndef GFITSTABLELONGCOL_HPP
  20 +#define GFITSTABLELONGCOL_HPP
  21 +
  22 +/* __ Includes ___________________________________________________________ */
  23 +#include "GFitsTableCol.hpp"
  24 +
  25 +
  26 +/***********************************************************************//**
  27 + * @class GFitsTableLongCol
  28 + *
  29 + * @brief Interface for FITS table long integer column
  30 + *
  31 + * This class implements a FITS table long integer column.
  32 + ***************************************************************************/
  33 +class GFitsTableLongCol : public GFitsTableCol {
  34 +
  35 + // I/O friends
  36 + friend std::ostream& operator<< (std::ostream& os, const GFitsTableLongCol& column);
  37 +
  38 +public:
  39 + // Constructors and destructors
  40 + GFitsTableLongCol(void);
  41 + GFitsTableLongCol(const std::string& name, const int& length,
  42 + const int& size = 1);
  43 + GFitsTableLongCol(const GFitsTableLongCol& column);
  44 + virtual ~GFitsTableLongCol(void);
  45 +
  46 + // Operators
  47 + GFitsTableLongCol& operator= (const GFitsTableLongCol& column);
  48 + long& operator() (const int& row, const int& inx = 0);
  49 + const long& operator() (const int& row, const int& inx = 0) const;
  50 +
  51 + // Methods
  52 + std::string string(const int& row, const int& col = 0);
  53 + double real(const int& row, const int& col = 0);
  54 + int integer(const int& row, const int& col = 0);
  55 + long* data(void) { return m_data; }
  56 + void nullval(const long* value);
  57 + long* nullval(void) { return m_nulval; }
  58 +
  59 +private:
  60 + // Private methods
  61 + void init_members(void);
  62 + void copy_members(const GFitsTableLongCol& column);
  63 + void free_members(void);
  64 + GFitsTableLongCol* clone(void) const;
  65 + std::string ascii_format(void) const;
  66 + std::string binary_format(void) const;
  67 + void alloc_data(void);
  68 + void release_data(void);
  69 + void alloc_nulval(const long* value);
  70 + void init_data(void);
  71 + void* ptr_data(void) { return m_data; }
  72 + void* ptr_nulval(void) { return m_nulval; }
  73 +
  74 + // Private data area
  75 + long* m_data; //!< Data vector
  76 + long* m_nulval; //!< NULL value
  77 +};
  78 +
  79 +#endif /* GFITSTABLELONGCOL_HPP */
... ...
include/GFitsTableLongLongCol.hpp 0 → 100644
  1 +/***************************************************************************
  2 + * GFitsTableLongLongCol.hpp - FITS table long long column class *
  3 + * ----------------------------------------------------------------------- *
  4 + * copyright (C) 2010 by Jurgen Knodlseder *
  5 + * ----------------------------------------------------------------------- *
  6 + * *
  7 + * This program is free software; you can redistribute it and/or modify *
  8 + * it under the terms of the GNU General Public License as published by *
  9 + * the Free Software Foundation; either version 2 of the License, or *
  10 + * (at your option) any later version. *
  11 + * *
  12 + ***************************************************************************/
  13 +/**
  14 + * @file GFitsTableLongLongCol.hpp
  15 + * @brief GFitsTableLongLongCol class definition.
  16 + * @author J. Knodlseder
  17 + */
  18 +
  19 +#ifndef GFITSTABLELONGLONGCOL_HPP
  20 +#define GFITSTABLELONGLONGCOL_HPP
  21 +
  22 +/* __ Includes ___________________________________________________________ */
  23 +#include "GFitsTableCol.hpp"
  24 +
  25 +
  26 +/***********************************************************************//**
  27 + * @class GFitsTableLongLongCol
  28 + *
  29 + * @brief Interface for FITS table long integer column
  30 + *
  31 + * This class implements a FITS table long integer column.
  32 + ***************************************************************************/
  33 +class GFitsTableLongLongCol : public GFitsTableCol {
  34 +
  35 + // I/O friends
  36 + friend std::ostream& operator<< (std::ostream& os, const GFitsTableLongLongCol& column);
  37 +
  38 +public:
  39 + // Constructors and destructors
  40 + GFitsTableLongLongCol(void);
  41 + GFitsTableLongLongCol(const std::string& name, const int& length,
  42 + const int& size = 1);
  43 + GFitsTableLongLongCol(const GFitsTableLongLongCol& column);
  44 + virtual ~GFitsTableLongLongCol(void);
  45 +
  46 + // Operators
  47 + GFitsTableLongLongCol& operator= (const GFitsTableLongLongCol& column);
  48 + long long& operator() (const int& row, const int& inx = 0);
  49 + const long long& operator() (const int& row, const int& inx = 0) const;
  50 +
  51 + // Methods
  52 + std::string string(const int& row, const int& col = 0);
  53 + double real(const int& row, const int& col = 0);
  54 + int integer(const int& row, const int& col = 0);
  55 + long long* data(void) { return m_data; }
  56 + void nullval(const long long* value);
  57 + long long* nullval(void) { return m_nulval; }
  58 +
  59 +private:
  60 + // Private methods
  61 + void init_members(void);
  62 + void copy_members(const GFitsTableLongLongCol& column);
  63 + void free_members(void);
  64 + GFitsTableLongLongCol* clone(void) const;
  65 + std::string ascii_format(void) const;
  66 + std::string binary_format(void) const;
  67 + void alloc_data(void);
  68 + void release_data(void);
  69 + void alloc_nulval(const long long* value);
  70 + void init_data(void);
  71 + void* ptr_data(void) { return m_data; }
  72 + void* ptr_nulval(void) { return m_nulval; }
  73 +
  74 + // Private data area
  75 + long long* m_data; //!< Data vector
  76 + long long* m_nulval; //!< NULL value
  77 +};
  78 +
  79 +#endif /* GFITSTABLELONGLONGCOL_HPP */
... ...
include/GFitsTableShtCol.hpp renamed to include/GFitsTableShortCol.hpp
1 1 /***************************************************************************
2   - * GFitsTableShtCol.hpp - FITS table short column class *
  2 + * GFitsTableShortCol.hpp - FITS table short column class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2008 by Jurgen Knodlseder *
  4 + * copyright (C) 2010 by Jurgen Knodlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software; you can redistribute it and/or modify *
... ... @@ -11,68 +11,69 @@
11 11 * *
12 12 ***************************************************************************/
13 13 /**
14   - * @file GFitsTableShtCol.hpp
15   - * @brief GFitsTableShtCol class definition.
  14 + * @file GFitsTableShortCol.hpp
  15 + * @brief GFitsTableShortCol class definition.
16 16 * @author J. Knodlseder
17 17 */
18 18  
19   -#ifndef GFITSTABLESHTCOL_HPP
20   -#define GFITSTABLESHTCOL_HPP
  19 +#ifndef GFITSTABLESHORTCOL_HPP
  20 +#define GFITSTABLESHORTCOL_HPP
21 21  
22 22 /* __ Includes ___________________________________________________________ */
23 23 #include "GFitsTableCol.hpp"
24 24  
25 25  
26 26 /***********************************************************************//**
27   - * @class GFitsTableShtCol
  27 + * @class GFitsTableShortCol
28 28 *
29 29 * @brief Interface for FITS table short integer column
30 30 *
31 31 * This class implements a FITS table short integer column.
32 32 ***************************************************************************/
33   -class GFitsTableShtCol : public GFitsTableCol {
  33 +class GFitsTableShortCol : public GFitsTableCol {
34 34  
35 35 // I/O friends
36   - friend std::ostream& operator<< (std::ostream& os, const GFitsTableShtCol& column);
  36 + friend std::ostream& operator<< (std::ostream& os, const GFitsTableShortCol& column);
37 37  
38 38 public:
39 39 // Constructors and destructors
40   - GFitsTableShtCol();
41   - GFitsTableShtCol(const std::string& name, const int& length,
42   - const int& size = 1);
43   - GFitsTableShtCol(const GFitsTableShtCol& column);
44   - virtual ~GFitsTableShtCol();
  40 + GFitsTableShortCol(void);
  41 + GFitsTableShortCol(const std::string& name, const int& length,
  42 + const int& size = 1);
  43 + GFitsTableShortCol(const GFitsTableShortCol& column);
  44 + virtual ~GFitsTableShortCol(void);
45 45  
46 46 // Operators
47   - GFitsTableShtCol& operator= (const GFitsTableShtCol& column);
48   - short& operator() (const int& row, const int& inx = 0);
49   - const short& operator() (const int& row, const int& inx = 0) const;
  47 + GFitsTableShortCol& operator= (const GFitsTableShortCol& column);
  48 + short& operator() (const int& row, const int& inx = 0);
  49 + const short& operator() (const int& row, const int& inx = 0) const;
50 50  
51 51 // Methods
52 52 std::string string(const int& row, const int& col = 0);
53 53 double real(const int& row, const int& col = 0);
54 54 int integer(const int& row, const int& col = 0);
55   - short* data(void);
56   - void set_nullval(const short* value);
  55 + short* data(void) { return m_data; }
  56 + void nullval(const short* value);
  57 + short* nullval(void) { return m_nulval; }
57 58  
58 59 private:
59 60 // Private methods
60   - void init_members(void);
61   - void copy_members(const GFitsTableShtCol& column);
62   - void free_members(void);
63   - void save(void);
64   - GFitsTableShtCol* clone(void) const;
65   - std::string ascii_format(void) const;
66   - std::string binary_format(void) const;
67   - void alloc_data(void);
68   - void init_data(void);
69   - void fetch_data(void);
70   - void* ptr_data(void) { return m_data; }
71   - void* ptr_nulval(void) { return m_nulval; }
  61 + void init_members(void);
  62 + void copy_members(const GFitsTableShortCol& column);
  63 + void free_members(void);
  64 + GFitsTableShortCol* clone(void) const;
  65 + std::string ascii_format(void) const;
  66 + std::string binary_format(void) const;
  67 + void alloc_data(void);
  68 + void release_data(void);
  69 + void alloc_nulval(const short* value);
  70 + void init_data(void);
  71 + void* ptr_data(void) { return m_data; }
  72 + void* ptr_nulval(void) { return m_nulval; }
72 73  
73 74 // Private data area
74   - short* m_data; //!< Data area
  75 + short* m_data; //!< Data vector
75 76 short* m_nulval; //!< NULL value
76 77 };
77 78  
78   -#endif /* GFITSTABLESHTCOL_HPP */
  79 +#endif /* GFITSTABLESHORTCOL_HPP */
... ...
include/GFitsTableStrCol.hpp renamed to include/GFitsTableStringCol.hpp
1 1 /***************************************************************************
2   - * GFitsTableStrCol.hpp - FITS table string column class *
  2 + * GFitsTableStringCol.hpp - FITS table string column class *
3 3 * ----------------------------------------------------------------------- *
4 4 * copyright (C) 2008-2010 by Jurgen Knodlseder *
5 5 * ----------------------------------------------------------------------- *
... ... @@ -11,66 +11,69 @@
11 11 * *
12 12 ***************************************************************************/
13 13 /**
14   - * @file GFitsTableStrCol.hpp
15   - * @brief GFitsTableStrCol class definition.
  14 + * @file GFitsTableStringCol.hpp
  15 + * @brief GFitsTableStringCol class definition.
16 16 * @author J. Knodlseder
17 17 */
18 18  
19   -#ifndef GFITSTABLESTRCOL_HPP
20   -#define GFITSTABLESTRCOL_HPP
  19 +#ifndef GFITSTABLESTRINGCOL_HPP
  20 +#define GFITSTABLESTRINGCOL_HPP
21 21  
22 22 /* __ Includes ___________________________________________________________ */
23 23 #include "GFitsTableCol.hpp"
24 24  
25 25  
26 26 /***********************************************************************//**
27   - * @class GFitsTableStrCol
  27 + * @class GFitsTableStringCol
28 28 *
29 29 * @brief Interface for FITS table string column
30 30 *
31 31 * This class implements a FITS table string column.
32 32 ***************************************************************************/
33   -class GFitsTableStrCol : public GFitsTableCol {
  33 +class GFitsTableStringCol : public GFitsTableCol {
34 34  
35 35 // I/O friends
36   - friend std::ostream& operator<< (std::ostream& os, const GFitsTableStrCol& column);
  36 + friend std::ostream& operator<< (std::ostream& os, const GFitsTableStringCol& column);
37 37  
38 38 public:
39 39 // Constructors and destructors
40   - GFitsTableStrCol();
41   - GFitsTableStrCol(const std::string& name, const int& length,
42   - const int& width, const int& size = 1);
43   - GFitsTableStrCol(const GFitsTableStrCol& column);
44   - ~GFitsTableStrCol();
  40 + GFitsTableStringCol(void);
  41 + GFitsTableStringCol(const std::string& name, const int& length,
  42 + const int& width, const int& size = 1);
  43 + GFitsTableStringCol(const GFitsTableStringCol& column);
  44 + virtual ~GFitsTableStringCol(void);
45 45  
46 46 // Operators
47   - GFitsTableStrCol& operator= (const GFitsTableStrCol& column);
48   - std::string& operator() (const int& row, const int& inx = 0);
49   - const std::string& operator() (const int& row, const int& inx = 0) const;
  47 + GFitsTableStringCol& operator= (const GFitsTableStringCol& column);
  48 + std::string& operator() (const int& row, const int& inx = 0);
  49 + const std::string& operator() (const int& row, const int& inx = 0) const;
50 50  
51 51 // Methods
52 52 std::string string(const int& row, const int& col = 0);
53 53 double real(const int& row, const int& col = 0);
54 54 int integer(const int& row, const int& col = 0);
55   - std::string* data(void);
56   - void set_nullval(const std::string& string);
  55 + std::string* data(void) { return m_data; }
  56 + void nullval(const std::string& value);
  57 + char* nullval(void) { return m_nulval; }
57 58  
58 59 private:
59 60 // Private methods
60   - void init_members(void);
61   - void copy_members(const GFitsTableStrCol& column);
62   - void free_members(void);
63   - void save(void);
64   - GFitsTableStrCol* clone(void) const;
65   - std::string ascii_format(void) const;
66   - std::string binary_format(void) const;
67   - void alloc_data(void);
68   - void init_data(void);
69   - void fetch_data(void);
70   - void* ptr_data(void) { return m_buffer; }
71   - void* ptr_nulval(void) { return m_nulval; }
72   - void alloc_buffer(void);
73   - void free_buffer(void);
  61 + void init_members(void);
  62 + void copy_members(const GFitsTableStringCol& column);
  63 + void free_members(void);
  64 + void save(void);
  65 + GFitsTableStringCol* clone(void) const;
  66 + std::string ascii_format(void) const;
  67 + std::string binary_format(void) const;
  68 + void alloc_data(void);
  69 + void release_data(void);
  70 + void alloc_nulval(const std::string& value);
  71 + void init_data(void);
  72 + void fetch_data(void);
  73 + void alloc_buffer(void);
  74 + void free_buffer(void);
  75 + void* ptr_data(void) { return m_buffer; }
  76 + void* ptr_nulval(void) { return m_nulval; }
74 77  
75 78 // Private data area
76 79 std::string* m_data; //!< Data area
... ... @@ -78,4 +81,4 @@ private:
78 81 char* m_nulval; //!< NULL string
79 82 };
80 83  
81   -#endif /* GFITSTABLESTRCOL_HPP */
  84 +#endif /* GFITSTABLESTRINGCOL_HPP */
... ...
include/GFitsTableULgCol.hpp renamed to include/GFitsTableULongCol.hpp
1 1 /***************************************************************************
2   - * GFitsTableULgCol.hpp - FITS table unsigned long column class *
  2 + * GFitsTableULongCol.hpp - FITS table unsigned long column class *
3 3 * ----------------------------------------------------------------------- *
4 4 * copyright (C) 2010 by Jurgen Knodlseder *
5 5 * ----------------------------------------------------------------------- *
... ... @@ -11,40 +11,40 @@
11 11 * *
12 12 ***************************************************************************/
13 13 /**
14   - * @file GFitsTableULgCol.hpp
15   - * @brief GFitsTableULgCol class definition.
  14 + * @file GFitsTableULongCol.hpp
  15 + * @brief GFitsTableULongCol class definition.
16 16 * @author J. Knodlseder
17 17 */
18 18  
19   -#ifndef GFITSTABLEULGCOL_HPP
20   -#define GFITSTABLEULGCOL_HPP
  19 +#ifndef GFITSTABLEULONGCOL_HPP
  20 +#define GFITSTABLEULONGCOL_HPP
21 21  
22 22 /* __ Includes ___________________________________________________________ */
23 23 #include "GFitsTableCol.hpp"
24 24  
25 25  
26 26 /***********************************************************************//**
27   - * @class GFitsTableULgCol
  27 + * @class GFitsTableULongCol
28 28 *
29 29 * @brief Interface for FITS table unsigned long integer column
30 30 *
31 31 * This class implements a FITS table unsigned long integer column.
32 32 ***************************************************************************/
33   -class GFitsTableULgCol : public GFitsTableCol {
  33 +class GFitsTableULongCol : public GFitsTableCol {
34 34  
35 35 // I/O friends
36   - friend std::ostream& operator<< (std::ostream& os, const GFitsTableULgCol& column);
  36 + friend std::ostream& operator<< (std::ostream& os, const GFitsTableULongCol& column);
37 37  
38 38 public:
39 39 // Constructors and destructors
40   - GFitsTableULgCol();
41   - GFitsTableULgCol(const std::string& name, const int& length,
42   - const int& size = 1);
43   - GFitsTableULgCol(const GFitsTableULgCol& column);
44   - virtual ~GFitsTableULgCol();
  40 + GFitsTableULongCol(void);
  41 + GFitsTableULongCol(const std::string& name, const int& length,
  42 + const int& size = 1);
  43 + GFitsTableULongCol(const GFitsTableULongCol& column);
  44 + virtual ~GFitsTableULongCol(void);
45 45  
46 46 // Operators
47   - GFitsTableULgCol& operator= (const GFitsTableULgCol& column);
  47 + GFitsTableULongCol& operator= (const GFitsTableULongCol& column);
48 48 unsigned long& operator() (const int& row, const int& inx = 0);
49 49 const unsigned long& operator() (const int& row, const int& inx = 0) const;
50 50  
... ... @@ -52,27 +52,28 @@ public:
52 52 std::string string(const int& row, const int& col = 0);
53 53 double real(const int& row, const int& col = 0);
54 54 int integer(const int& row, const int& col = 0);
55   - unsigned long* data(void);
56   - void set_nullval(const unsigned long* value);
  55 + unsigned long* data(void) { return m_data; }
  56 + void nullval(const unsigned long* value);
  57 + unsigned long* nullval(void) { return m_nulval; }
57 58  
58 59 private:
59 60 // Private methods
60   - void init_members(void);
61   - void copy_members(const GFitsTableULgCol& column);
62   - void free_members(void);
63   - void save(void);
64   - GFitsTableULgCol* clone(void) const;
65   - std::string ascii_format(void) const;
66   - std::string binary_format(void) const;
67   - void alloc_data(void);
68   - void init_data(void);
69   - void fetch_data(void);
70   - void* ptr_data(void) { return m_data; }
71   - void* ptr_nulval(void) { return m_nulval; }
  61 + void init_members(void);
  62 + void copy_members(const GFitsTableULongCol& column);
  63 + void free_members(void);
  64 + GFitsTableULongCol* clone(void) const;
  65 + std::string ascii_format(void) const;
  66 + std::string binary_format(void) const;
  67 + void alloc_data(void);
  68 + void release_data(void);
  69 + void alloc_nulval(const unsigned long* value);
  70 + void init_data(void);
  71 + void* ptr_data(void) { return m_data; }
  72 + void* ptr_nulval(void) { return m_nulval; }
72 73  
73 74 // Private data area
74   - unsigned long* m_data; //!< Data area
75   - unsigned long* m_nulval; //!< NULL value
  75 + unsigned long* m_data; //!< Data vector
  76 + unsigned long* m_nulval; //!< NULL value
76 77 };
77 78  
78   -#endif /* GFITSTABLEULGCOL_HPP */
  79 +#endif /* GFITSTABLEULONGCOL_HPP */
... ...
include/GFitsTableUStCol.hpp renamed to include/GFitsTableUShortCol.hpp
1 1 /***************************************************************************
2   - * GFitsTableUStCol.hpp - FITS table unsigned short column class *
  2 + * GFitsTableUShortCol.hpp - FITS table unsigned short column class *
3 3 * ----------------------------------------------------------------------- *
4 4 * copyright (C) 2010 by Jurgen Knodlseder *
5 5 * ----------------------------------------------------------------------- *
... ... @@ -11,40 +11,40 @@
11 11 * *
12 12 ***************************************************************************/
13 13 /**
14   - * @file GFitsTableUStCol.hpp
15   - * @brief GFitsTableUStCol class definition.
  14 + * @file GFitsTableUShortCol.hpp
  15 + * @brief GFitsTableUShortCol class definition.
16 16 * @author J. Knodlseder
17 17 */
18 18  
19   -#ifndef GFITSTABLEUSTCOL_HPP
20   -#define GFITSTABLEUSTCOL_HPP
  19 +#ifndef GFITSTABLEUSHORTCOL_HPP
  20 +#define GFITSTABLEUSHORTCOL_HPP
21 21  
22 22 /* __ Includes ___________________________________________________________ */
23 23 #include "GFitsTableCol.hpp"
24 24  
25 25  
26 26 /***********************************************************************//**
27   - * @class GFitsTableUStCol
  27 + * @class GFitsTableUShortCol
28 28 *
29   - * @brief Interface for FITS table unsigned long integer column
  29 + * @brief Interface for FITS table unsigned short integer column
30 30 *
31   - * This class implements a FITS table unsigned long integer column.
  31 + * This class implements a FITS table unsigned short integer column.
32 32 ***************************************************************************/
33   -class GFitsTableUStCol : public GFitsTableCol {
  33 +class GFitsTableUShortCol : public GFitsTableCol {
34 34  
35 35 // I/O friends
36   - friend std::ostream& operator<< (std::ostream& os, const GFitsTableUStCol& column);
  36 + friend std::ostream& operator<< (std::ostream& os, const GFitsTableUShortCol& column);
37 37  
38 38 public:
39 39 // Constructors and destructors
40   - GFitsTableUStCol();
41   - GFitsTableUStCol(const std::string& name, const int& length,
42   - const int& size = 1);
43   - GFitsTableUStCol(const GFitsTableUStCol& column);
44   - virtual ~GFitsTableUStCol();
  40 + GFitsTableUShortCol(void);
  41 + GFitsTableUShortCol(const std::string& name, const int& length,
  42 + const int& size = 1);
  43 + GFitsTableUShortCol(const GFitsTableUShortCol& column);
  44 + virtual ~GFitsTableUShortCol(void);
45 45  
46 46 // Operators
47   - GFitsTableUStCol& operator= (const GFitsTableUStCol& column);
  47 + GFitsTableUShortCol& operator= (const GFitsTableUShortCol& column);
48 48 unsigned short& operator() (const int& row, const int& inx = 0);
49 49 const unsigned short& operator() (const int& row, const int& inx = 0) const;
50 50  
... ... @@ -52,27 +52,28 @@ public:
52 52 std::string string(const int& row, const int& col = 0);
53 53 double real(const int& row, const int& col = 0);
54 54 int integer(const int& row, const int& col = 0);
55   - unsigned short* data(void);
56   - void set_nullval(const unsigned short* value);
  55 + unsigned short* data(void) { return m_data; }
  56 + void nullval(const unsigned short* value);
  57 + unsigned short* nullval(void) { return m_nulval; }
57 58  
58 59 private:
59 60 // Private methods
60   - void init_members(void);
61   - void copy_members(const GFitsTableUStCol& column);
62   - void free_members(void);
63   - void save(void);
64   - GFitsTableUStCol* clone(void) const;
65   - std::string ascii_format(void) const;
66   - std::string binary_format(void) const;
67   - void alloc_data(void);
68   - void init_data(void);
69   - void fetch_data(void);
70   - void* ptr_data(void) { return m_data; }
71   - void* ptr_nulval(void) { return m_nulval; }
  61 + void init_members(void);
  62 + void copy_members(const GFitsTableUShortCol& column);
  63 + void free_members(void);
  64 + GFitsTableUShortCol* clone(void) const;
  65 + std::string ascii_format(void) const;
  66 + std::string binary_format(void) const;
  67 + void alloc_data(void);
  68 + void release_data(void);
  69 + void alloc_nulval(const unsigned short* value);
  70 + void init_data(void);
  71 + void* ptr_data(void) { return m_data; }
  72 + void* ptr_nulval(void) { return m_nulval; }
72 73  
73 74 // Private data area
74   - unsigned short* m_data; //!< Data area
75   - unsigned short* m_nulval; //!< NULL value
  75 + unsigned short* m_data; //!< Data vector
  76 + unsigned short* m_nulval; //!< NULL value
76 77 };
77 78  
78   -#endif /* GFITSTABLEUSTCOL_HPP */
  79 +#endif /* GFITSTABLEUSHORTCOL_HPP */
... ...
pyext/GFitsTableLogCol.i renamed to pyext/GFitsTableBitCol.i
1 1 /***************************************************************************
2   - * GFitsTableLogCol.i - FITS table logical column class SWIG definition *
  2 + * GFitsTableBitCol.i - FITS table bit column class SWIG definition *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright : (C) 2008 by Jurgen Knodlseder *
  4 + * copyright : (C) 2010 by Jurgen Knodlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software; you can redistribute it and/or modify *
... ... @@ -11,43 +11,44 @@
11 11 * *
12 12 ***************************************************************************/
13 13 /**
14   - * @file GFitsTableLogCol.i
15   - * @brief GFitsTableLogCol class SWIG file.
  14 + * @file GFitsTableBitCol.i
  15 + * @brief GFitsTableBitCol class SWIG file.
16 16 * @author J. Knodlseder
17 17 */
18 18 %{
19 19 /* Put headers and other declarations here that are needed for compilation */
20   -#include "GFitsTableLogCol.hpp"
  20 +#include "GFitsTableBitCol.hpp"
21 21 %}
22 22  
23 23  
24 24 /***********************************************************************//**
25   - * @class GFitsTableLogCol
  25 + * @class GFitsTableBitCol
26 26 *
27 27 * @brief SWIG interface for FITS table logical column
28 28 ***************************************************************************/
29   -class GFitsTableLogCol : public GFitsTableCol {
  29 +class GFitsTableBitCol : public GFitsTableCol {
30 30 public:
31 31 // Constructors and destructors
32   - GFitsTableLogCol();
33   - GFitsTableLogCol(const std::string& name, const int& length,
  32 + GFitsTableBitCol(void);
  33 + GFitsTableBitCol(const std::string& name, const int& length,
34 34 const int& size = 1);
35   - GFitsTableLogCol(const GFitsTableLogCol& column);
36   - virtual ~GFitsTableLogCol();
  35 + GFitsTableBitCol(const GFitsTableBitCol& column);
  36 + virtual ~GFitsTableBitCol(void);
37 37  
38 38 // Methods
39 39 std::string string(const int& row, const int& col = 0);
40 40 double real(const int& row, const int& col = 0);
41 41 int integer(const int& row, const int& col = 0);
42   - char* data(void);
43   - void set_nullval(const char* value);
  42 + char* data(void) { return m_data; }
  43 + void nullval(const char* value);
  44 + char* nullval(void) { return m_nulval; }
44 45 };
45 46  
46 47  
47 48 /***********************************************************************//**
48   - * @brief GFitsTableLogCol class extension
  49 + * @brief GFitsTableBitCol class extension
49 50 ***************************************************************************/
50   -%extend GFitsTableLogCol {
  51 +%extend GFitsTableBitCol {
51 52 char *__str__() {
52 53 static char str_buffer[1001];
53 54 std::ostringstream buffer;
... ... @@ -69,7 +70,7 @@ public:
69 70 void set(const int& row, const int& col, const char& value) {
70 71 (*self)(row, col) = value;
71 72 }
72   - GFitsTableLogCol copy() {
  73 + GFitsTableBitCol copy() {
73 74 return (*self);
74 75 }
75 76 };
... ...
pyext/GFitsTableBoolCol.i 0 → 100644
  1 +/***************************************************************************
  2 + * GFitsTableBoolCol.i - FITS table boolean column class SWIG definition *
  3 + * ----------------------------------------------------------------------- *
  4 + * copyright : (C) 2008-2010 by Jurgen Knodlseder *
  5 + * ----------------------------------------------------------------------- *
  6 + * *
  7 + * This program is free software; you can redistribute it and/or modify *
  8 + * it under the terms of the GNU General Public License as published by *
  9 + * the Free Software Foundation; either version 2 of the License, or *
  10 + * (at your option) any later version. *
  11 + * *
  12 + ***************************************************************************/
  13 +/**
  14 + * @file GFitsTableBoolCol.i
  15 + * @brief GFitsTableBoolCol class SWIG file.
  16 + * @author J. Knodlseder
  17 + */
  18 +%{
  19 +/* Put headers and other declarations here that are needed for compilation */
  20 +#include "GFitsTableBoolCol.hpp"
  21 +%}
  22 +
  23 +
  24 +/***********************************************************************//**
  25 + * @class GFitsTableBoolCol
  26 + *
  27 + * @brief SWIG interface for FITS table logical column
  28 + ***************************************************************************/
  29 +class GFitsTableBoolCol : public GFitsTableCol {
  30 +public:
  31 + // Constructors and destructors
  32 + GFitsTableBoolCol(void);
  33 + GFitsTableBoolCol(const std::string& name, const int& length,
  34 + const int& size = 1);
  35 + GFitsTableBoolCol(const GFitsTableBoolCol& column);
  36 + virtual ~GFitsTableBoolCol(void);
  37 +
  38 + // Methods
  39 + std::string string(const int& row, const int& col = 0);
  40 + double real(const int& row, const int& col = 0);
  41 + int integer(const int& row, const int& col = 0);
  42 + bool* data(void) { return m_data; }
  43 + void nullval(const bool* value);
  44 + bool* nullval(void) { return m_nulval; }
  45 +};
  46 +
  47 +
  48 +/***********************************************************************//**
  49 + * @brief GFitsTableBoolCol class extension
  50 + ***************************************************************************/
  51 +%extend GFitsTableBoolCol {
  52 + char *__str__() {
  53 + static char str_buffer[1001];
  54 + std::ostringstream buffer;
  55 + buffer << *self;
  56 + std::string str = buffer.str();
  57 + strncpy(str_buffer, (char*)str.c_str(), 1001);
  58 + str_buffer[1000] = '\0';
  59 + return str_buffer;
  60 + }
  61 + bool get(const int& row) {
  62 + return (*self)(row);
  63 + }
  64 + bool get(const int& row, const int& col) {
  65 + return (*self)(row, col);
  66 + }
  67 + void set(const int& row, const bool& value) {
  68 + (*self)(row) = value;
  69 + }
  70 + void set(const int& row, const int& col, const bool& value) {
  71 + (*self)(row, col) = value;
  72 + }
  73 + GFitsTableBoolCol copy() {
  74 + return (*self);
  75 + }
  76 +};
... ...
pyext/GFitsTableDblCol.i renamed to pyext/GFitsTableDoubleCol.i
1 1 /***************************************************************************
2   - * GFitsTableDblCol.i - FITS table double column class SWIG definiton *
  2 + * GFitsTableDoubleCol.i - FITS table double column class SWIG definiton *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright : (C) 2008 by Jurgen Knodlseder *
  4 + * copyright (C) 2008-2010 by Jurgen Knodlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software; you can redistribute it and/or modify *
... ... @@ -11,43 +11,44 @@
11 11 * *
12 12 ***************************************************************************/
13 13 /**
14   - * @file GFitsTableDblCol.i
15   - * @brief GFitsTableDblCol class SWIG file.
  14 + * @file GFitsTableDoubleCol.i
  15 + * @brief GFitsTableDoubleCol class SWIG file.
16 16 * @author J. Knodlseder
17 17 */
18 18 %{
19 19 /* Put headers and other declarations here that are needed for compilation */
20   -#include "GFitsTableDblCol.hpp"
  20 +#include "GFitsTableDoubleCol.hpp"
21 21 %}
22 22  
23 23  
24 24 /***********************************************************************//**
25   - * @class GFitsTableDblCol
  25 + * @class GFitsTableDoubleCol
26 26 *
27 27 * @brief SWIG interface for FITS table double precision column
28 28 ***************************************************************************/
29   -class GFitsTableDblCol : public GFitsTableCol {
  29 +class GFitsTableDoubleCol : public GFitsTableCol {
30 30 public:
31 31 // Constructors and destructors
32   - GFitsTableDblCol();
33   - GFitsTableDblCol(const std::string& name, const int& length,
34   - const int& size = 1);
35   - GFitsTableDblCol(const GFitsTableDblCol& column);
36   - virtual ~GFitsTableDblCol();
  32 + GFitsTableDoubleCol(void);
  33 + GFitsTableDoubleCol(const std::string& name, const int& length,
  34 + const int& size = 1);
  35 + GFitsTableDoubleCol(const GFitsTableDoubleCol& column);
  36 + virtual ~GFitsTableDoubleCol(void);
37 37  
38 38 // Methods
39 39 std::string string(const int& row, const int& inx = 0);
40 40 double real(const int& row, const int& inx = 0);
41 41 int integer(const int& row, const int& inx = 0);
42   - double* data(void);
43   - void set_nullval(const double* value);
  42 + double* data(void) { return m_data; }
  43 + void nullval(const double* value);
  44 + double* nullval(void) { return m_nulval; }
44 45 };
45 46  
46 47  
47 48 /***********************************************************************//**
48   - * @brief GFitsTableDblCol class extension
  49 + * @brief GFitsTableDoubleCol class extension
49 50 ***************************************************************************/
50   -%extend GFitsTableDblCol {
  51 +%extend GFitsTableDoubleCol {
51 52 char *__str__() {
52 53 static char str_buffer[1001];
53 54 std::ostringstream buffer;
... ... @@ -69,7 +70,7 @@ public:
69 70 void set(const int& row, const int& col, const double& value) {
70 71 (*self)(row, col) = value;
71 72 }
72   - GFitsTableDblCol copy() {
  73 + GFitsTableDoubleCol copy() {
73 74 return (*self);
74 75 }
75 76 };
... ...
pyext/GFitsTableFltCol.i renamed to pyext/GFitsTableFloatCol.i
1 1 /***************************************************************************
2   - * GFitsTableFltCol.i - FITS table float column class SWIG definition *
  2 + * GFitsTableFloatCol.i - FITS table float column class SWIG definition *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright : (C) 2008 by Jurgen Knodlseder *
  4 + * copyright (C) 2008-2010 by Jurgen Knodlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software; you can redistribute it and/or modify *
... ... @@ -11,43 +11,44 @@
11 11 * *
12 12 ***************************************************************************/
13 13 /**
14   - * @file GFitsTableFltCol.i
15   - * @brief GFitsTableFltCol class SWIG file.
  14 + * @file GFitsTableFloatCol.i
  15 + * @brief GFitsTableFloatCol class SWIG file.
16 16 * @author J. Knodlseder
17 17 */
18 18 %{
19 19 /* Put headers and other declarations here that are needed for compilation */
20   -#include "GFitsTableFltCol.hpp"
  20 +#include "GFitsTableFloatCol.hpp"
21 21 %}
22 22  
23 23  
24 24 /***********************************************************************//**
25   - * @class GFitsTableFltCol
  25 + * @class GFitsTableFloatCol
26 26 *
27 27 * @brief SWIG interface for FITS table floating point column
28 28 ***************************************************************************/
29   -class GFitsTableFltCol : public GFitsTableCol {
  29 +class GFitsTableFloatCol : public GFitsTableCol {
30 30 public:
31 31 // Constructors and destructors
32   - GFitsTableFltCol();
33   - GFitsTableFltCol(const std::string& name, const int& length,
34   - const int& size = 1);
35   - GFitsTableFltCol(const GFitsTableFltCol& column);
36   - virtual ~GFitsTableFltCol();
  32 + GFitsTableFloatCol(void);
  33 + GFitsTableFloatCol(const std::string& name, const int& length,
  34 + const int& size = 1);
  35 + GFitsTableFloatCol(const GFitsTableFloatCol& column);
  36 + virtual ~GFitsTableFloatCol(void);
37 37  
38 38 // Methods
39 39 std::string string(const int& row, const int& col = 0);
40 40 double real(const int& row, const int& col = 0);
41 41 int integer(const int& row, const int& col = 0);
42   - float* data(void);
43   - void set_nullval(const float* value);
  42 + float* data(void) { return m_data; }
  43 + void nullval(const float* value);
  44 + float* nullval(void) { return m_nulval; }
44 45 };
45 46  
46 47  
47 48 /***********************************************************************//**
48   - * @brief GFitsTableFltCol class extension
  49 + * @brief GFitsTableFloatCol class extension
49 50 ***************************************************************************/
50   -%extend GFitsTableFltCol {
  51 +%extend GFitsTableFloatCol {
51 52 char *__str__() {
52 53 static char str_buffer[1001];
53 54 std::ostringstream buffer;
... ... @@ -69,7 +70,7 @@ public:
69 70 void set(const int& row, const int& col, const float& value) {
70 71 (*self)(row, col) = value;
71 72 }
72   - GFitsTableFltCol copy() {
  73 + GFitsTableFloatCol copy() {
73 74 return (*self);
74 75 }
75 76 };
... ...
pyext/GFitsTableLngCol.i renamed to pyext/GFitsTableLongCol.i
1 1 /***************************************************************************
2   - * GFitsTableLngCol.i - FITS table long column class SWIG definiton *
  2 + * GFitsTableLongCol.i - FITS table long column class SWIG definiton *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright : (C) 2008 by Jurgen Knodlseder *
  4 + * copyright : (C) 2008-2010 by Jurgen Knodlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software; you can redistribute it and/or modify *
... ... @@ -11,43 +11,44 @@
11 11 * *
12 12 ***************************************************************************/
13 13 /**
14   - * @file GFitsTableLngCol.i
15   - * @brief GFitsTableLngCol class SWIG file.
  14 + * @file GFitsTableLongCol.i
  15 + * @brief GFitsTableLongCol class SWIG file.
16 16 * @author J. Knodlseder
17 17 */
18 18 %{
19 19 /* Put headers and other declarations here that are needed for compilation */
20   -#include "GFitsTableLngCol.hpp"
  20 +#include "GFitsTableLongCol.hpp"
21 21 %}
22 22  
23 23  
24 24 /***********************************************************************//**
25   - * @class GFitsTableLngCol
  25 + * @class GFitsTableLongCol
26 26 *
27 27 * @brief SWIG interface for FITS table long integer column
28 28 ***************************************************************************/
29   -class GFitsTableLngCol : public GFitsTableCol {
  29 +class GFitsTableLongCol : public GFitsTableCol {
30 30 public:
31 31 // Constructors and destructors
32   - GFitsTableLngCol();
33   - GFitsTableLngCol(const std::string& name, const int& length,
34   - const int& size = 1);
35   - GFitsTableLngCol(const GFitsTableLngCol& column);
36   - virtual ~GFitsTableLngCol();
  32 + GFitsTableLongCol(void);
  33 + GFitsTableLongCol(const std::string& name, const int& length,
  34 + const int& size = 1);
  35 + GFitsTableLongCol(const GFitsTableLongCol& column);
  36 + virtual ~GFitsTableLongCol(void);
37 37  
38 38 // Methods
39 39 std::string string(const int& row, const int& col = 0);
40 40 double real(const int& row, const int& col = 0);
41 41 int integer(const int& row, const int& col = 0);
42   - long* data(void);
43   - void set_nullval(const long* value);
  42 + long* data(void) { return m_data; }
  43 + void nullval(const long* value);
  44 + long* nullval(void) { return m_nulval; }
44 45 };
45 46  
46 47  
47 48 /***********************************************************************//**
48   - * @brief GFitsTableLngCol class extension
  49 + * @brief GFitsTableLongCol class extension
49 50 ***************************************************************************/
50   -%extend GFitsTableLngCol {
  51 +%extend GFitsTableLongCol {
51 52 char *__str__() {
52 53 static char str_buffer[1001];
53 54 std::ostringstream buffer;
... ... @@ -69,7 +70,7 @@ public:
69 70 void set(const int& row, const int& col, const long& value) {
70 71 (*self)(row, col) = value;
71 72 }
72   - GFitsTableLngCol copy() {
  73 + GFitsTableLongCol copy() {
73 74 return (*self);
74 75 }
75 76 };
... ...
pyext/GFitsTableLongLongCol.i 0 → 100644
  1 +/***************************************************************************
  2 + * GFitsTableLongLongCol.i - FITS table long long column class SWIG def. *
  3 + * ----------------------------------------------------------------------- *
  4 + * copyright : (C) 2008-2010 by Jurgen Knodlseder *
  5 + * ----------------------------------------------------------------------- *
  6 + * *
  7 + * This program is free software; you can redistribute it and/or modify *
  8 + * it under the terms of the GNU General Public License as published by *
  9 + * the Free Software Foundation; either version 2 of the License, or *
  10 + * (at your option) any later version. *
  11 + * *
  12 + ***************************************************************************/
  13 +/**
  14 + * @file GFitsTableLongLongCol.i
  15 + * @brief GFitsTableLongLongCol class SWIG file.
  16 + * @author J. Knodlseder
  17 + */
  18 +%{
  19 +/* Put headers and other declarations here that are needed for compilation */
  20 +#include "GFitsTableLongLongCol.hpp"
  21 +%}
  22 +
  23 +
  24 +/***********************************************************************//**
  25 + * @class GFitsTableLongLongCol
  26 + *
  27 + * @brief SWIG interface for FITS table long integer column
  28 + ***************************************************************************/
  29 +class GFitsTableLongLongCol : public GFitsTableCol {
  30 +public:
  31 + // Constructors and destructors
  32 + GFitsTableLongLongCol(void);
  33 + GFitsTableLongLongCol(const std::string& name, const int& length,
  34 + const int& size = 1);
  35 + GFitsTableLongLongCol(const GFitsTableLongLongCol& column);
  36 + virtual ~GFitsTableLongLongCol(void);
  37 +
  38 + // Methods
  39 + std::string string(const int& row, const int& col = 0);
  40 + double real(const int& row, const int& col = 0);
  41 + int integer(const int& row, const int& col = 0);
  42 + long long* data(void) { return m_data; }
  43 + void nullval(const long long* value);
  44 + long long* nullval(void) { return m_nulval; }
  45 +};
  46 +
  47 +
  48 +/***********************************************************************//**
  49 + * @brief GFitsTableLongLongCol class extension
  50 + ***************************************************************************/
  51 +%extend GFitsTableLongLongCol {
  52 + char *__str__() {
  53 + static char str_buffer[1001];
  54 + std::ostringstream buffer;
  55 + buffer << *self;
  56 + std::string str = buffer.str();
  57 + strncpy(str_buffer, (char*)str.c_str(), 1001);
  58 + str_buffer[1000] = '\0';
  59 + return str_buffer;
  60 + }
  61 + long long get(const int& row) {
  62 + return (*self)(row);
  63 + }
  64 + long long get(const int& row, const int& col) {
  65 + return (*self)(row, col);
  66 + }
  67 + void set(const int& row, const long long& value) {
  68 + (*self)(row) = value;
  69 + }
  70 + void set(const int& row, const int& col, const long long& value) {
  71 + (*self)(row, col) = value;
  72 + }
  73 + GFitsTableLongLongCol copy() {
  74 + return (*self);
  75 + }
  76 +};
... ...
pyext/GFitsTableShtCol.i renamed to pyext/GFitsTableShortCol.i
1 1 /***************************************************************************
2   - * GFitsTableShtCol.i - FITS table short column class SWIG definition *
  2 + * GFitsTableShortCol.i - FITS table short column class SWIG definition *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright : (C) 2008 by Jurgen Knodlseder *
  4 + * copyright : (C) 2008-2010 by Jurgen Knodlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software; you can redistribute it and/or modify *
... ... @@ -11,43 +11,44 @@
11 11 * *
12 12 ***************************************************************************/
13 13 /**
14   - * @file GFitsTableShtCol.i
15   - * @brief GFitsTableShtCol class SWIG file.
  14 + * @file GFitsTableShortCol.i
  15 + * @brief GFitsTableShortCol class SWIG file.
16 16 * @author J. Knodlseder
17 17 */
18 18 %{
19 19 /* Put headers and other declarations here that are needed for compilation */
20   -#include "GFitsTableShtCol.hpp"
  20 +#include "GFitsTableShortCol.hpp"
21 21 %}
22 22  
23 23  
24 24 /***********************************************************************//**
25   - * @class GFitsTableShtCol
  25 + * @class GFitsTableShortCol
26 26 *
27 27 * @brief SWIG interface for FITS table short integer column
28 28 ***************************************************************************/
29   -class GFitsTableShtCol : public GFitsTableCol {
  29 +class GFitsTableShortCol : public GFitsTableCol {
30 30 public:
31 31 // Constructors and destructors
32   - GFitsTableShtCol();
33   - GFitsTableShtCol(const std::string& name, const int& length,
34   - const int& size = 1);
35   - GFitsTableShtCol(const GFitsTableShtCol& column);
36   - virtual ~GFitsTableShtCol();
  32 + GFitsTableShortCol(void);
  33 + GFitsTableShortCol(const std::string& name, const int& length,
  34 + const int& size = 1);
  35 + GFitsTableShortCol(const GFitsTableShortCol& column);
  36 + virtual ~GFitsTableShortCol(void);
37 37  
38 38 // Methods
39 39 std::string string(const int& row, const int& col = 0);
40 40 double real(const int& row, const int& col = 0);
41 41 int integer(const int& row, const int& col = 0);
42   - short* data(void);
43   - void set_nullval(const short* value);
  42 + short* data(void) { return m_data; }
  43 + void nullval(const short* value);
  44 + short* nullval(void) { return m_nulval; }
44 45 };
45 46  
46 47  
47 48 /***********************************************************************//**
48   - * @brief GFitsTableShtCol class extension
  49 + * @brief GFitsTableShortCol class extension
49 50 ***************************************************************************/
50   -%extend GFitsTableShtCol {
  51 +%extend GFitsTableShortCol {
51 52 char *__str__() {
52 53 static char str_buffer[1001];
53 54 std::ostringstream buffer;
... ... @@ -69,7 +70,7 @@ public:
69 70 void set(const int& row, const int& col, const short& value) {
70 71 (*self)(row, col) = value;
71 72 }
72   - GFitsTableShtCol copy() {
  73 + GFitsTableShortCol copy() {
73 74 return (*self);
74 75 }
75 76 };
... ...
pyext/GFitsTableStrCol.i renamed to pyext/GFitsTableStringCol.i
1 1 /***************************************************************************
2   - * GFitsTableStrCol.i - FITS table string column class SWIG definition *
  2 + * GFitsTableStringCol.i - FITS table string column class SWIG definition *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright : (C) 2008 by Jurgen Knodlseder *
  4 + * copyright : (C) 2008-2010 by Jurgen Knodlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software; you can redistribute it and/or modify *
... ... @@ -11,43 +11,44 @@
11 11 * *
12 12 ***************************************************************************/
13 13 /**
14   - * @file GFitsTableStrCol.i
15   - * @brief GFitsTableStrCol class SWIG file.
  14 + * @file GFitsTableStringCol.i
  15 + * @brief GFitsTableStringCol class SWIG file.
16 16 * @author J. Knodlseder
17 17 */
18 18 %{
19 19 /* Put headers and other declarations here that are needed for compilation */
20   -#include "GFitsTableStrCol.hpp"
  20 +#include "GFitsTableStringCol.hpp"
21 21 %}
22 22  
23 23  
24 24 /***********************************************************************//**
25   - * @class GFitsTableStrCol
  25 + * @class GFitsTableStringCol
26 26 *
27 27 * @brief SWIG interface for FITS table string column
28 28 ***************************************************************************/
29   -class GFitsTableStrCol : public GFitsTableCol {
  29 +class GFitsTableStringCol : public GFitsTableCol {
30 30 public:
31 31 // Constructors and destructors
32   - GFitsTableStrCol();
33   - GFitsTableStrCol(const std::string& name, const int& length,
34   - const int& width, const int& size = 1);
35   - GFitsTableStrCol(const GFitsTableStrCol& column);
36   - ~GFitsTableStrCol();
  32 + GFitsTableStringCol(void);
  33 + GFitsTableStringCol(const std::string& name, const int& length,
  34 + const int& width, const int& size = 1);
  35 + GFitsTableStringCol(const GFitsTableStringCol& column);
  36 + virtual ~GFitsTableStringCol(void);
37 37  
38 38 // Methods
39 39 std::string string(const int& row, const int& col = 0);
40 40 double real(const int& row, const int& col = 0);
41 41 int integer(const int& row, const int& col = 0);
42   - std::string* data(void);
43   - void set_nullval(const std::string string);
  42 + std::string* data(void) { return m_data; }
  43 + void nullval(const std::string value);
  44 + char* nullval(void) { return m_nulval; }
44 45 };
45 46  
46 47  
47 48 /***********************************************************************//**
48   - * @brief GFitsTableStrCol class extension
  49 + * @brief GFitsTableStringCol class extension
49 50 ***************************************************************************/
50   -%extend GFitsTableStrCol {
  51 +%extend GFitsTableStringCol {
51 52 char *__str__() {
52 53 static char str_buffer[1001];
53 54 std::ostringstream buffer;
... ... @@ -69,7 +70,7 @@ public:
69 70 void set(const int& row, const int& col, const std::string& value) {
70 71 (*self)(row, col) = value;
71 72 }
72   - GFitsTableStrCol copy() {
  73 + GFitsTableStringCol copy() {
73 74 return (*self);
74 75 }
75 76 };
... ...
pyext/GFitsTableULongCol.i 0 → 100644
  1 +/***************************************************************************
  2 + * GFitsTableULongCol.i - FITS table unsigned long column class SWIG def. *
  3 + * ----------------------------------------------------------------------- *
  4 + * copyright : (C) 2010 by Jurgen Knodlseder *
  5 + * ----------------------------------------------------------------------- *
  6 + * *
  7 + * This program is free software; you can redistribute it and/or modify *
  8 + * it under the terms of the GNU General Public License as published by *
  9 + * the Free Software Foundation; either version 2 of the License, or *
  10 + * (at your option) any later version. *
  11 + * *
  12 + ***************************************************************************/
  13 +/**
  14 + * @file GFitsTableULongCol.i
  15 + * @brief GFitsTableULongCol class SWIG file.
  16 + * @author J. Knodlseder
  17 + */
  18 +%{
  19 +/* Put headers and other declarations here that are needed for compilation */
  20 +#include "GFitsTableULongCol.hpp"
  21 +%}
  22 +
  23 +
  24 +/***********************************************************************//**
  25 + * @class GFitsTableULongCol
  26 + *
  27 + * @brief SWIG interface for FITS table long integer column
  28 + ***************************************************************************/
  29 +class GFitsTableULongCol : public GFitsTableCol {
  30 +public:
  31 + // Constructors and destructors
  32 + GFitsTableULongCol(void);
  33 + GFitsTableULongCol(const std::string& name, const int& length,
  34 + const int& size = 1);
  35 + GFitsTableULongCol(const GFitsTableULongCol& column);
  36 + virtual ~GFitsTableULongCol(void);
  37 +
  38 + // Methods
  39 + std::string string(const int& row, const int& col = 0);
  40 + double real(const int& row, const int& col = 0);
  41 + int integer(const int& row, const int& col = 0);
  42 + unsigned long* data(void) { return m_data; }
  43 + void nullval(const unsigned long* value);
  44 + unsigned long* nullval(void) { return m_nulval; }
  45 +};
  46 +
  47 +
  48 +/***********************************************************************//**
  49 + * @brief GFitsTableULongCol class extension
  50 + ***************************************************************************/
  51 +%extend GFitsTableULongCol {
  52 + char *__str__() {
  53 + static char str_buffer[1001];
  54 + std::ostringstream buffer;
  55 + buffer << *self;
  56 + std::string str = buffer.str();
  57 + strncpy(str_buffer, (char*)str.c_str(), 1001);
  58 + str_buffer[1000] = '\0';
  59 + return str_buffer;
  60 + }
  61 + unsigned long get(const int& row) {
  62 + return (*self)(row);
  63 + }
  64 + unsigned long get(const int& row, const int& col) {
  65 + return (*self)(row, col);
  66 + }
  67 + void set(const int& row, const unsigned long& value) {
  68 + (*self)(row) = value;
  69 + }
  70 + void set(const int& row, const int& col, const unsigned long& value) {
  71 + (*self)(row, col) = value;
  72 + }
  73 + GFitsTableULongCol copy() {
  74 + return (*self);
  75 + }
  76 +};
... ...
pyext/GFitsTableUShortCol.i 0 → 100644
  1 +/***************************************************************************
  2 + * GFitsTableUShortCol.i - FITS table unsigned short column class SWIG def*
  3 + * ----------------------------------------------------------------------- *
  4 + * copyright : (C) 2008-2010 by Jurgen Knodlseder *
  5 + * ----------------------------------------------------------------------- *
  6 + * *
  7 + * This program is free software; you can redistribute it and/or modify *
  8 + * it under the terms of the GNU General Public License as published by *
  9 + * the Free Software Foundation; either version 2 of the License, or *
  10 + * (at your option) any later version. *
  11 + * *
  12 + ***************************************************************************/
  13 +/**
  14 + * @file GFitsTableUShortCol.i
  15 + * @brief GFitsTableUShortCol class SWIG file.
  16 + * @author J. Knodlseder
  17 + */
  18 +%{
  19 +/* Put headers and other declarations here that are needed for compilation */
  20 +#include "GFitsTableUShortCol.hpp"
  21 +%}
  22 +
  23 +
  24 +/***********************************************************************//**
  25 + * @class GFitsTableUShortCol
  26 + *
  27 + * @brief SWIG interface for FITS table short integer column
  28 + ***************************************************************************/
  29 +class GFitsTableUShortCol : public GFitsTableCol {
  30 +public:
  31 + // Constructors and destructors
  32 + GFitsTableUShortCol(void);
  33 + GFitsTableUShortCol(const std::string& name, const int& length,
  34 + const int& size = 1);
  35 + GFitsTableUShortCol(const GFitsTableUShortCol& column);
  36 + virtual ~GFitsTableUShortCol(void);
  37 +
  38 + // Methods
  39 + std::string string(const int& row, const int& col = 0);
  40 + double real(const int& row, const int& col = 0);
  41 + int integer(const int& row, const int& col = 0);
  42 + unsigned short* data(void) { return m_data; }
  43 + void nullval(const unsigned short* value);
  44 + unsigned short* nullval(void) { return m_nulval; }
  45 +};
  46 +
  47 +
  48 +/***********************************************************************//**
  49 + * @brief GFitsTableUShortCol class extension
  50 + ***************************************************************************/
  51 +%extend GFitsTableUShortCol {
  52 + char *__str__() {
  53 + static char str_buffer[1001];
  54 + std::ostringstream buffer;
  55 + buffer << *self;
  56 + std::string str = buffer.str();
  57 + strncpy(str_buffer, (char*)str.c_str(), 1001);
  58 + str_buffer[1000] = '\0';
  59 + return str_buffer;
  60 + }
  61 + unsigned short get(const int& row) {
  62 + return (*self)(row);
  63 + }
  64 + unsigned short get(const int& row, const int& col) {
  65 + return (*self)(row, col);
  66 + }
  67 + void set(const int& row, const unsigned short& value) {
  68 + (*self)(row) = value;
  69 + }
  70 + void set(const int& row, const int& col, const unsigned short& value) {
  71 + (*self)(row, col) = value;
  72 + }
  73 + GFitsTableUShortCol copy() {
  74 + return (*self);
  75 + }
  76 +};
... ...
pyext/gammalib.i
... ... @@ -41,12 +41,16 @@
41 41 #include "GFitsAsciiTable.i"
42 42 #include "GFitsBinTable.i"
43 43 #include "GFitsTableCol.i"
44   -#include "GFitsTableLogCol.i"
45   -#include "GFitsTableDblCol.i"
46   -#include "GFitsTableFltCol.i"
47   -#include "GFitsTableLngCol.i"
48   -#include "GFitsTableShtCol.i"
49   -#include "GFitsTableStrCol.i"
  44 +#include "GFitsTableBitCol.i"
  45 +#include "GFitsTableBoolCol.i"
  46 +#include "GFitsTableDoubleCol.i"
  47 +#include "GFitsTableFloatCol.i"
  48 +#include "GFitsTableULongCol.i"
  49 +#include "GFitsTableLongCol.i"
  50 +#include "GFitsTableUShortCol.i"
  51 +#include "GFitsTableLongLongCol.i"
  52 +#include "GFitsTableShortCol.i"
  53 +#include "GFitsTableStringCol.i"
50 54  
51 55 /* __ Application module _________________________________________________ */
52 56 #include "GApplication.i"
... ...
src/fits/GFitsTableBitCol.cpp
... ... @@ -21,9 +21,6 @@
21 21 #include "GFitsTableBitCol.hpp"
22 22  
23 23 /* __ Method name definitions ____________________________________________ */
24   -#define G_STRING "GFitsTableBitCol::string(const int&, const int&)"
25   -#define G_REAL "GFitsTableBitCol::real(const int&, const int&)"
26   -#define G_INTEGER "GFitsTableBitCol::integer(const int&, const int&)"
27 24  
28 25 /* __ Macros _____________________________________________________________ */
29 26  
... ... @@ -144,23 +141,15 @@ GFitsTableBitCol&amp; GFitsTableBitCol::operator= (const GFitsTableBitCol&amp; column)
144 141 * @param[in] row Row of column to access.
145 142 * @param[in] inx Vector index in column row to access
146 143 *
147   - * Provides access to data in a column. No range checking is performed.
148   - * Use one of
149   - * GFitsTableBitCol::string(ix,iy),
150   - * GFitsTableBitCol::real(ix,iy) or
151   - * GFitsTableBitCol::integer(ix,iy)
152   - * if range checking is required.
  144 + * Provides access to data in a column.
153 145 ***************************************************************************/
154 146 char& GFitsTableBitCol::operator() (const int& row, const int& inx)
155 147 {
156 148 // If data are not available then load them now
157 149 if (m_data == NULL) fetch_data();
158 150  
159   - // Calculate pixel offset
160   - int offset = row * m_number + inx;
161   -
162 151 // Return data bin
163   - return m_data[offset];
  152 + return m_data[offset(row, inx)];
164 153 }
165 154  
166 155  
... ... @@ -170,24 +159,15 @@ char&amp; GFitsTableBitCol::operator() (const int&amp; row, const int&amp; inx)
170 159 * @param[in] row Row of column to access.
171 160 * @param[in] inx Vector index in column row to access
172 161 *
173   - * Provides access to data in a column. No range checking is performed.
174   - * Use one of
175   - * GFitsTableBitCol::string(ix,iy),
176   - * GFitsTableBitCol::real(ix,iy) or
177   - * GFitsTableBitCol::integer(ix,iy)
178   - * if range checking is required.
  162 + * Provides access to data in a column.
179 163 ***************************************************************************/
180   -const char& GFitsTableBitCol::operator() (const int& row, const int& inx)
181   - const
  164 +const char& GFitsTableBitCol::operator() (const int& row, const int& inx) const
182 165 {
183 166 // If data are not available then load them now
184 167 if (m_data == NULL) ((GFitsTableBitCol*)this)->fetch_data();
185 168  
186   - // Calculate pixel offset
187   - int offset = row * m_number + inx;
188   -
189 169 // Return data bin
190   - return m_data[offset];
  170 + return m_data[offset(row, inx)];
191 171 }
192 172  
193 173  
... ... @@ -203,9 +183,6 @@ const char&amp; GFitsTableBitCol::operator() (const int&amp; row, const int&amp; inx)
203 183 * @param[in] row Table row.
204 184 * @param[in] inx Table column vector index.
205 185 *
206   - * @exception GException::out_of_range
207   - * Table row or vector index are out of valid range.
208   - *
209 186 * Returns value of specified row and vector index as string.
210 187 ***************************************************************************/
211 188 std::string GFitsTableBitCol::string(const int& row, const int& inx)
... ... @@ -213,19 +190,8 @@ std::string GFitsTableBitCol::string(const int&amp; row, const int&amp; inx)
213 190 // If data are not available then load them now
214 191 if (m_data == NULL) fetch_data();
215 192  
216   - // Check row value
217   - if (row < 0 || row >= m_length)
218   - throw GException::out_of_range(G_STRING, row, 0, m_length-1);
219   -
220   - // Check inx value
221   - if (inx < 0 || inx >= m_number)
222   - throw GException::out_of_range(G_STRING, inx, 0, m_number-1);
223   -
224   - // Get index
225   - int offset = row * m_number + inx;
226   -
227   - // Convert Bit into string
228   - std::string result = (m_data[offset]) ? "1" : "0";
  193 + // Convert bit into string
  194 + std::string result = (m_data[offset(row,inx)]) ? "1" : "0";
229 195  
230 196 // Return value
231 197 return result;
... ... @@ -238,9 +204,6 @@ std::string GFitsTableBitCol::string(const int&amp; row, const int&amp; inx)
238 204 * @param[in] row Table row.
239 205 * @param[in] inx Table column vector index.
240 206 *
241   - * @exception GException::out_of_range
242   - * Table row or vector index are out of valid range.
243   - *
244 207 * Returns value of specified row and vector index as double precision.
245 208 ***************************************************************************/
246 209 double GFitsTableBitCol::real(const int& row, const int& inx)
... ... @@ -248,19 +211,8 @@ double GFitsTableBitCol::real(const int&amp; row, const int&amp; inx)
248 211 // If data are not available then load them now
249 212 if (m_data == NULL) fetch_data();
250 213  
251   - // Check row value
252   - if (row < 0 || row >= m_length)
253   - throw GException::out_of_range(G_REAL, row, 0, m_length-1);
254   -
255   - // Check inx value
256   - if (inx < 0 || inx >= m_number)
257   - throw GException::out_of_range(G_REAL, inx, 0, m_number-1);
258   -
259   - // Get index
260   - int offset = row * m_number + inx;
261   -
262   - // Convert Bit into double
263   - double value = (double)m_data[offset];
  214 + // Convert bit into double
  215 + double value = (double)m_data[offset(row,inx)];
264 216  
265 217 // Return value
266 218 return value;
... ... @@ -273,9 +225,6 @@ double GFitsTableBitCol::real(const int&amp; row, const int&amp; inx)
273 225 * @param[in] row Table row.
274 226 * @param[in] inx Table column vector index.
275 227 *
276   - * @exception GException::out_of_range
277   - * Table row or vector index are out of valid range.
278   - *
279 228 * Returns value of specified row and vector index as integer.
280 229 ***************************************************************************/
281 230 int GFitsTableBitCol::integer(const int& row, const int& inx)
... ... @@ -283,19 +232,8 @@ int GFitsTableBitCol::integer(const int&amp; row, const int&amp; inx)
283 232 // If data are not available then load them now
284 233 if (m_data == NULL) fetch_data();
285 234  
286   - // Check row value
287   - if (row < 0 || row >= m_length)
288   - throw GException::out_of_range(G_INTEGER, row, 0, m_length-1);
289   -
290   - // Check col value
291   - if (inx < 0 || inx >= m_number)
292   - throw GException::out_of_range(G_INTEGER, inx, 0, m_number-1);
293   -
294   - // Get index
295   - int offset = row * m_number + inx;
296   -
297   - // Convert Bit into int
298   - int value = (int)m_data[offset];
  235 + // Convert bit into int
  236 + int value = (int)m_data[offset(row,inx)];
299 237  
300 238 // Return value
301 239 return value;
... ... @@ -303,44 +241,30 @@ int GFitsTableBitCol::integer(const int&amp; row, const int&amp; inx)
303 241  
304 242  
305 243 /***********************************************************************//**
306   - * @brief Return pointer to column
307   - ***************************************************************************/
308   -char* GFitsTableBitCol::data(void)
309   -{
310   - return m_data;
311   -}
312   -
313   -
314   -/***********************************************************************//**
315 244 * @brief Set NULL value
316 245 *
317 246 * @param[in] value Pointer on NULL value
318 247 *
319 248 * Allows the specification of the FITS table NULL value. If value=NULL the
320 249 * data will not be screened for NULL values.
  250 + *
  251 + * @todo To correctly reflect the NULL value in the data, the column should
  252 + * be reloaded. However, the column may have been changed, so in principle
  253 + * saving is needed. However, we may not want to store the data, hence saving
  254 + * is also not desired. We thus have to develop a method to update the
  255 + * column information for a new NULL value in place ...
321 256 ***************************************************************************/
322   -void GFitsTableBitCol::set_nullval(const char* value)
  257 +void GFitsTableBitCol::nullval(const char* value)
323 258 {
324   - // If NULL value is empty then reset the NULL value
325   - if (value == NULL) {
326   - if (m_nulval != NULL) delete m_nulval;
327   - m_nulval = NULL;
328   - }
  259 + // Allocate nul value
  260 + alloc_nulval(value);
329 261  
330   - // ... otherwise copy value into NULL value
331   - else {
332   - if (m_nulval != NULL) delete m_nulval;
333   - m_nulval = new char;
334   - *m_nulval = *value;
335   - }
  262 + // Update column
  263 +// if (m_data != NULL) {
  264 +// save();
  265 +// load();
  266 +// }
336 267  
337   - // Re-load column
338   -/*
339   - if (m_data != NULL) {
340   - save();
341   - load();
342   - }
343   -*/
344 268 // Return
345 269 return;
346 270 }
... ... @@ -376,8 +300,8 @@ void GFitsTableBitCol::copy_members(const GFitsTableBitCol&amp; column)
376 300 {
377 301 // Fetch column data if not yet fetched. The casting circumvents the
378 302 // const correctness
379   - if (column.m_data == NULL)
380   - ((GFitsTableBitCol*)(&column))->fetch_data();
  303 + bool not_loaded = (column.m_data == NULL);
  304 + if (not_loaded) ((GFitsTableBitCol*)(&column))->fetch_data();
381 305  
382 306 // Copy attributes
383 307 m_type = column.m_type;
... ... @@ -391,11 +315,12 @@ void GFitsTableBitCol::copy_members(const GFitsTableBitCol&amp; column)
391 315 }
392 316  
393 317 // Copy NULL value
394   - if (column.m_nulval != NULL) {
395   - if (m_nulval != NULL) delete m_nulval;
396   - m_nulval = new char;
397   - *m_nulval = *column.m_nulval;
398   - }
  318 + alloc_nulval(column.m_nulval);
  319 +
  320 + // Small memory option: release column if it was fetch above
  321 + #if defined(G_SMALL_MEMORY)
  322 + if (not_loaded) ((GFitsTableBitCol*)(&column))->release_data();
  323 + #endif
399 324  
400 325 // Return
401 326 return;
... ... @@ -415,24 +340,8 @@ void GFitsTableBitCol::free_members(void)
415 340 m_data = NULL;
416 341 m_nulval = NULL;
417 342  
418   - // Return
419   - return;
420   -}
421   -
422   -
423   -/***********************************************************************//**
424   - * @brief Save table column into FITS file
425   - *
426   - * The table column is only saved if it is linked to a FITS file and if the
427   - * data are indeed present in the class instance. This avoids saving of data
428   - * that have not been modified.
429   - *
430   - * Refer to GFitsTableCol::save_column() for more information.
431   - ***************************************************************************/
432   -void GFitsTableBitCol::save(void)
433   -{
434   - // Save column
435   - save_column();
  343 + // Reset load flag
  344 + m_size = 0;
436 345  
437 346 // Return
438 347 return;
... ... @@ -507,14 +416,37 @@ void GFitsTableBitCol::alloc_data(void)
507 416  
508 417  
509 418 /***********************************************************************//**
510   - * @brief Initialise column data
  419 + * @brief Release column data
511 420 ***************************************************************************/
512   -void GFitsTableBitCol::init_data(void)
  421 +void GFitsTableBitCol::release_data(void)
513 422 {
514   - // Initialise data if they exist
515   - if (m_data != NULL) {
516   - for (int i = 0; i < m_size; ++i)
517   - m_data[i] = 0;
  423 + // Free any existing memory
  424 + if (m_data != NULL) delete [] m_data;
  425 +
  426 + // Mark pointer as free and reset loaded vector size
  427 + m_data = NULL;
  428 + m_size = 0;
  429 +
  430 + // Return
  431 + return;
  432 +}
  433 +
  434 +
  435 +/***********************************************************************//**
  436 + * @brief Allocates null value
  437 + ***************************************************************************/
  438 +void GFitsTableBitCol::alloc_nulval(const char* value)
  439 +{
  440 + // Free any existing memory
  441 + if (m_nulval != NULL) delete m_nulval;
  442 +
  443 + // Mark pointer as free
  444 + m_nulval = NULL;
  445 +
  446 + // If we have valid value, allocate and set nul value
  447 + if (value != NULL) {
  448 + m_nulval = new char;
  449 + *m_nulval = *value;
518 450 }
519 451  
520 452 // Return
... ... @@ -523,18 +455,15 @@ void GFitsTableBitCol::init_data(void)
523 455  
524 456  
525 457 /***********************************************************************//**
526   - * @brief Fetch column data
527   - *
528   - * If a FITS file is attached to the column the data are loaded into memory
529   - * from the FITS file. If no FITS file is attached, memory is allocated
530   - * to hold the column data and all cells are set to 0.
531   - *
532   - * Refer to GFitsTableCol::load_column for more information.
  458 + * @brief Initialise column data
533 459 ***************************************************************************/
534   -void GFitsTableBitCol::fetch_data(void)
  460 +void GFitsTableBitCol::init_data(void)
535 461 {
536   - // Save column
537   - load_column();
  462 + // Initialise data if they exist
  463 + if (m_data != NULL) {
  464 + for (int i = 0; i < m_size; ++i)
  465 + m_data[i] = 0;
  466 + }
538 467  
539 468 // Return
540 469 return;
... ... @@ -550,8 +479,8 @@ void GFitsTableBitCol::fetch_data(void)
550 479 /***********************************************************************//**
551 480 * @brief Output operator
552 481 *
553   - * @param[in] os Output stream
554   - * @param[in] column Column to put in output stream
  482 + * @param[in] os Output stream.
  483 + * @param[in] column Column to put in output stream.
555 484 ***************************************************************************/
556 485 std::ostream& operator<< (std::ostream& os, const GFitsTableBitCol& column)
557 486 {
... ...
src/fits/GFitsTableBoolCol.cpp 0 → 100644
  1 +/***************************************************************************
  2 + * GFitsTableBoolCol.cpp - FITS table Boolean column class *
  3 + * ----------------------------------------------------------------------- *
  4 + * copyright (C) 2010 by Jurgen Knodlseder *
  5 + * ----------------------------------------------------------------------- *
  6 + * *
  7 + * This program is free software; you can redistribute it and/or modify *
  8 + * it under the terms of the GNU General Public License as published by *
  9 + * the Free Software Foundation; either version 2 of the License, or *
  10 + * (at your option) any later version. *
  11 + * *
  12 + ***************************************************************************/
  13 +
  14 +/* __ Includes ___________________________________________________________ */
  15 +#ifdef HAVE_CONFIG_H
  16 +#include <config.h>
  17 +#endif
  18 +#include <iostream>
  19 +#include "GException.hpp"
  20 +#include "GTools.hpp"
  21 +#include "GFitsTableBoolCol.hpp"
  22 +
  23 +/* __ Method name definitions ____________________________________________ */
  24 +
  25 +/* __ Macros _____________________________________________________________ */
  26 +
  27 +/* __ Coding definitions _________________________________________________ */
  28 +
  29 +/* __ Debug definitions __________________________________________________ */
  30 +
  31 +
  32 +/*==========================================================================
  33 + = =
  34 + = Constructors/destructors =
  35 + = =
  36 + ==========================================================================*/
  37 +
  38 +/***********************************************************************//**
  39 + * @brief Constructor
  40 + ***************************************************************************/
  41 +GFitsTableBoolCol::GFitsTableBoolCol(void) : GFitsTableCol()
  42 +{
  43 + // Initialise class members for clean destruction
  44 + init_members();
  45 +
  46 + // Return
  47 + return;
  48 +}
  49 +
  50 +
  51 +/***********************************************************************//**
  52 + * @brief Constructor
  53 + *
  54 + * @param[in] name Name of column.
  55 + * @param[in] length Length of column.
  56 + * @param[in] size Vector size of column.
  57 + ***************************************************************************/
  58 +GFitsTableBoolCol::GFitsTableBoolCol(const std::string& name,
  59 + const int& length,
  60 + const int& size)
  61 + : GFitsTableCol(name, length, size, 2)
  62 +{
  63 + // Initialise class members for clean destruction
  64 + init_members();
  65 +
  66 + // Return
  67 + return;
  68 +}
  69 +
  70 +
  71 +/***********************************************************************//**
  72 + * @brief Copy constructor
  73 + *
  74 + * @param[in] column Column from which class instance should be built.
  75 + ***************************************************************************/
  76 +GFitsTableBoolCol::GFitsTableBoolCol(const GFitsTableBoolCol& column)
  77 + : GFitsTableCol(column)
  78 +{
  79 + // Initialise class members for clean destruction
  80 + init_members();
  81 +
  82 + // Copy members
  83 + copy_members(column);
  84 +
  85 + // Return
  86 + return;
  87 +}
  88 +
  89 +
  90 +/***********************************************************************//**
  91 + * @brief Destructor
  92 + ***************************************************************************/
  93 +GFitsTableBoolCol::~GFitsTableBoolCol(void)
  94 +{
  95 + // Free members
  96 + free_members();
  97 +
  98 + // Return
  99 + return;
  100 +}
  101 +
  102 +
  103 +/*==========================================================================
  104 + = =
  105 + = Operators =
  106 + = =
  107 + ==========================================================================*/
  108 +
  109 +/***********************************************************************//**
  110 + * @brief Assignment operator
  111 + *
  112 + * @param[in] column Column which should be assigned
  113 + ***************************************************************************/
  114 +GFitsTableBoolCol& GFitsTableBoolCol::operator= (const GFitsTableBoolCol& column)
  115 +{
  116 + // Execute only if object is not identical
  117 + if (this != &column) {
  118 +
  119 + // Copy base class members
  120 + this->GFitsTableCol::operator=(column);
  121 +
  122 + // Free members
  123 + free_members();
  124 +
  125 + // Initialise private members for clean destruction
  126 + init_members();
  127 +
  128 + // Copy members
  129 + copy_members(column);
  130 +
  131 + } // endif: object was not identical
  132 +
  133 + // Return this object
  134 + return *this;
  135 +}
  136 +
  137 +
  138 +/***********************************************************************//**
  139 + * @brief Column data access operator
  140 + *
  141 + * @param[in] row Row of column to access.
  142 + * @param[in] inx Vector index in column row to access
  143 + *
  144 + * Provides access to data in a column.
  145 + ***************************************************************************/
  146 +bool& GFitsTableBoolCol::operator() (const int& row, const int& inx)
  147 +{
  148 + // If data are not available then load them now
  149 + if (m_data == NULL) fetch_data();
  150 +
  151 + // Return data bin
  152 + return m_data[offset(row, inx)];
  153 +}
  154 +
  155 +
  156 +/***********************************************************************//**
  157 + * @brief Column data access operator (const variant)
  158 + *
  159 + * @param[in] row Row of column to access.
  160 + * @param[in] inx Vector index in column row to access
  161 + *
  162 + * Provides access to data in a column.
  163 + ***************************************************************************/
  164 +const bool& GFitsTableBoolCol::operator() (const int& row, const int& inx) const
  165 +{
  166 + // If data are not available then load them now
  167 + if (m_data == NULL) ((GFitsTableBoolCol*)this)->fetch_data();
  168 +
  169 + // Return data bin
  170 + return m_data[offset(row, inx)];
  171 +}
  172 +
  173 +
  174 +/*==========================================================================
  175 + = =
  176 + = Public methods =
  177 + = =
  178 + ==========================================================================*/
  179 +
  180 +/***********************************************************************//**
  181 + * @brief Get string value
  182 + *
  183 + * @param[in] row Table row.
  184 + * @param[in] inx Table column vector index.
  185 + *
  186 + * Returns value of specified row and vector index as string.
  187 + ***************************************************************************/
  188 +std::string GFitsTableBoolCol::string(const int& row, const int& inx)
  189 +{
  190 + // If data are not available then load them now
  191 + if (m_data == NULL) fetch_data();
  192 +
  193 + // Convert bool into string
  194 + std::string result = (m_data[offset(row,inx)]) ? "T" : "F";
  195 +
  196 + // Return value
  197 + return result;
  198 +}
  199 +
  200 +
  201 +/***********************************************************************//**
  202 + * @brief Get double precision value
  203 + *
  204 + * @param[in] row Table row.
  205 + * @param[in] inx Table column vector index.
  206 + *
  207 + * Returns value of specified row and vector index as double precision.
  208 + ***************************************************************************/
  209 +double GFitsTableBoolCol::real(const int& row, const int& inx)
  210 +{
  211 + // If data are not available then load them now
  212 + if (m_data == NULL) fetch_data();
  213 +
  214 + // Convert bool into double
  215 + double value = (double)m_data[offset(row,inx)];
  216 +
  217 + // Return value
  218 + return value;
  219 +}
  220 +
  221 +
  222 +/***********************************************************************//**
  223 + * @brief Get integer value
  224 + *
  225 + * @param[in] row Table row.
  226 + * @param[in] inx Table column vector index.
  227 + *
  228 + * Returns value of specified row and vector index as integer.
  229 + ***************************************************************************/
  230 +int GFitsTableBoolCol::integer(const int& row, const int& inx)
  231 +{
  232 + // If data are not available then load them now
  233 + if (m_data == NULL) fetch_data();
  234 +
  235 + // Convert bool into int
  236 + int value = (int)m_data[offset(row,inx)];
  237 +
  238 + // Return value
  239 + return value;
  240 +}
  241 +
  242 +
  243 +/***********************************************************************//**
  244 + * @brief Set NULL value
  245 + *
  246 + * @param[in] value Pointer on NULL value
  247 + *
  248 + * Allows the specification of the FITS table NULL value. If value=NULL the
  249 + * data will not be screened for NULL values.
  250 + *
  251 + * @todo To correctly reflect the NULL value in the data, the column should
  252 + * be reloaded. However, the column may have been changed, so in principle
  253 + * saving is needed. However, we may not want to store the data, hence saving
  254 + * is also not desired. We thus have to develop a method to update the
  255 + * column information for a new NULL value in place ...
  256 + ***************************************************************************/
  257 +void GFitsTableBoolCol::nullval(const bool* value)
  258 +{
  259 + // Allocate nul value
  260 + alloc_nulval(value);
  261 +
  262 + // Update column
  263 +// if (m_data != NULL) {
  264 +// save();
  265 +// load();
  266 +// }
  267 +
  268 + // Return
  269 + return;
  270 +}
  271 +
  272 +
  273 +/*==========================================================================
  274 + = =
  275 + = Private methods =
  276 + = =
  277 + ==========================================================================*/
  278 +
  279 +/***********************************************************************//**
  280 + * @brief Initialise class members
  281 + ***************************************************************************/
  282 +void GFitsTableBoolCol::init_members(void)
  283 +{
  284 + // Initialise members
  285 + m_type = __TLOGICAL;
  286 + m_data = NULL;
  287 + m_buffer = NULL;
  288 + m_nulval = NULL;
  289 +
  290 + // Return
  291 + return;
  292 +}
  293 +
  294 +
  295 +/***********************************************************************//**
  296 + * @brief Copy class members
  297 + *
  298 + * @param[in] column Column for which members should be copied.
  299 + ***************************************************************************/
  300 +void GFitsTableBoolCol::copy_members(const GFitsTableBoolCol& column)
  301 +{
  302 + // Fetch column data if not yet fetched. The casting circumvents the
  303 + // const correctness
  304 + bool not_loaded = (column.m_data == NULL);
  305 + if (not_loaded) ((GFitsTableBoolCol*)(&column))->fetch_data();
  306 +
  307 + // Copy attributes
  308 + m_type = column.m_type;
  309 + m_size = column.m_size;
  310 +
  311 + // Copy column data
  312 + if (column.m_data != NULL && m_size > 0) {
  313 + alloc_data();
  314 + for (int i = 0; i < m_size; ++i)
  315 + m_data[i] = column.m_data[i];
  316 + }
  317 +
  318 + // Copy NULL value
  319 + alloc_nulval(column.m_nulval);
  320 +
  321 + // Small memory option: release column if it was fetch above
  322 + #if defined(G_SMALL_MEMORY)
  323 + if (not_loaded) ((GFitsTableBoolCol*)(&column))->release_data();
  324 + #endif
  325 +
  326 + // Return
  327 + return;
  328 +}
  329 +
  330 +
  331 +/***********************************************************************//**
  332 + * @brief Delete class members
  333 + ***************************************************************************/
  334 +void GFitsTableBoolCol::free_members(void)
  335 +{
  336 + // Free memory
  337 + if (m_data != NULL) delete [] m_data;
  338 + if (m_nulval != NULL) delete m_nulval;
  339 +
  340 + // Mark memory as freed
  341 + m_data = NULL;
  342 + m_nulval = NULL;
  343 +
  344 + // Reset load flag
  345 + m_size = 0;
  346 +
  347 + // Free buffer
  348 + free_buffer();
  349 +
  350 + // Return
  351 + return;
  352 +}
  353 +
  354 +
  355 +/***********************************************************************//**
  356 + * @brief Save table column into FITS file
  357 + *
  358 + * The table column is only saved if it is linked to a FITS file and if the
  359 + * data are indeed present in the class instance. This avoids saving of data
  360 + * that have not been modified.
  361 + *
  362 + * Refer to GFitsTableCol::save_column() for more information.
  363 + ***************************************************************************/
  364 +void GFitsTableBoolCol::save(void)
  365 +{
  366 + // Free buffer
  367 + free_buffer();
  368 +
  369 + // Allocate buffer
  370 + alloc_buffer();
  371 +
  372 + // Transfer string into buffer
  373 + for (int i = 0; i < m_size; ++i)
  374 + m_buffer[i] = (char)m_data[i];
  375 +
  376 + // Save column
  377 + save_column();
  378 +
  379 + // Free buffer
  380 + free_buffer();
  381 +
  382 + // Return
  383 + return;
  384 +}
  385 +
  386 +
  387 +/***********************************************************************//**
  388 + * @brief Clone column
  389 + ***************************************************************************/
  390 +GFitsTableBoolCol* GFitsTableBoolCol::clone(void) const
  391 +{
  392 + return new GFitsTableBoolCol(*this);
  393 +}
  394 +
  395 +
  396 +/***********************************************************************//**
  397 + * @brief Returns format string of ASCII table
  398 + ***************************************************************************/
  399 +std::string GFitsTableBoolCol::ascii_format(void) const
  400 +{
  401 + // Initialize format string
  402 + std::string format;
  403 +
  404 + // Set type code
  405 + format.append("L");
  406 +
  407 + // Set width
  408 + format.append(str(m_width));
  409 +
  410 + // Return format
  411 + return format;
  412 +}
  413 +
  414 +
  415 +/***********************************************************************//**
  416 + * @brief Returns format string of binary table
  417 + ***************************************************************************/
  418 +std::string GFitsTableBoolCol::binary_format(void) const
  419 +{
  420 + // Initialize format string
  421 + std::string format;
  422 +
  423 + // Set number of elements
  424 + format.append(str(m_number));
  425 +
  426 + // Set type code
  427 + format.append("L");
  428 +
  429 + // Return format
  430 + return format;
  431 +}
  432 +
  433 +
  434 +/***********************************************************************//**
  435 + * @brief Allocates column data
  436 + ***************************************************************************/
  437 +void GFitsTableBoolCol::alloc_data(void)
  438 +{
  439 + // Free any existing memory
  440 + if (m_data != NULL) delete [] m_data;
  441 +
  442 + // Mark pointer as free
  443 + m_data = NULL;
  444 +
  445 + // Allocate new data
  446 + if (m_size > 0)
  447 + m_data = new bool[m_size];
  448 +
  449 + // Return
  450 + return;
  451 +}
  452 +
  453 +
  454 +/***********************************************************************//**
  455 + * @brief Release column data
  456 + ***************************************************************************/
  457 +void GFitsTableBoolCol::release_data(void)
  458 +{
  459 + // Free any existing memory
  460 + if (m_data != NULL) delete [] m_data;
  461 +
  462 + // Mark pointer as free and reset loaded vector size
  463 + m_data = NULL;
  464 + m_size = 0;
  465 +
  466 + // Return
  467 + return;
  468 +}
  469 +
  470 +
  471 +/***********************************************************************//**
  472 + * @brief Allocate null value
  473 + ***************************************************************************/
  474 +void GFitsTableBoolCol::alloc_nulval(const bool* value)
  475 +{
  476 + // Free any existing memory
  477 + if (m_nulval != NULL) delete m_nulval;
  478 +
  479 + // Mark pointer as free
  480 + m_nulval = NULL;
  481 +
  482 + // If we have valid value, allocate and set null value
  483 + if (value != NULL) {
  484 + m_nulval = new bool;
  485 + *m_nulval = *value;
  486 + }
  487 +
  488 + // Return
  489 + return;
  490 +}
  491 +
  492 +
  493 +/***********************************************************************//**
  494 + * @brief Initialise column data
  495 + ***************************************************************************/
  496 +void GFitsTableBoolCol::init_data(void)
  497 +{
  498 + // Initialise data if they exist
  499 + if (m_data != NULL) {
  500 + for (int i = 0; i < m_size; ++i)
  501 + m_data[i] = false;
  502 + }
  503 +
  504 + // Return
  505 + return;
  506 +}
  507 +
  508 +
  509 +/***********************************************************************//**
  510 + * @brief Fetch column data
  511 + *
  512 + * If a FITS file is attached to the column the data are loaded into memory
  513 + * from the FITS file. If no FITS file is attached, memory is allocated
  514 + * to hold the column data and all cells are set to 0.
  515 + *
  516 + * Refer to GFitsTableCol::load_column for more information.
  517 + ***************************************************************************/
  518 +void GFitsTableBoolCol::fetch_data(void)
  519 +{
  520 + // Calculate size of memory
  521 + m_size = m_number * m_length;
  522 +
  523 + // Free old buffer memory
  524 + free_buffer();
  525 +
  526 + // Allocate buffer memory
  527 + alloc_buffer();
  528 +
  529 + // Save column
  530 + load_column();
  531 +
  532 + // Extract values from buffer
  533 + for (int i = 0; i < m_size; ++i)
  534 + m_data[i] = (bool)m_buffer[i];
  535 +
  536 + // Free buffer memory
  537 + free_buffer();
  538 +
  539 + // Return
  540 + return;
  541 +}
  542 +
  543 +
  544 +/***********************************************************************//**
  545 + * @brief Allocate CFITSIO transfer buffer
  546 + *
  547 + * The CFITSIO transfer buffer allows transparent conversion from the CFITSIO
  548 + * storage format to a vector of bool values.
  549 + ***************************************************************************/
  550 +void GFitsTableBoolCol::alloc_buffer(void)
  551 +{
  552 + // Allocate and initialise buffer memory
  553 + if (m_size > 0) {
  554 + m_buffer = new char[m_size];
  555 + for (int i = 0; i < m_size; ++i)
  556 + m_buffer[i] = 0;
  557 + }
  558 +
  559 + // Return
  560 + return;
  561 +}
  562 +
  563 +
  564 +/***********************************************************************//**
  565 + * @brief Free CFITSIO transfer buffer
  566 + *
  567 + * Release memory that has been allocated for the CFITSIO transfer buffer.
  568 + ***************************************************************************/
  569 +void GFitsTableBoolCol::free_buffer(void)
  570 +{
  571 + // Free buffer
  572 + if (m_buffer != NULL) delete [] m_buffer;
  573 +
  574 + // Mark buffer as free
  575 + m_buffer = NULL;
  576 +
  577 + // Return
  578 + return;
  579 +}
  580 +
  581 +
  582 +/*==========================================================================
  583 + = =
  584 + = Friends =
  585 + = =
  586 + ==========================================================================*/
  587 +
  588 +/***********************************************************************//**
  589 + * @brief Output operator
  590 + *
  591 + * @param[in] os Output stream.
  592 + * @param[in] column Column to put in output stream.
  593 + ***************************************************************************/
  594 +std::ostream& operator<< (std::ostream& os, const GFitsTableBoolCol& column)
  595 +{
  596 + // Dump column in output stream
  597 + column.dump_column(os, column.m_data);
  598 +
  599 + // Return output stream
  600 + return os;
  601 +}
... ...
src/fits/GFitsTableCol.cpp
... ... @@ -22,6 +22,7 @@
22 22 /* __ Method name definitions ____________________________________________ */
23 23 #define G_LOAD_COLUMN "GFitsTableCol::load_column()"
24 24 #define G_SAVE_COLUMN "GFitsTableCol::save_column()"
  25 +#define G_OFFSET "GFitsTableCol::offset(const int&, const int&)"
25 26  
26 27 /* __ Macros _____________________________________________________________ */
27 28  
... ... @@ -252,53 +253,19 @@ int GFitsTableCol::length(void)
252 253  
253 254 /*==========================================================================
254 255 = =
255   - = Private methods =
  256 + = Protected methods =
256 257 = =
257 258 ==========================================================================*/
258 259  
259 260 /***********************************************************************//**
260   - * @brief Initialise class members
261   - ***************************************************************************/
262   -void GFitsTableCol::init_members(void)
263   -{
264   - // Initialise members
265   - m_name.clear();
266   - m_unit.clear();
267   - m_colnum = 0;
268   - m_type = 0;
269   - m_repeat = 0;
270   - m_width = 0;
271   - m_number = 0;
272   - m_length = 0;
273   - m_size = 0;
274   - m_anynul = 0;
275   - m_fitsfile.HDUposition = 0;
276   - m_fitsfile.Fptr = NULL;
277   -
278   - // Return
279   - return;
280   -}
281   -
282   -
283   -/***********************************************************************//**
284   - * @brief Copy class members
  261 + * @brief Save table column into FITS file
285 262 *
286   - * @param[in] column Column to be copied
  263 + * Refer to GFitsTableCol::save_column() for more information.
287 264 ***************************************************************************/
288   -void GFitsTableCol::copy_members(const GFitsTableCol& column)
  265 +void GFitsTableCol::save(void)
289 266 {
290   - // Copy attributes
291   - m_name = column.m_name;
292   - m_unit = column.m_unit;
293   - m_colnum = column.m_colnum;
294   - m_type = column.m_type;
295   - m_repeat = column.m_repeat;
296   - m_width = column.m_width;
297   - m_number = column.m_number;
298   - m_length = column.m_length;
299   - m_size = column.m_size;
300   - m_anynul = column.m_anynul;
301   - m_fitsfile = column.m_fitsfile;
  267 + // Save column
  268 + save_column();
302 269  
303 270 // Return
304 271 return;
... ... @@ -306,29 +273,18 @@ void GFitsTableCol::copy_members(const GFitsTableCol&amp; column)
306 273  
307 274  
308 275 /***********************************************************************//**
309   - * @brief Delete class members
310   - ***************************************************************************/
311   -void GFitsTableCol::free_members(void)
312   -{
313   - // Free memory
314   -
315   - // Mark memory as freed
316   -
317   - // Return
318   - return;
319   -}
320   -
321   -
322   -/***********************************************************************//**
323   - * @brief Connect table column to FITS file
  276 + * @brief Fetch column data
324 277 *
325   - * @param[in] fptr FITS file pointer to which the table column should be
326   - * connected
  278 + * If a FITS file is attached to the column the data are loaded into memory
  279 + * from the FITS file. If no FITS file is attached, memory is allocated
  280 + * to hold the column data and all cells are set to 0.
  281 + *
  282 + * Refer to GFitsTableCol::load_column for more information.
327 283 ***************************************************************************/
328   -void GFitsTableCol::connect(__fitsfile* fptr)
  284 +void GFitsTableCol::fetch_data(void)
329 285 {
330   - // Connect Image
331   - m_fitsfile = *fptr;
  286 + // Save column
  287 + load_column();
332 288  
333 289 // Return
334 290 return;
... ... @@ -347,11 +303,11 @@ void GFitsTableCol::connect(__fitsfile* fptr)
347 303 * from the FITS file. If no FITS file is attached, memory is allocated
348 304 * to hold the column data and all cells are set to 0.
349 305 *
350   - * The method make use of the virtual methods
351   - * GFitsTableCol::alloc_data,
352   - * GFitsTableCol::init_data,
353   - * GFitsTableCol::ptr_data, and
354   - * GFitsTableCol::ptr_nulval.
  306 + * The method makes use of the virtual methods
  307 + * GFitsTableCol::alloc_data,
  308 + * GFitsTableCol::init_data,
  309 + * GFitsTableCol::ptr_data, and
  310 + * GFitsTableCol::ptr_nulval.
355 311 * These methods are implemented by the derived column classes which
356 312 * implement a specific storage class (i.e. float, double, short, ...).
357 313 ***************************************************************************/
... ... @@ -488,6 +444,125 @@ void GFitsTableCol::dump_column(std::ostream&amp; os, void* data) const
488 444 }
489 445  
490 446  
  447 +/***********************************************************************//**
  448 + * @brief Convert row and vector index into column offset
  449 + *
  450 + * @param[in] row Row of column.
  451 + * @param[in] inx Vector index in column row.
  452 + *
  453 + * @exception GException::out_of_range
  454 + * Table row or vector index are out of valid range.
  455 + *
  456 + * Converts the row and vector index of a column into a linear offset from
  457 + * the column start.
  458 + ***************************************************************************/
  459 +int GFitsTableCol::offset(const int& row, const int& inx) const
  460 +{
  461 + // Check row value
  462 + #if defined(G_RANGE_CHECK)
  463 + if (row < 0 || row >= m_length)
  464 + throw GException::out_of_range(G_OFFSET, row, 0, m_length-1);
  465 + #endif
  466 +
  467 + // Check inx value
  468 + #if defined(G_RANGE_CHECK)
  469 + if (inx < 0 || inx >= m_number)
  470 + throw GException::out_of_range(G_OFFSET, inx, 0, m_number-1);
  471 + #endif
  472 +
  473 + // Calculate pixel offset
  474 + int offset = row * m_number + inx;
  475 +
  476 + // Return offset
  477 + return offset;
  478 +}
  479 +
  480 +
  481 +/*==========================================================================
  482 + = =
  483 + = Private methods =
  484 + = =
  485 + ==========================================================================*/
  486 +
  487 +/***********************************************************************//**
  488 + * @brief Initialise class members
  489 + ***************************************************************************/
  490 +void GFitsTableCol::init_members(void)
  491 +{
  492 + // Initialise members
  493 + m_name.clear();
  494 + m_unit.clear();
  495 + m_colnum = 0;
  496 + m_type = 0;
  497 + m_repeat = 0;
  498 + m_width = 0;
  499 + m_number = 0;
  500 + m_length = 0;
  501 + m_size = 0;
  502 + m_anynul = 0;
  503 + m_fitsfile.HDUposition = 0;
  504 + m_fitsfile.Fptr = NULL;
  505 +
  506 + // Return
  507 + return;
  508 +}
  509 +
  510 +
  511 +/***********************************************************************//**
  512 + * @brief Copy class members
  513 + *
  514 + * @param[in] column Column to be copied
  515 + ***************************************************************************/
  516 +void GFitsTableCol::copy_members(const GFitsTableCol& column)
  517 +{
  518 + // Copy attributes
  519 + m_name = column.m_name;
  520 + m_unit = column.m_unit;
  521 + m_colnum = column.m_colnum;
  522 + m_type = column.m_type;
  523 + m_repeat = column.m_repeat;
  524 + m_width = column.m_width;
  525 + m_number = column.m_number;
  526 + m_length = column.m_length;
  527 + m_size = column.m_size;
  528 + m_anynul = column.m_anynul;
  529 + m_fitsfile = column.m_fitsfile;
  530 +
  531 + // Return
  532 + return;
  533 +}
  534 +
  535 +
  536 +/***********************************************************************//**
  537 + * @brief Delete class members
  538 + ***************************************************************************/
  539 +void GFitsTableCol::free_members(void)
  540 +{
  541 + // Free memory
  542 +
  543 + // Mark memory as freed
  544 +
  545 + // Return
  546 + return;
  547 +}
  548 +
  549 +
  550 +/***********************************************************************//**
  551 + * @brief Connect table column to FITS file
  552 + *
  553 + * @param[in] fptr FITS file pointer to which the table column should be
  554 + * connected
  555 + ***************************************************************************/
  556 +void GFitsTableCol::connect(__fitsfile* fptr)
  557 +{
  558 + // Connect Image
  559 + m_fitsfile = *fptr;
  560 +
  561 + // Return
  562 + return;
  563 +}
  564 +
  565 +
491 566 /*==========================================================================
492 567 = =
493 568 = GFitsTableCol friends =
... ...
src/fits/GFitsTableDoubleCol.cpp 0 → 100644
  1 +/***************************************************************************
  2 + * GFitsTableDoubleCol.cpp - FITS table double column class *
  3 + * ----------------------------------------------------------------------- *
  4 + * copyright (C) 2010 by Jurgen Knodlseder *
  5 + * ----------------------------------------------------------------------- *
  6 + * *
  7 + * This program is free software; you can redistribute it and/or modify *
  8 + * it under the terms of the GNU General Public License as published by *
  9 + * the Free Software Foundation; either version 2 of the License, or *
  10 + * (at your option) any later version. *
  11 + * *
  12 + ***************************************************************************/
  13 +
  14 +/* __ Includes ___________________________________________________________ */
  15 +#ifdef HAVE_CONFIG_H
  16 +#include <config.h>
  17 +#endif
  18 +#include <iostream>
  19 +#include "GException.hpp"
  20 +#include "GTools.hpp"
  21 +#include "GFitsTableDoubleCol.hpp"
  22 +
  23 +/* __ Method name definitions ____________________________________________ */
  24 +
  25 +/* __ Macros _____________________________________________________________ */
  26 +
  27 +/* __ Coding definitions _________________________________________________ */
  28 +
  29 +/* __ Debug definitions __________________________________________________ */
  30 +
  31 +
  32 +/*==========================================================================
  33 + = =
  34 + = Constructors/destructors =
  35 + = =
  36 + ==========================================================================*/
  37 +
  38 +/***********************************************************************//**
  39 + * @brief Constructor
  40 + ***************************************************************************/
  41 +GFitsTableDoubleCol::GFitsTableDoubleCol(void) : GFitsTableCol()
  42 +{
  43 + // Initialise class members for clean destruction
  44 + init_members();
  45 +
  46 + // Return
  47 + return;
  48 +}
  49 +
  50 +
  51 +/***********************************************************************//**
  52 + * @brief Constructor
  53 + *
  54 + * @param[in] name Name of column.
  55 + * @param[in] length Length of column.
  56 + * @param[in] size Vector size of column.
  57 + ***************************************************************************/
  58 +GFitsTableDoubleCol::GFitsTableDoubleCol(const std::string& name,
  59 + const int& length,
  60 + const int& size)
  61 + : GFitsTableCol(name, length, size, 2)
  62 +{
  63 + // Initialise class members for clean destruction
  64 + init_members();
  65 +
  66 + // Return
  67 + return;
  68 +}
  69 +
  70 +
  71 +/***********************************************************************//**
  72 + * @brief Copy constructor
  73 + *
  74 + * @param[in] column Column from which class instance should be built.
  75 + ***************************************************************************/
  76 +GFitsTableDoubleCol::GFitsTableDoubleCol(const GFitsTableDoubleCol& column)
  77 + : GFitsTableCol(column)
  78 +{
  79 + // Initialise class members for clean destruction
  80 + init_members();
  81 +
  82 + // Copy members
  83 + copy_members(column);
  84 +
  85 + // Return
  86 + return;
  87 +}
  88 +
  89 +
  90 +/***********************************************************************//**
  91 + * @brief Destructor
  92 + ***************************************************************************/
  93 +GFitsTableDoubleCol::~GFitsTableDoubleCol(void)
  94 +{
  95 + // Free members
  96 + free_members();
  97 +
  98 + // Return
  99 + return;
  100 +}
  101 +
  102 +
  103 +/*==========================================================================
  104 + = =
  105 + = Operators =
  106 + = =
  107 + ==========================================================================*/
  108 +
  109 +/***********************************************************************//**
  110 + * @brief Assignment operator
  111 + *
  112 + * @param[in] column Column which should be assigned
  113 + ***************************************************************************/
  114 +GFitsTableDoubleCol& GFitsTableDoubleCol::operator= (const GFitsTableDoubleCol& column)
  115 +{
  116 + // Execute only if object is not identical
  117 + if (this != &column) {
  118 +
  119 + // Copy base class members
  120 + this->GFitsTableCol::operator=(column);
  121 +
  122 + // Free members
  123 + free_members();
  124 +
  125 + // Initialise private members for clean destruction
  126 + init_members();
  127 +
  128 + // Copy members
  129 + copy_members(column);
  130 +
  131 + } // endif: object was not identical
  132 +
  133 + // Return this object
  134 + return *this;
  135 +}
  136 +
  137 +
  138 +/***********************************************************************//**
  139 + * @brief Column data access operator
  140 + *
  141 + * @param[in] row Row of column to access.
  142 + * @param[in] inx Vector index in column row to access
  143 + *
  144 + * Provides access to data in a column.
  145 + ***************************************************************************/
  146 +double& GFitsTableDoubleCol::operator() (const int& row, const int& inx)
  147 +{
  148 + // If data are not available then load them now
  149 + if (m_data == NULL) fetch_data();
  150 +
  151 + // Return data bin
  152 + return m_data[offset(row, inx)];
  153 +}
  154 +
  155 +
  156 +/***********************************************************************//**
  157 + * @brief Column data access operator (const variant)
  158 + *
  159 + * @param[in] row Row of column to access.
  160 + * @param[in] inx Vector index in column row to access
  161 + *
  162 + * Provides access to data in a column.
  163 + ***************************************************************************/
  164 +const double& GFitsTableDoubleCol::operator() (const int& row, const int& inx) const
  165 +{
  166 + // If data are not available then load them now
  167 + if (m_data == NULL) ((GFitsTableDoubleCol*)this)->fetch_data();
  168 +
  169 + // Return data bin
  170 + return m_data[offset(row, inx)];
  171 +}
  172 +
  173 +
  174 +/*==========================================================================
  175 + = =
  176 + = Public methods =
  177 + = =
  178 + ==========================================================================*/
  179 +
  180 +/***********************************************************************//**
  181 + * @brief Get string value
  182 + *
  183 + * @param[in] row Table row.
  184 + * @param[in] inx Table column vector index.
  185 + *
  186 + * Returns value of specified row and vector index as string.
  187 + ***************************************************************************/
  188 +std::string GFitsTableDoubleCol::string(const int& row, const int& inx)
  189 +{
  190 + // If data are not available then load them now
  191 + if (m_data == NULL) fetch_data();
  192 +
  193 + // Convert double into string
  194 + std::ostringstream s_value;
  195 + s_value << m_data[offset(row,inx)];
  196 +
  197 + // Return value
  198 + return s_value.str();
  199 +}
  200 +
  201 +
  202 +/***********************************************************************//**
  203 + * @brief Get double precision value
  204 + *
  205 + * @param[in] row Table row.
  206 + * @param[in] inx Table column vector index.
  207 + *
  208 + * Returns value of specified row and vector index as double precision.
  209 + ***************************************************************************/
  210 +double GFitsTableDoubleCol::real(const int& row, const int& inx)
  211 +{
  212 + // If data are not available then load them now
  213 + if (m_data == NULL) fetch_data();
  214 +
  215 + // Convert double into double
  216 + double value = (double)m_data[offset(row,inx)];
  217 +
  218 + // Return value
  219 + return value;
  220 +}
  221 +
  222 +
  223 +/***********************************************************************//**
  224 + * @brief Get integer value
  225 + *
  226 + * @param[in] row Table row.
  227 + * @param[in] inx Table column vector index.
  228 + *
  229 + * Returns value of specified row and vector index as integer.
  230 + ***************************************************************************/
  231 +int GFitsTableDoubleCol::integer(const int& row, const int& inx)
  232 +{
  233 + // If data are not available then load them now
  234 + if (m_data == NULL) fetch_data();
  235 +
  236 + // Convert double into int
  237 + int value = (int)m_data[offset(row,inx)];
  238 +
  239 + // Return value
  240 + return value;
  241 +}
  242 +
  243 +
  244 +/***********************************************************************//**
  245 + * @brief Set NULL value
  246 + *
  247 + * @param[in] value Pointer on NULL value
  248 + *
  249 + * Allows the specification of the FITS table NULL value. If value=NULL the
  250 + * data will not be screened for NULL values.
  251 + *
  252 + * @todo To correctly reflect the NULL value in the data, the column should
  253 + * be reloaded. However, the column may have been changed, so in principle
  254 + * saving is needed. However, we may not want to store the data, hence saving
  255 + * is also not desired. We thus have to develop a method to update the
  256 + * column information for a new NULL value in place ...
  257 + ***************************************************************************/
  258 +void GFitsTableDoubleCol::nullval(const double* value)
  259 +{
  260 + // Allocate nul value
  261 + alloc_nulval(value);
  262 +
  263 + // Update column
  264 +// if (m_data != NULL) {
  265 +// save();
  266 +// load();
  267 +// }
  268 +
  269 + // Return
  270 + return;
  271 +}
  272 +
  273 +
  274 +/*==========================================================================
  275 + = =
  276 + = Private methods =
  277 + = =
  278 + ==========================================================================*/
  279 +
  280 +/***********************************************************************//**
  281 + * @brief Initialise class members
  282 + ***************************************************************************/
  283 +void GFitsTableDoubleCol::init_members(void)
  284 +{
  285 + // Initialise members
  286 + m_type = __TDOUBLE;
  287 + m_data = NULL;
  288 + m_nulval = NULL;
  289 +
  290 + // Return
  291 + return;
  292 +}
  293 +
  294 +
  295 +/***********************************************************************//**
  296 + * @brief Copy class members
  297 + *
  298 + * @param[in] column Column for which members should be copied.
  299 + *
  300 + * Sets the content of the vector column by copying from another column.
  301 + * If the code is compiled with the small memory option, and if the source
  302 + * column has not yet been loaded, then we only load the column temporarily
  303 + * for copying purposes and release it again once copying is finished.
  304 + ***************************************************************************/
  305 +void GFitsTableDoubleCol::copy_members(const GFitsTableDoubleCol& column)
  306 +{
  307 + // Fetch column data if not yet fetched. The casting circumvents the
  308 + // const correctness
  309 + bool not_loaded = (column.m_data == NULL);
  310 + if (not_loaded) ((GFitsTableDoubleCol*)(&column))->fetch_data();
  311 +
  312 + // Copy attributes
  313 + m_type = column.m_type;
  314 + m_size = column.m_size;
  315 +
  316 + // Copy column data
  317 + if (column.m_data != NULL && m_size > 0) {
  318 + alloc_data();
  319 + for (int i = 0; i < m_size; ++i)
  320 + m_data[i] = column.m_data[i];
  321 + }
  322 +
  323 + // Copy NULL value
  324 + alloc_nulval(column.m_nulval);
  325 +
  326 + // Small memory option: release column if it was fetch above
  327 + #if defined(G_SMALL_MEMORY)
  328 + if (not_loaded) ((GFitsTableDoubleCol*)(&column))->release_data();
  329 + #endif
  330 +
  331 + // Return
  332 + return;
  333 +}
  334 +
  335 +
  336 +/***********************************************************************//**
  337 + * @brief Delete class members
  338 + ***************************************************************************/
  339 +void GFitsTableDoubleCol::free_members(void)
  340 +{
  341 + // Free memory
  342 + if (m_data != NULL) delete [] m_data;
  343 + if (m_nulval != NULL) delete m_nulval;
  344 +
  345 + // Mark memory as freed
  346 + m_data = NULL;
  347 + m_nulval = NULL;
  348 +
  349 + // Reset load flag
  350 + m_size = 0;
  351 +
  352 + // Return
  353 + return;
  354 +}
  355 +
  356 +
  357 +/***********************************************************************//**
  358 + * @brief Clone column
  359 + ***************************************************************************/
  360 +GFitsTableDoubleCol* GFitsTableDoubleCol::clone(void) const
  361 +{
  362 + return new GFitsTableDoubleCol(*this);
  363 +}
  364 +
  365 +
  366 +/***********************************************************************//**
  367 + * @brief Returns format string of ASCII table
  368 + ***************************************************************************/
  369 +std::string GFitsTableDoubleCol::ascii_format(void) const
  370 +{
  371 + // Initialize format string
  372 + std::string format;
  373 +
  374 + // Set type code
  375 + format.append("F");
  376 +
  377 + // Set width
  378 + format.append(str(m_width));
  379 +
  380 + // Return format
  381 + return format;
  382 +}
  383 +
  384 +
  385 +/***********************************************************************//**
  386 + * @brief Returns format string of binary table
  387 + ***************************************************************************/
  388 +std::string GFitsTableDoubleCol::binary_format(void) const
  389 +{
  390 + // Initialize format string
  391 + std::string format;
  392 +
  393 + // Set number of elements
  394 + format.append(str(m_number));
  395 +
  396 + // Set type code
  397 + format.append("D");
  398 +
  399 + // Return format
  400 + return format;
  401 +}
  402 +
  403 +
  404 +/***********************************************************************//**
  405 + * @brief Allocates column data
  406 + ***************************************************************************/
  407 +void GFitsTableDoubleCol::alloc_data(void)
  408 +{
  409 + // Free any existing memory
  410 + if (m_data != NULL) delete [] m_data;
  411 +
  412 + // Mark pointer as free
  413 + m_data = NULL;
  414 +
  415 + // Allocate new data
  416 + if (m_size > 0)
  417 + m_data = new double[m_size];
  418 +
  419 + // Return
  420 + return;
  421 +}
  422 +
  423 +
  424 +/***********************************************************************//**
  425 + * @brief Release column data
  426 + ***************************************************************************/
  427 +void GFitsTableDoubleCol::release_data(void)
  428 +{
  429 + // Free any existing memory
  430 + if (m_data != NULL) delete [] m_data;
  431 +
  432 + // Mark pointer as free and reset loaded vector size
  433 + m_data = NULL;
  434 + m_size = 0;
  435 +
  436 + // Return
  437 + return;
  438 +}
  439 +
  440 +
  441 +/***********************************************************************//**
  442 + * @brief Allocates null value
  443 + ***************************************************************************/
  444 +void GFitsTableDoubleCol::alloc_nulval(const double* value)
  445 +{
  446 + // Free any existing memory
  447 + if (m_nulval != NULL) delete m_nulval;
  448 +
  449 + // Mark pointer as free
  450 + m_nulval = NULL;
  451 +
  452 + // If we have valid value, allocate and set nul value
  453 + if (value != NULL) {
  454 + m_nulval = new double;
  455 + *m_nulval = *value;
  456 + }
  457 +
  458 + // Return
  459 + return;
  460 +}
  461 +
  462 +
  463 +/***********************************************************************//**
  464 + * @brief Initialise column data
  465 + ***************************************************************************/
  466 +void GFitsTableDoubleCol::init_data(void)
  467 +{
  468 + // Initialise data if they exist
  469 + if (m_data != NULL) {
  470 + for (int i = 0; i < m_size; ++i)
  471 + m_data[i] = 0.0;
  472 + }
  473 +
  474 + // Return
  475 + return;
  476 +}
  477 +
  478 +
  479 +/*==========================================================================
  480 + = =
  481 + = Friends =
  482 + = =
  483 + ==========================================================================*/
  484 +
  485 +/***********************************************************************//**
  486 + * @brief Output operator
  487 + *
  488 + * @param[in] os Output stream
  489 + * @param[in] column Column to put in output stream
  490 + ***************************************************************************/
  491 +std::ostream& operator<< (std::ostream& os, const GFitsTableDoubleCol& column)
  492 +{
  493 + // Dump column in output stream
  494 + column.dump_column(os, column.m_data);
  495 +
  496 + // Return output stream
  497 + return os;
  498 +}
... ...
src/fits/GFitsTableFloatCol.cpp 0 → 100644
  1 +/***************************************************************************
  2 + * GFitsTableFloatCol.cpp - FITS table float column class *
  3 + * ----------------------------------------------------------------------- *
  4 + * copyright (C) 2010 by Jurgen Knodlseder *
  5 + * ----------------------------------------------------------------------- *
  6 + * *
  7 + * This program is free software; you can redistribute it and/or modify *
  8 + * it under the terms of the GNU General Public License as published by *
  9 + * the Free Software Foundation; either version 2 of the License, or *
  10 + * (at your option) any later version. *
  11 + * *
  12 + ***************************************************************************/
  13 +
  14 +/* __ Includes ___________________________________________________________ */
  15 +#ifdef HAVE_CONFIG_H
  16 +#include <config.h>
  17 +#endif
  18 +#include <iostream>
  19 +#include "GException.hpp"
  20 +#include "GTools.hpp"
  21 +#include "GFitsTableFloatCol.hpp"
  22 +
  23 +/* __ Method name definitions ____________________________________________ */
  24 +
  25 +/* __ Macros _____________________________________________________________ */
  26 +
  27 +/* __ Coding definitions _________________________________________________ */
  28 +
  29 +/* __ Debug definitions __________________________________________________ */
  30 +
  31 +
  32 +/*==========================================================================
  33 + = =
  34 + = Constructors/destructors =
  35 + = =
  36 + ==========================================================================*/
  37 +
  38 +/***********************************************************************//**
  39 + * @brief Constructor
  40 + ***************************************************************************/
  41 +GFitsTableFloatCol::GFitsTableFloatCol(void) : GFitsTableCol()
  42 +{
  43 + // Initialise class members for clean destruction
  44 + init_members();
  45 +
  46 + // Return
  47 + return;
  48 +}
  49 +
  50 +
  51 +/***********************************************************************//**
  52 + * @brief Constructor
  53 + *
  54 + * @param[in] name Name of column.
  55 + * @param[in] length Length of column.
  56 + * @param[in] size Vector size of column.
  57 + ***************************************************************************/
  58 +GFitsTableFloatCol::GFitsTableFloatCol(const std::string& name,
  59 + const int& length,
  60 + const int& size)
  61 + : GFitsTableCol(name, length, size, 2)
  62 +{
  63 + // Initialise class members for clean destruction
  64 + init_members();
  65 +
  66 + // Return
  67 + return;
  68 +}
  69 +
  70 +
  71 +/***********************************************************************//**
  72 + * @brief Copy constructor
  73 + *
  74 + * @param[in] column Column from which class instance should be built.
  75 + ***************************************************************************/
  76 +GFitsTableFloatCol::GFitsTableFloatCol(const GFitsTableFloatCol& column)
  77 + : GFitsTableCol(column)
  78 +{
  79 + // Initialise class members for clean destruction
  80 + init_members();
  81 +
  82 + // Copy members
  83 + copy_members(column);
  84 +
  85 + // Return
  86 + return;
  87 +}
  88 +
  89 +
  90 +/***********************************************************************//**
  91 + * @brief Destructor
  92 + ***************************************************************************/
  93 +GFitsTableFloatCol::~GFitsTableFloatCol(void)
  94 +{
  95 + // Free members
  96 + free_members();
  97 +
  98 + // Return
  99 + return;
  100 +}
  101 +
  102 +
  103 +/*==========================================================================
  104 + = =
  105 + = Operators =
  106 + = =
  107 + ==========================================================================*/
  108 +
  109 +/***********************************************************************//**
  110 + * @brief Assignment operator
  111 + *
  112 + * @param[in] column Column which should be assigned
  113 + ***************************************************************************/
  114 +GFitsTableFloatCol& GFitsTableFloatCol::operator= (const GFitsTableFloatCol& column)
  115 +{
  116 + // Execute only if object is not identical
  117 + if (this != &column) {
  118 +
  119 + // Copy base class members
  120 + this->GFitsTableCol::operator=(column);
  121 +
  122 + // Free members
  123 + free_members();
  124 +
  125 + // Initialise private members for clean destruction
  126 + init_members();
  127 +
  128 + // Copy members
  129 + copy_members(column);
  130 +
  131 + } // endif: object was not identical
  132 +
  133 + // Return this object
  134 + return *this;
  135 +}
  136 +
  137 +
  138 +/***********************************************************************//**
  139 + * @brief Column data access operator
  140 + *
  141 + * @param[in] row Row of column to access.
  142 + * @param[in] inx Vector index in column row to access
  143 + *
  144 + * Provides access to data in a column.
  145 + ***************************************************************************/
  146 +float& GFitsTableFloatCol::operator() (const int& row, const int& inx)
  147 +{
  148 + // If data are not available then load them now
  149 + if (m_data == NULL) fetch_data();
  150 +
  151 + // Return data bin
  152 + return m_data[offset(row, inx)];
  153 +}
  154 +
  155 +
  156 +/***********************************************************************//**
  157 + * @brief Column data access operator (const variant)
  158 + *
  159 + * @param[in] row Row of column to access.
  160 + * @param[in] inx Vector index in column row to access
  161 + *
  162 + * Provides access to data in a column.
  163 + ***************************************************************************/
  164 +const float& GFitsTableFloatCol::operator() (const int& row, const int& inx) const
  165 +{
  166 + // If data are not available then load them now
  167 + if (m_data == NULL) ((GFitsTableFloatCol*)this)->fetch_data();
  168 +
  169 + // Return data bin
  170 + return m_data[offset(row, inx)];
  171 +}
  172 +
  173 +
  174 +/*==========================================================================
  175 + = =
  176 + = Public methods =
  177 + = =
  178 + ==========================================================================*/
  179 +
  180 +/***********************************************************************//**
  181 + * @brief Get string value
  182 + *
  183 + * @param[in] row Table row.
  184 + * @param[in] inx Table column vector index.
  185 + *
  186 + * Returns value of specified row and vector index as string.
  187 + ***************************************************************************/
  188 +std::string GFitsTableFloatCol::string(const int& row, const int& inx)
  189 +{
  190 + // If data are not available then load them now
  191 + if (m_data == NULL) fetch_data();
  192 +
  193 + // Convert float into string
  194 + std::ostringstream s_value;
  195 + s_value << m_data[offset(row,inx)];
  196 +
  197 + // Return value
  198 + return s_value.str();
  199 +}
  200 +
  201 +
  202 +/***********************************************************************//**
  203 + * @brief Get double precision value
  204 + *
  205 + * @param[in] row Table row.
  206 + * @param[in] inx Table column vector index.
  207 + *
  208 + * Returns value of specified row and vector index as double precision.
  209 + ***************************************************************************/
  210 +double GFitsTableFloatCol::real(const int& row, const int& inx)
  211 +{
  212 + // If data are not available then load them now
  213 + if (m_data == NULL) fetch_data();
  214 +
  215 + // Convert float into double
  216 + double value = (double)m_data[offset(row,inx)];
  217 +
  218 + // Return value
  219 + return value;
  220 +}
  221 +
  222 +
  223 +/***********************************************************************//**
  224 + * @brief Get integer value
  225 + *
  226 + * @param[in] row Table row.
  227 + * @param[in] inx Table column vector index.
  228 + *
  229 + * Returns value of specified row and vector index as integer.
  230 + ***************************************************************************/
  231 +int GFitsTableFloatCol::integer(const int& row, const int& inx)
  232 +{
  233 + // If data are not available then load them now
  234 + if (m_data == NULL) fetch_data();
  235 +
  236 + // Convert float into int
  237 + int value = (int)m_data[offset(row,inx)];
  238 +
  239 + // Return value
  240 + return value;
  241 +}
  242 +
  243 +
  244 +/***********************************************************************//**
  245 + * @brief Set NULL value
  246 + *
  247 + * @param[in] value Pointer on NULL value
  248 + *
  249 + * Allows the specification of the FITS table NULL value. If value=NULL the
  250 + * data will not be screened for NULL values.
  251 + *
  252 + * @todo To correctly reflect the NULL value in the data, the column should
  253 + * be reloaded. However, the column may have been changed, so in principle
  254 + * saving is needed. However, we may not want to store the data, hence saving
  255 + * is also not desired. We thus have to develop a method to update the
  256 + * column information for a new NULL value in place ...
  257 + ***************************************************************************/
  258 +void GFitsTableFloatCol::nullval(const float* value)
  259 +{
  260 + // Allocate nul value
  261 + alloc_nulval(value);
  262 +
  263 + // Update column
  264 +// if (m_data != NULL) {
  265 +// save();
  266 +// load();
  267 +// }
  268 +
  269 + // Return
  270 + return;
  271 +}
  272 +
  273 +
  274 +/*==========================================================================
  275 + = =
  276 + = Private methods =
  277 + = =
  278 + ==========================================================================*/
  279 +
  280 +/***********************************************************************//**
  281 + * @brief Initialise class members
  282 + ***************************************************************************/
  283 +void GFitsTableFloatCol::init_members(void)
  284 +{
  285 + // Initialise members
  286 + m_type = __TFLOAT;
  287 + m_data = NULL;
  288 + m_nulval = NULL;
  289 +
  290 + // Return
  291 + return;
  292 +}
  293 +
  294 +
  295 +/***********************************************************************//**
  296 + * @brief Copy class members
  297 + *
  298 + * @param[in] column Column for which members should be copied.
  299 + *
  300 + * Sets the content of the vector column by copying from another column.
  301 + * If the code is compiled with the small memory option, and if the source
  302 + * column has not yet been loaded, then we only load the column temporarily
  303 + * for copying purposes and release it again once copying is finished.
  304 + ***************************************************************************/
  305 +void GFitsTableFloatCol::copy_members(const GFitsTableFloatCol& column)
  306 +{
  307 + // Fetch column data if not yet fetched. The casting circumvents the
  308 + // const correctness
  309 + bool not_loaded = (column.m_data == NULL);
  310 + if (not_loaded) ((GFitsTableFloatCol*)(&column))->fetch_data();
  311 +
  312 + // Copy attributes
  313 + m_type = column.m_type;
  314 + m_size = column.m_size;
  315 +
  316 + // Copy column data
  317 + if (column.m_data != NULL && m_size > 0) {
  318 + alloc_data();
  319 + for (int i = 0; i < m_size; ++i)
  320 + m_data[i] = column.m_data[i];
  321 + }
  322 +
  323 + // Copy NULL value
  324 + alloc_nulval(column.m_nulval);
  325 +
  326 + // Small memory option: release column if it was fetch above
  327 + #if defined(G_SMALL_MEMORY)
  328 + if (not_loaded) ((GFitsTableFloatCol*)(&column))->release_data();
  329 + #endif
  330 +
  331 + // Return
  332 + return;
  333 +}
  334 +
  335 +
  336 +/***********************************************************************//**
  337 + * @brief Delete class members
  338 + ***************************************************************************/
  339 +void GFitsTableFloatCol::free_members(void)
  340 +{
  341 + // Free memory
  342 + if (m_data != NULL) delete [] m_data;
  343 + if (m_nulval != NULL) delete m_nulval;
  344 +
  345 + // Mark memory as freed
  346 + m_data = NULL;
  347 + m_nulval = NULL;
  348 +
  349 + // Reset load flag
  350 + m_size = 0;
  351 +
  352 + // Return
  353 + return;
  354 +}
  355 +
  356 +
  357 +/***********************************************************************//**
  358 + * @brief Clone column
  359 + ***************************************************************************/
  360 +GFitsTableFloatCol* GFitsTableFloatCol::clone(void) const
  361 +{
  362 + return new GFitsTableFloatCol(*this);
  363 +}
  364 +
  365 +
  366 +/***********************************************************************//**
  367 + * @brief Returns format string of ASCII table
  368 + ***************************************************************************/
  369 +std::string GFitsTableFloatCol::ascii_format(void) const
  370 +{
  371 + // Initialize format string
  372 + std::string format;
  373 +
  374 + // Set type code
  375 + format.append("F");
  376 +
  377 + // Set width
  378 + format.append(str(m_width));
  379 +
  380 + // Return format
  381 + return format;
  382 +}
  383 +
  384 +
  385 +/***********************************************************************//**
  386 + * @brief Returns format string of binary table
  387 + ***************************************************************************/
  388 +std::string GFitsTableFloatCol::binary_format(void) const
  389 +{
  390 + // Initialize format string
  391 + std::string format;
  392 +
  393 + // Set number of elements
  394 + format.append(str(m_number));
  395 +
  396 + // Set type code
  397 + format.append("E");
  398 +
  399 + // Return format
  400 + return format;
  401 +}
  402 +
  403 +
  404 +/***********************************************************************//**
  405 + * @brief Allocates column data
  406 + ***************************************************************************/
  407 +void GFitsTableFloatCol::alloc_data(void)
  408 +{
  409 + // Free any existing memory
  410 + if (m_data != NULL) delete [] m_data;
  411 +
  412 + // Mark pointer as free
  413 + m_data = NULL;
  414 +
  415 + // Allocate new data
  416 + if (m_size > 0)
  417 + m_data = new float[m_size];
  418 +
  419 + // Return
  420 + return;
  421 +}
  422 +
  423 +
  424 +/***********************************************************************//**
  425 + * @brief Release column data
  426 + ***************************************************************************/
  427 +void GFitsTableFloatCol::release_data(void)
  428 +{
  429 + // Free any existing memory
  430 + if (m_data != NULL) delete [] m_data;
  431 +
  432 + // Mark pointer as free and reset loaded vector size
  433 + m_data = NULL;
  434 + m_size = 0;
  435 +
  436 + // Return
  437 + return;
  438 +}
  439 +
  440 +
  441 +/***********************************************************************//**
  442 + * @brief Allocates null value
  443 + ***************************************************************************/
  444 +void GFitsTableFloatCol::alloc_nulval(const float* value)
  445 +{
  446 + // Free any existing memory
  447 + if (m_nulval != NULL) delete m_nulval;
  448 +
  449 + // Mark pointer as free
  450 + m_nulval = NULL;
  451 +
  452 + // If we have valid value, allocate and set nul value
  453 + if (value != NULL) {
  454 + m_nulval = new float;
  455 + *m_nulval = *value;
  456 + }
  457 +
  458 + // Return
  459 + return;
  460 +}
  461 +
  462 +
  463 +/***********************************************************************//**
  464 + * @brief Initialise column data
  465 + ***************************************************************************/
  466 +void GFitsTableFloatCol::init_data(void)
  467 +{
  468 + // Initialise data if they exist
  469 + if (m_data != NULL) {
  470 + for (int i = 0; i < m_size; ++i)
  471 + m_data[i] = 0.0;
  472 + }
  473 +
  474 + // Return
  475 + return;
  476 +}
  477 +
  478 +
  479 +/*==========================================================================
  480 + = =
  481 + = Friends =
  482 + = =
  483 + ==========================================================================*/
  484 +
  485 +/***********************************************************************//**
  486 + * @brief Output operator
  487 + *
  488 + * @param[in] os Output stream.
  489 + * @param[in] column Column to put in output stream.
  490 + ***************************************************************************/
  491 +std::ostream& operator<< (std::ostream& os, const GFitsTableFloatCol& column)
  492 +{
  493 + // Dump column in output stream
  494 + column.dump_column(os, column.m_data);
  495 +
  496 + // Return output stream
  497 + return os;
  498 +}
... ...
src/fits/GFitsTableLongCol.cpp 0 → 100644
  1 +/***************************************************************************
  2 + * GFitsTableLongCol.cpp - FITS table long column class *
  3 + * ----------------------------------------------------------------------- *
  4 + * copyright (C) 2010 by Jurgen Knodlseder *
  5 + * ----------------------------------------------------------------------- *
  6 + * *
  7 + * This program is free software; you can redistribute it and/or modify *
  8 + * it under the terms of the GNU General Public License as published by *
  9 + * the Free Software Foundation; either version 2 of the License, or *
  10 + * (at your option) any later version. *
  11 + * *
  12 + ***************************************************************************/
  13 +
  14 +/* __ Includes ___________________________________________________________ */
  15 +#ifdef HAVE_CONFIG_H
  16 +#include <config.h>
  17 +#endif
  18 +#include <iostream>
  19 +#include "GException.hpp"
  20 +#include "GTools.hpp"
  21 +#include "GFitsTableLongCol.hpp"
  22 +
  23 +/* __ Method name definitions ____________________________________________ */
  24 +
  25 +/* __ Macros _____________________________________________________________ */
  26 +
  27 +/* __ Coding definitions _________________________________________________ */
  28 +
  29 +/* __ Debug definitions __________________________________________________ */
  30 +
  31 +
  32 +/*==========================================================================
  33 + = =
  34 + = Constructors/destructors =
  35 + = =
  36 + ==========================================================================*/
  37 +
  38 +/***********************************************************************//**
  39 + * @brief Constructor
  40 + ***************************************************************************/
  41 +GFitsTableLongCol::GFitsTableLongCol(void) : GFitsTableCol()
  42 +{
  43 + // Initialise class members for clean destruction
  44 + init_members();
  45 +
  46 + // Return
  47 + return;
  48 +}
  49 +
  50 +
  51 +/***********************************************************************//**
  52 + * @brief Constructor
  53 + *
  54 + * @param[in] name Name of column.
  55 + * @param[in] length Length of column.
  56 + * @param[in] size Vector size of column.
  57 + ***************************************************************************/
  58 +GFitsTableLongCol::GFitsTableLongCol(const std::string& name,
  59 + const int& length,
  60 + const int& size)
  61 + : GFitsTableCol(name, length, size, 2)
  62 +{
  63 + // Initialise class members for clean destruction
  64 + init_members();
  65 +
  66 + // Return
  67 + return;
  68 +}
  69 +
  70 +
  71 +/***********************************************************************//**
  72 + * @brief Copy constructor
  73 + *
  74 + * @param[in] column Column from which class instance should be built.
  75 + ***************************************************************************/
  76 +GFitsTableLongCol::GFitsTableLongCol(const GFitsTableLongCol& column)
  77 + : GFitsTableCol(column)
  78 +{
  79 + // Initialise class members for clean destruction
  80 + init_members();
  81 +
  82 + // Copy members
  83 + copy_members(column);
  84 +
  85 + // Return
  86 + return;
  87 +}
  88 +
  89 +
  90 +/***********************************************************************//**
  91 + * @brief Destructor
  92 + ***************************************************************************/
  93 +GFitsTableLongCol::~GFitsTableLongCol(void)
  94 +{
  95 + // Free members
  96 + free_members();
  97 +
  98 + // Return
  99 + return;
  100 +}
  101 +
  102 +
  103 +/*==========================================================================
  104 + = =
  105 + = Operators =
  106 + = =
  107 + ==========================================================================*/
  108 +
  109 +/***********************************************************************//**
  110 + * @brief Assignment operator
  111 + *
  112 + * @param[in] column Column which should be assigned
  113 + ***************************************************************************/
  114 +GFitsTableLongCol& GFitsTableLongCol::operator= (const GFitsTableLongCol& column)
  115 +{
  116 + // Execute only if object is not identical
  117 + if (this != &column) {
  118 +
  119 + // Copy base class members
  120 + this->GFitsTableCol::operator=(column);
  121 +
  122 + // Free members
  123 + free_members();
  124 +
  125 + // Initialise private members for clean destruction
  126 + init_members();
  127 +
  128 + // Copy members
  129 + copy_members(column);
  130 +
  131 + } // endif: object was not identical
  132 +
  133 + // Return this object
  134 + return *this;
  135 +}
  136 +
  137 +
  138 +/***********************************************************************//**
  139 + * @brief Column data access operator
  140 + *
  141 + * @param[in] row Row of column to access.
  142 + * @param[in] inx Vector index in column row to access
  143 + *
  144 + * Provides access to data in a column.
  145 + ***************************************************************************/
  146 +long& GFitsTableLongCol::operator() (const int& row, const int& inx)
  147 +{
  148 + // If data are not available then load them now
  149 + if (m_data == NULL) fetch_data();
  150 +
  151 + // Return data bin
  152 + return m_data[offset(row, inx)];
  153 +}
  154 +
  155 +
  156 +/***********************************************************************//**
  157 + * @brief Column data access operator (const variant)
  158 + *
  159 + * @param[in] row Row of column to access.
  160 + * @param[in] inx Vector index in column row to access
  161 + *
  162 + * Provides access to data in a column.
  163 + ***************************************************************************/
  164 +const long& GFitsTableLongCol::operator() (const int& row, const int& inx) const
  165 +{
  166 + // If data are not available then load them now
  167 + if (m_data == NULL) ((GFitsTableLongCol*)this)->fetch_data();
  168 +
  169 + // Return data bin
  170 + return m_data[offset(row, inx)];
  171 +}
  172 +
  173 +
  174 +/*==========================================================================
  175 + = =
  176 + = Public methods =
  177 + = =
  178 + ==========================================================================*/
  179 +
  180 +/***********************************************************************//**
  181 + * @brief Get string value
  182 + *
  183 + * @param[in] row Table row.
  184 + * @param[in] inx Table column vector index.
  185 + *
  186 + * Returns value of specified row and vector index as string.
  187 + ***************************************************************************/
  188 +std::string GFitsTableLongCol::string(const int& row, const int& inx)
  189 +{
  190 + // If data are not available then load them now
  191 + if (m_data == NULL) fetch_data();
  192 +
  193 + // Convert long into string
  194 + std::ostringstream s_value;
  195 + s_value << m_data[offset(row,inx)];
  196 +
  197 + // Return value
  198 + return s_value.str();
  199 +}
  200 +
  201 +
  202 +/***********************************************************************//**
  203 + * @brief Get double precision value
  204 + *
  205 + * @param[in] row Table row.
  206 + * @param[in] inx Table column vector index.
  207 + *
  208 + * Returns value of specified row and vector index as double precision.
  209 + ***************************************************************************/
  210 +double GFitsTableLongCol::real(const int& row, const int& inx)
  211 +{
  212 + // If data are not available then load them now
  213 + if (m_data == NULL) fetch_data();
  214 +
  215 + // Convert long into double
  216 + double value = (double)m_data[offset(row,inx)];
  217 +
  218 + // Return value
  219 + return value;
  220 +}
  221 +
  222 +
  223 +/***********************************************************************//**
  224 + * @brief Get integer value
  225 + *
  226 + * @param[in] row Table row.
  227 + * @param[in] inx Table column vector index.
  228 + *
  229 + * Returns value of specified row and vector index as integer.
  230 + ***************************************************************************/
  231 +int GFitsTableLongCol::integer(const int& row, const int& inx)
  232 +{
  233 + // If data are not available then load them now
  234 + if (m_data == NULL) fetch_data();
  235 +
  236 + // Convert long into int
  237 + int value = (int)m_data[offset(row,inx)];
  238 +
  239 + // Return value
  240 + return value;
  241 +}
  242 +
  243 +
  244 +/***********************************************************************//**
  245 + * @brief Set NULL value
  246 + *
  247 + * @param[in] value Pointer on NULL value
  248 + *
  249 + * Allows the specification of the FITS table NULL value. If value=NULL the
  250 + * data will not be screened for NULL values.
  251 + *
  252 + * @todo To correctly reflect the NULL value in the data, the column should
  253 + * be reloaded. However, the column may have been changed, so in principle
  254 + * saving is needed. However, we may not want to store the data, hence saving
  255 + * is also not desired. We thus have to develop a method to update the
  256 + * column information for a new NULL value in place ...
  257 + ***************************************************************************/
  258 +void GFitsTableLongCol::nullval(const long* value)
  259 +{
  260 + // Allocate nul value
  261 + alloc_nulval(value);
  262 +
  263 + // Update column
  264 +// if (m_data != NULL) {
  265 +// save();
  266 +// load();
  267 +// }
  268 +
  269 + // Return
  270 + return;
  271 +}
  272 +
  273 +
  274 +/*==========================================================================
  275 + = =
  276 + = Private methods =
  277 + = =
  278 + ==========================================================================*/
  279 +
  280 +/***********************************************************************//**
  281 + * @brief Initialise class members
  282 + ***************************************************************************/
  283 +void GFitsTableLongCol::init_members(void)
  284 +{
  285 + // Initialise members
  286 + m_type = __TLONG;
  287 + m_data = NULL;
  288 + m_nulval = NULL;
  289 +
  290 + // Return
  291 + return;
  292 +}
  293 +
  294 +
  295 +/***********************************************************************//**
  296 + * @brief Copy class members
  297 + *
  298 + * @param[in] column Column for which members should be copied.
  299 + *
  300 + * Sets the content of the vector column by copying from another column.
  301 + * If the code is compiled with the small memory option, and if the source
  302 + * column has not yet been loaded, then we only load the column temporarily
  303 + * for copying purposes and release it again once copying is finished.
  304 + ***************************************************************************/
  305 +void GFitsTableLongCol::copy_members(const GFitsTableLongCol& column)
  306 +{
  307 + // Fetch column data if not yet fetched. The casting circumvents the
  308 + // const correctness
  309 + bool not_loaded = (column.m_data == NULL);
  310 + if (not_loaded) ((GFitsTableLongCol*)(&column))->fetch_data();
  311 +
  312 + // Copy attributes
  313 + m_type = column.m_type;
  314 + m_size = column.m_size;
  315 +
  316 + // Copy column data
  317 + if (column.m_data != NULL && m_size > 0) {
  318 + alloc_data();
  319 + for (int i = 0; i < m_size; ++i)
  320 + m_data[i] = column.m_data[i];
  321 + }
  322 +
  323 + // Copy NULL value
  324 + alloc_nulval(column.m_nulval);
  325 +
  326 + // Small memory option: release column if it was fetch above
  327 + #if defined(G_SMALL_MEMORY)
  328 + if (not_loaded) ((GFitsTableLongCol*)(&column))->release_data();
  329 + #endif
  330 +
  331 + // Return
  332 + return;
  333 +}
  334 +
  335 +
  336 +/***********************************************************************//**
  337 + * @brief Delete class members
  338 + ***************************************************************************/
  339 +void GFitsTableLongCol::free_members(void)
  340 +{
  341 + // Free memory
  342 + if (m_data != NULL) delete [] m_data;
  343 + if (m_nulval != NULL) delete m_nulval;
  344 +
  345 + // Mark memory as freed
  346 + m_data = NULL;
  347 + m_nulval = NULL;
  348 +
  349 + // Reset load flag
  350 + m_size = 0;
  351 +
  352 + // Return
  353 + return;
  354 +}
  355 +
  356 +
  357 +/***********************************************************************//**
  358 + * @brief Clone column
  359 + ***************************************************************************/
  360 +GFitsTableLongCol* GFitsTableLongCol::clone(void) const
  361 +{
  362 + return new GFitsTableLongCol(*this);
  363 +}
  364 +
  365 +
  366 +/***********************************************************************//**
  367 + * @brief Returns format string of ASCII table
  368 + ***************************************************************************/
  369 +std::string GFitsTableLongCol::ascii_format(void) const
  370 +{
  371 + // Initialize format string
  372 + std::string format;
  373 +
  374 + // Set type code
  375 + format.append("J");
  376 +
  377 + // Set width
  378 + format.append(str(m_width));
  379 +
  380 + // Return format
  381 + return format;
  382 +}
  383 +
  384 +
  385 +/***********************************************************************//**
  386 + * @brief Returns format string of binary table
  387 + ***************************************************************************/
  388 +std::string GFitsTableLongCol::binary_format(void) const
  389 +{
  390 + // Initialize format string
  391 + std::string format;
  392 +
  393 + // Set number of elements
  394 + format.append(str(m_number));
  395 +
  396 + // Set type code
  397 + format.append("J");
  398 +
  399 + // Return format
  400 + return format;
  401 +}
  402 +
  403 +
  404 +/***********************************************************************//**
  405 + * @brief Allocates column data
  406 + ***************************************************************************/
  407 +void GFitsTableLongCol::alloc_data(void)
  408 +{
  409 + // Free any existing memory
  410 + if (m_data != NULL) delete [] m_data;
  411 +
  412 + // Mark pointer as free
  413 + m_data = NULL;
  414 +
  415 + // Allocate new data
  416 + if (m_size > 0)
  417 + m_data = new long[m_size];
  418 +
  419 + // Return
  420 + return;
  421 +}
  422 +
  423 +
  424 +/***********************************************************************//**
  425 + * @brief Release column data
  426 + ***************************************************************************/
  427 +void GFitsTableLongCol::release_data(void)
  428 +{
  429 + // Free any existing memory
  430 + if (m_data != NULL) delete [] m_data;
  431 +
  432 + // Mark pointer as free and reset loaded vector size
  433 + m_data = NULL;
  434 + m_size = 0;
  435 +
  436 + // Return
  437 + return;
  438 +}
  439 +
  440 +
  441 +/***********************************************************************//**
  442 + * @brief Allocates null value
  443 + ***************************************************************************/
  444 +void GFitsTableLongCol::alloc_nulval(const long* value)
  445 +{
  446 + // Free any existing memory
  447 + if (m_nulval != NULL) delete m_nulval;
  448 +
  449 + // Mark pointer as free
  450 + m_nulval = NULL;
  451 +
  452 + // If we have valid value, allocate and set nul value
  453 + if (value != NULL) {
  454 + m_nulval = new long;
  455 + *m_nulval = *value;
  456 + }
  457 +
  458 + // Return
  459 + return;
  460 +}
  461 +
  462 +
  463 +/***********************************************************************//**
  464 + * @brief Initialise column data
  465 + ***************************************************************************/
  466 +void GFitsTableLongCol::init_data(void)
  467 +{
  468 + // Initialise data if they exist
  469 + if (m_data != NULL) {
  470 + for (int i = 0; i < m_size; ++i)
  471 + m_data[i] = 0;
  472 + }
  473 +
  474 + // Return
  475 + return;
  476 +}
  477 +
  478 +
  479 +/*==========================================================================
  480 + = =
  481 + = Friends =
  482 + = =
  483 + ==========================================================================*/
  484 +
  485 +/***********************************************************************//**
  486 + * @brief Output operator
  487 + *
  488 + * @param[in] os Output stream.
  489 + * @param[in] column Column to put in output stream.
  490 + ***************************************************************************/
  491 +std::ostream& operator<< (std::ostream& os, const GFitsTableLongCol& column)
  492 +{
  493 + // Dump column in output stream
  494 + column.dump_column(os, column.m_data);
  495 +
  496 + // Return output stream
  497 + return os;
  498 +}
... ...
src/fits/GFitsTableLongLongCol.cpp 0 → 100644
  1 +/***************************************************************************
  2 + * GFitsTableLongLongCol.cpp - FITS table long long column class *
  3 + * ----------------------------------------------------------------------- *
  4 + * copyright (C) 2010 by Jurgen Knodlseder *
  5 + * ----------------------------------------------------------------------- *
  6 + * *
  7 + * This program is free software; you can redistribute it and/or modify *
  8 + * it under the terms of the GNU General Public License as published by *
  9 + * the Free Software Foundation; either version 2 of the License, or *
  10 + * (at your option) any later version. *
  11 + * *
  12 + ***************************************************************************/
  13 +
  14 +/* __ Includes ___________________________________________________________ */
  15 +#ifdef HAVE_CONFIG_H
  16 +#include <config.h>
  17 +#endif
  18 +#include <iostream>
  19 +#include "GException.hpp"
  20 +#include "GTools.hpp"
  21 +#include "GFitsTableLongLongCol.hpp"
  22 +
  23 +/* __ Method name definitions ____________________________________________ */
  24 +
  25 +/* __ Macros _____________________________________________________________ */
  26 +
  27 +/* __ Coding definitions _________________________________________________ */
  28 +
  29 +/* __ Debug definitions __________________________________________________ */
  30 +
  31 +
  32 +/*==========================================================================
  33 + = =
  34 + = Constructors/destructors =
  35 + = =
  36 + ==========================================================================*/
  37 +
  38 +/***********************************************************************//**
  39 + * @brief Constructor
  40 + ***************************************************************************/
  41 +GFitsTableLongLongCol::GFitsTableLongLongCol(void) : GFitsTableCol()
  42 +{
  43 + // Initialise class members for clean destruction
  44 + init_members();
  45 +
  46 + // Return
  47 + return;
  48 +}
  49 +
  50 +
  51 +/***********************************************************************//**
  52 + * @brief Constructor
  53 + *
  54 + * @param[in] name Name of column.
  55 + * @param[in] length Length of column.
  56 + * @param[in] size Vector size of column.
  57 + ***************************************************************************/
  58 +GFitsTableLongLongCol::GFitsTableLongLongCol(const std::string& name,
  59 + const int& length,
  60 + const int& size)
  61 + : GFitsTableCol(name, length, size, 2)
  62 +{
  63 + // Initialise class members for clean destruction
  64 + init_members();
  65 +
  66 + // Return
  67 + return;
  68 +}
  69 +
  70 +
  71 +/***********************************************************************//**
  72 + * @brief Copy constructor
  73 + *
  74 + * @param[in] column Column from which class instance should be built.
  75 + ***************************************************************************/
  76 +GFitsTableLongLongCol::GFitsTableLongLongCol(const GFitsTableLongLongCol& column)
  77 + : GFitsTableCol(column)
  78 +{
  79 + // Initialise class members for clean destruction
  80 + init_members();
  81 +
  82 + // Copy members
  83 + copy_members(column);
  84 +
  85 + // Return
  86 + return;
  87 +}
  88 +
  89 +
  90 +/***********************************************************************//**
  91 + * @brief Destructor
  92 + ***************************************************************************/
  93 +GFitsTableLongLongCol::~GFitsTableLongLongCol(void)
  94 +{
  95 + // Free members
  96 + free_members();
  97 +
  98 + // Return
  99 + return;
  100 +}
  101 +
  102 +
  103 +/*==========================================================================
  104 + = =
  105 + = Operators =
  106 + = =
  107 + ==========================================================================*/
  108 +
  109 +/***********************************************************************//**
  110 + * @brief Assignment operator
  111 + *
  112 + * @param[in] column Column which should be assigned
  113 + ***************************************************************************/
  114 +GFitsTableLongLongCol& GFitsTableLongLongCol::operator= (const GFitsTableLongLongCol& column)
  115 +{
  116 + // Execute only if object is not identical
  117 + if (this != &column) {
  118 +
  119 + // Copy base class members
  120 + this->GFitsTableCol::operator=(column);
  121 +
  122 + // Free members
  123 + free_members();
  124 +
  125 + // Initialise private members for clean destruction
  126 + init_members();
  127 +
  128 + // Copy members
  129 + copy_members(column);
  130 +
  131 + } // endif: object was not identical
  132 +
  133 + // Return this object
  134 + return *this;
  135 +}
  136 +
  137 +
  138 +/***********************************************************************//**
  139 + * @brief Column data access operator
  140 + *
  141 + * @param[in] row Row of column to access.
  142 + * @param[in] inx Vector index in column row to access
  143 + *
  144 + * Provides access to data in a column.
  145 + ***************************************************************************/
  146 +long long& GFitsTableLongLongCol::operator() (const int& row, const int& inx)
  147 +{
  148 + // If data are not available then load them now
  149 + if (m_data == NULL) fetch_data();
  150 +
  151 + // Return data bin
  152 + return m_data[offset(row, inx)];
  153 +}
  154 +
  155 +
  156 +/***********************************************************************//**
  157 + * @brief Column data access operator (const variant)
  158 + *
  159 + * @param[in] row Row of column to access.
  160 + * @param[in] inx Vector index in column row to access
  161 + *
  162 + * Provides access to data in a column.
  163 + ***************************************************************************/
  164 +const long long& GFitsTableLongLongCol::operator() (const int& row, const int& inx) const
  165 +{
  166 + // If data are not available then load them now
  167 + if (m_data == NULL) ((GFitsTableLongLongCol*)this)->fetch_data();
  168 +
  169 + // Return data bin
  170 + return m_data[offset(row, inx)];
  171 +}
  172 +
  173 +
  174 +/*==========================================================================
  175 + = =
  176 + = Public methods =
  177 + = =
  178 + ==========================================================================*/
  179 +
  180 +/***********************************************************************//**
  181 + * @brief Get string value
  182 + *
  183 + * @param[in] row Table row.
  184 + * @param[in] inx Table column vector index.
  185 + *
  186 + * Returns value of specified row and vector index as string.
  187 + ***************************************************************************/
  188 +std::string GFitsTableLongLongCol::string(const int& row, const int& inx)
  189 +{
  190 + // If data are not available then load them now
  191 + if (m_data == NULL) fetch_data();
  192 +
  193 + // Convert long long into string
  194 + std::ostringstream s_value;
  195 + s_value << m_data[offset(row,inx)];
  196 +
  197 + // Return value
  198 + return s_value.str();
  199 +}
  200 +
  201 +
  202 +/***********************************************************************//**
  203 + * @brief Get double precision value
  204 + *
  205 + * @param[in] row Table row.
  206 + * @param[in] inx Table column vector index.
  207 + *
  208 + * Returns value of specified row and vector index as double precision.
  209 + ***************************************************************************/
  210 +double GFitsTableLongLongCol::real(const int& row, const int& inx)
  211 +{
  212 + // If data are not available then load them now
  213 + if (m_data == NULL) fetch_data();
  214 +
  215 + // Convert long long into double
  216 + double value = (double)m_data[offset(row,inx)];
  217 +
  218 + // Return value
  219 + return value;
  220 +}
  221 +
  222 +
  223 +/***********************************************************************//**
  224 + * @brief Get integer value
  225 + *
  226 + * @param[in] row Table row.
  227 + * @param[in] inx Table column vector index.
  228 + *
  229 + * Returns value of specified row and vector index as integer.
  230 + ***************************************************************************/
  231 +int GFitsTableLongLongCol::integer(const int& row, const int& inx)
  232 +{
  233 + // If data are not available then load them now
  234 + if (m_data == NULL) fetch_data();
  235 +
  236 + // Convert long long into int
  237 + int value = (int)m_data[offset(row,inx)];
  238 +
  239 + // Return value
  240 + return value;
  241 +}
  242 +
  243 +
  244 +/***********************************************************************//**
  245 + * @brief Set NULL value
  246 + *
  247 + * @param[in] value Pointer on NULL value
  248 + *
  249 + * Allows the specification of the FITS table NULL value. If value=NULL the
  250 + * data will not be screened for NULL values.
  251 + *
  252 + * @todo To correctly reflect the NULL value in the data, the column should
  253 + * be reloaded. However, the column may have been changed, so in principle
  254 + * saving is needed. However, we may not want to store the data, hence saving
  255 + * is also not desired. We thus have to develop a method to update the
  256 + * column information for a new NULL value in place ...
  257 + ***************************************************************************/
  258 +void GFitsTableLongLongCol::nullval(const long long* value)
  259 +{
  260 + // Allocate nul value
  261 + alloc_nulval(value);
  262 +
  263 + // Update column
  264 +// if (m_data != NULL) {
  265 +// save();
  266 +// load();
  267 +// }
  268 +
  269 + // Return
  270 + return;
  271 +}
  272 +
  273 +
  274 +/*==========================================================================
  275 + = =
  276 + = Private methods =
  277 + = =
  278 + ==========================================================================*/
  279 +
  280 +/***********************************************************************//**
  281 + * @brief Initialise class members
  282 + ***************************************************************************/
  283 +void GFitsTableLongLongCol::init_members(void)
  284 +{
  285 + // Initialise members
  286 + m_type = __TLONGLONG;
  287 + m_data = NULL;
  288 + m_nulval = NULL;
  289 +
  290 + // Return
  291 + return;
  292 +}
  293 +
  294 +
  295 +/***********************************************************************//**
  296 + * @brief Copy class members
  297 + *
  298 + * @param[in] column Column for which members should be copied.
  299 + *
  300 + * Sets the content of the vector column by copying from another column.
  301 + * If the code is compiled with the small memory option, and if the source
  302 + * column has not yet been loaded, then we only load the column temporarily
  303 + * for copying purposes and release it again once copying is finished.
  304 + ***************************************************************************/
  305 +void GFitsTableLongLongCol::copy_members(const GFitsTableLongLongCol& column)
  306 +{
  307 + // Fetch column data if not yet fetched. The casting circumvents the
  308 + // const correctness
  309 + bool not_loaded = (column.m_data == NULL);
  310 + if (not_loaded) ((GFitsTableLongLongCol*)(&column))->fetch_data();
  311 +
  312 + // Copy attributes
  313 + m_type = column.m_type;
  314 + m_size = column.m_size;
  315 +
  316 + // Copy column data
  317 + if (column.m_data != NULL && m_size > 0) {
  318 + alloc_data();
  319 + for (int i = 0; i < m_size; ++i)
  320 + m_data[i] = column.m_data[i];
  321 + }
  322 +
  323 + // Copy NULL value
  324 + alloc_nulval(column.m_nulval);
  325 +
  326 + // Small memory option: release column if it was fetch above
  327 + #if defined(G_SMALL_MEMORY)
  328 + if (not_loaded) ((GFitsTableLongLongCol*)(&column))->release_data();
  329 + #endif
  330 +
  331 + // Return
  332 + return;
  333 +}
  334 +
  335 +
  336 +/***********************************************************************//**
  337 + * @brief Delete class members
  338 + ***************************************************************************/
  339 +void GFitsTableLongLongCol::free_members(void)
  340 +{
  341 + // Free memory
  342 + if (m_data != NULL) delete [] m_data;
  343 + if (m_nulval != NULL) delete m_nulval;
  344 +
  345 + // Mark memory as freed
  346 + m_data = NULL;
  347 + m_nulval = NULL;
  348 +
  349 + // Reset load flag
  350 + m_size = 0;
  351 +
  352 + // Return
  353 + return;
  354 +}
  355 +
  356 +
  357 +/***********************************************************************//**
  358 + * @brief Clone column
  359 + ***************************************************************************/
  360 +GFitsTableLongLongCol* GFitsTableLongLongCol::clone(void) const
  361 +{
  362 + return new GFitsTableLongLongCol(*this);
  363 +}
  364 +
  365 +
  366 +/***********************************************************************//**
  367 + * @brief Returns format string of ASCII table
  368 + ***************************************************************************/
  369 +std::string GFitsTableLongLongCol::ascii_format(void) const
  370 +{
  371 + // Initialize format string
  372 + std::string format;
  373 +
  374 + // Set type code
  375 + format.append("K");
  376 +
  377 + // Set width
  378 + format.append(str(m_width));
  379 +
  380 + // Return format
  381 + return format;
  382 +}
  383 +
  384 +
  385 +/***********************************************************************//**
  386 + * @brief Returns format string of binary table
  387 + ***************************************************************************/
  388 +std::string GFitsTableLongLongCol::binary_format(void) const
  389 +{
  390 + // Initialize format string
  391 + std::string format;
  392 +
  393 + // Set number of elements
  394 + format.append(str(m_number));
  395 +
  396 + // Set type code
  397 + format.append("K");
  398 +
  399 + // Return format
  400 + return format;
  401 +}
  402 +
  403 +
  404 +/***********************************************************************//**
  405 + * @brief Allocates column data
  406 + ***************************************************************************/
  407 +void GFitsTableLongLongCol::alloc_data(void)
  408 +{
  409 + // Free any existing memory
  410 + if (m_data != NULL) delete [] m_data;
  411 +
  412 + // Mark pointer as free
  413 + m_data = NULL;
  414 +
  415 + // Allocate new data
  416 + if (m_size > 0)
  417 + m_data = new long long[m_size];
  418 +
  419 + // Return
  420 + return;
  421 +}
  422 +
  423 +
  424 +/***********************************************************************//**
  425 + * @brief Release column data
  426 + ***************************************************************************/
  427 +void GFitsTableLongLongCol::release_data(void)
  428 +{
  429 + // Free any existing memory
  430 + if (m_data != NULL) delete [] m_data;
  431 +
  432 + // Mark pointer as free and reset loaded vector size
  433 + m_data = NULL;
  434 + m_size = 0;
  435 +
  436 + // Return
  437 + return;
  438 +}
  439 +
  440 +
  441 +/***********************************************************************//**
  442 + * @brief Allocates null value
  443 + ***************************************************************************/
  444 +void GFitsTableLongLongCol::alloc_nulval(const long long* value)
  445 +{
  446 + // Free any existing memory
  447 + if (m_nulval != NULL) delete m_nulval;
  448 +
  449 + // Mark pointer as free
  450 + m_nulval = NULL;
  451 +
  452 + // If we have valid value, allocate and set nul value
  453 + if (value != NULL) {
  454 + m_nulval = new long long;
  455 + *m_nulval = *value;
  456 + }
  457 +
  458 + // Return
  459 + return;
  460 +}
  461 +
  462 +
  463 +/***********************************************************************//**
  464 + * @brief Initialise column data
  465 + ***************************************************************************/
  466 +void GFitsTableLongLongCol::init_data(void)
  467 +{
  468 + // Initialise data if they exist
  469 + if (m_data != NULL) {
  470 + for (int i = 0; i < m_size; ++i)
  471 + m_data[i] = 0;
  472 + }
  473 +
  474 + // Return
  475 + return;
  476 +}
  477 +
  478 +
  479 +/*==========================================================================
  480 + = =
  481 + = Friends =
  482 + = =
  483 + ==========================================================================*/
  484 +
  485 +/***********************************************************************//**
  486 + * @brief Output operator
  487 + *
  488 + * @param[in] os Output stream
  489 + * @param[in] column Column to put in output stream
  490 + ***************************************************************************/
  491 +std::ostream& operator<< (std::ostream& os, const GFitsTableLongLongCol& column)
  492 +{
  493 + // Dump column in output stream
  494 + column.dump_column(os, column.m_data);
  495 +
  496 + // Return output stream
  497 + return os;
  498 +}
... ...
src/fits/GFitsTableShortCol.cpp 0 → 100644
  1 +/***************************************************************************
  2 + * GFitsTableShortCol.cpp - FITS table short column class *
  3 + * ----------------------------------------------------------------------- *
  4 + * copyright (C) 2010 by Jurgen Knodlseder *
  5 + * ----------------------------------------------------------------------- *
  6 + * *
  7 + * This program is free software; you can redistribute it and/or modify *
  8 + * it under the terms of the GNU General Public License as published by *
  9 + * the Free Software Foundation; either version 2 of the License, or *
  10 + * (at your option) any later version. *
  11 + * *
  12 + ***************************************************************************/
  13 +
  14 +/* __ Includes ___________________________________________________________ */
  15 +#ifdef HAVE_CONFIG_H
  16 +#include <config.h>
  17 +#endif
  18 +#include <iostream>
  19 +#include "GException.hpp"
  20 +#include "GTools.hpp"
  21 +#include "GFitsTableShortCol.hpp"
  22 +
  23 +/* __ Method name definitions ____________________________________________ */
  24 +
  25 +/* __ Macros _____________________________________________________________ */
  26 +
  27 +/* __ Coding definitions _________________________________________________ */
  28 +
  29 +/* __ Debug definitions __________________________________________________ */
  30 +
  31 +
  32 +/*==========================================================================
  33 + = =
  34 + = Constructors/destructors =
  35 + = =
  36 + ==========================================================================*/
  37 +
  38 +/***********************************************************************//**
  39 + * @brief Constructor
  40 + ***************************************************************************/
  41 +GFitsTableShortCol::GFitsTableShortCol(void) : GFitsTableCol()
  42 +{
  43 + // Initialise class members for clean destruction
  44 + init_members();
  45 +
  46 + // Return
  47 + return;
  48 +}
  49 +
  50 +
  51 +/***********************************************************************//**
  52 + * @brief Constructor
  53 + *
  54 + * @param[in] name Name of column.
  55 + * @param[in] length Length of column.
  56 + * @param[in] size Vector size of column.
  57 + ***************************************************************************/
  58 +GFitsTableShortCol::GFitsTableShortCol(const std::string& name,
  59 + const int& length,
  60 + const int& size)
  61 + : GFitsTableCol(name, length, size, 2)
  62 +{
  63 + // Initialise class members for clean destruction
  64 + init_members();
  65 +
  66 + // Return
  67 + return;
  68 +}
  69 +
  70 +
  71 +/***********************************************************************//**
  72 + * @brief Copy constructor
  73 + *
  74 + * @param[in] column Column from which class instance should be built.
  75 + ***************************************************************************/
  76 +GFitsTableShortCol::GFitsTableShortCol(const GFitsTableShortCol& column)
  77 + : GFitsTableCol(column)
  78 +{
  79 + // Initialise class members for clean destruction
  80 + init_members();
  81 +
  82 + // Copy members
  83 + copy_members(column);
  84 +
  85 + // Return
  86 + return;
  87 +}
  88 +
  89 +
  90 +/***********************************************************************//**
  91 + * @brief Destructor
  92 + ***************************************************************************/
  93 +GFitsTableShortCol::~GFitsTableShortCol(void)
  94 +{
  95 + // Free members
  96 + free_members();
  97 +
  98 + // Return
  99 + return;
  100 +}
  101 +
  102 +
  103 +/*==========================================================================
  104 + = =
  105 + = Operators =
  106 + = =
  107 + ==========================================================================*/
  108 +
  109 +/***********************************************************************//**
  110 + * @brief Assignment operator
  111 + *
  112 + * @param[in] column Column which should be assigned
  113 + ***************************************************************************/
  114 +GFitsTableShortCol& GFitsTableShortCol::operator= (const GFitsTableShortCol& column)
  115 +{
  116 + // Execute only if object is not identical
  117 + if (this != &column) {
  118 +
  119 + // Copy base class members
  120 + this->GFitsTableCol::operator=(column);
  121 +
  122 + // Free members
  123 + free_members();
  124 +
  125 + // Initialise private members for clean destruction
  126 + init_members();
  127 +
  128 + // Copy members
  129 + copy_members(column);
  130 +
  131 + } // endif: object was not identical
  132 +
  133 + // Return this object
  134 + return *this;
  135 +}
  136 +
  137 +
  138 +/***********************************************************************//**
  139 + * @brief Column data access operator
  140 + *
  141 + * @param[in] row Row of column to access.
  142 + * @param[in] inx Vector index in column row to access
  143 + *
  144 + * Provides access to data in a column.
  145 + ***************************************************************************/
  146 +short& GFitsTableShortCol::operator() (const int& row, const int& inx)
  147 +{
  148 + // If data are not available then load them now
  149 + if (m_data == NULL) fetch_data();
  150 +
  151 + // Return data bin
  152 + return m_data[offset(row, inx)];
  153 +}
  154 +
  155 +
  156 +/***********************************************************************//**
  157 + * @brief Column data access operator (const variant)
  158 + *
  159 + * @param[in] row Row of column to access.
  160 + * @param[in] inx Vector index in column row to access
  161 + *
  162 + * Provides access to data in a column.
  163 + ***************************************************************************/
  164 +const short& GFitsTableShortCol::operator() (const int& row, const int& inx) const
  165 +{
  166 + // If data are not available then load them now
  167 + if (m_data == NULL) ((GFitsTableShortCol*)this)->fetch_data();
  168 +
  169 + // Return data bin
  170 + return m_data[offset(row, inx)];
  171 +}
  172 +
  173 +
  174 +/*==========================================================================
  175 + = =
  176 + = Public methods =
  177 + = =
  178 + ==========================================================================*/
  179 +
  180 +/***********************************************************************//**
  181 + * @brief Get string value
  182 + *
  183 + * @param[in] row Table row.
  184 + * @param[in] inx Table column vector index.
  185 + *
  186 + * Returns value of specified row and vector index as string.
  187 + ***************************************************************************/
  188 +std::string GFitsTableShortCol::string(const int& row, const int& inx)
  189 +{
  190 + // If data are not available then load them now
  191 + if (m_data == NULL) fetch_data();
  192 +
  193 + // Convert short into string
  194 + std::ostringstream s_value;
  195 + s_value << m_data[offset(row,inx)];
  196 +
  197 + // Return value
  198 + return s_value.str();
  199 +}
  200 +
  201 +
  202 +/***********************************************************************//**
  203 + * @brief Get double precision value
  204 + *
  205 + * @param[in] row Table row.
  206 + * @param[in] inx Table column vector index.
  207 + *
  208 + * Returns value of specified row and vector index as double precision.
  209 + ***************************************************************************/
  210 +double GFitsTableShortCol::real(const int& row, const int& inx)
  211 +{
  212 + // If data are not available then load them now
  213 + if (m_data == NULL) fetch_data();
  214 +
  215 + // Convert short into double
  216 + double value = (double)m_data[offset(row,inx)];
  217 +
  218 + // Return value
  219 + return value;
  220 +}
  221 +
  222 +
  223 +/***********************************************************************//**
  224 + * @brief Get integer value
  225 + *
  226 + * @param[in] row Table row.
  227 + * @param[in] inx Table column vector index.
  228 + *
  229 + * Returns value of specified row and vector index as integer.
  230 + ***************************************************************************/
  231 +int GFitsTableShortCol::integer(const int& row, const int& inx)
  232 +{
  233 + // If data are not available then load them now
  234 + if (m_data == NULL) fetch_data();
  235 +
  236 + // Convert short into int
  237 + int value = (int)m_data[offset(row,inx)];
  238 +
  239 + // Return value
  240 + return value;
  241 +}
  242 +
  243 +
  244 +/***********************************************************************//**
  245 + * @brief Set NULL value
  246 + *
  247 + * @param[in] value Pointer on NULL value
  248 + *
  249 + * Allows the specification of the FITS table NULL value. If value=NULL the
  250 + * data will not be screened for NULL values.
  251 + *
  252 + * @todo To correctly reflect the NULL value in the data, the column should
  253 + * be reloaded. However, the column may have been changed, so in principle
  254 + * saving is needed. However, we may not want to store the data, hence saving
  255 + * is also not desired. We thus have to develop a method to update the
  256 + * column information for a new NULL value in place ...
  257 + ***************************************************************************/
  258 +void GFitsTableShortCol::nullval(const short* value)
  259 +{
  260 + // Allocate nul value
  261 + alloc_nulval(value);
  262 +
  263 + // Update column
  264 +// if (m_data != NULL) {
  265 +// save();
  266 +// load();
  267 +// }
  268 +
  269 + // Return
  270 + return;
  271 +}
  272 +
  273 +
  274 +/*==========================================================================
  275 + = =
  276 + = Private methods =
  277 + = =
  278 + ==========================================================================*/
  279 +
  280 +/***********************************************************************//**
  281 + * @brief Initialise class members
  282 + ***************************************************************************/
  283 +void GFitsTableShortCol::init_members(void)
  284 +{
  285 + // Initialise members
  286 + m_type = __TSHORT;
  287 + m_data = NULL;
  288 + m_nulval = NULL;
  289 +
  290 + // Return
  291 + return;
  292 +}
  293 +
  294 +
  295 +/***********************************************************************//**
  296 + * @brief Copy class members
  297 + *
  298 + * @param[in] column Column for which members should be copied.
  299 + *
  300 + * Sets the content of the vector column by copying from another column.
  301 + * If the code is compiled with the small memory option, and if the source
  302 + * column has not yet been loaded, then we only load the column temporarily
  303 + * for copying purposes and release it again once copying is finished.
  304 + ***************************************************************************/
  305 +void GFitsTableShortCol::copy_members(const GFitsTableShortCol& column)
  306 +{
  307 + // Fetch column data if not yet fetched. The casting circumvents the
  308 + // const correctness
  309 + bool not_loaded = (column.m_data == NULL);
  310 + if (not_loaded) ((GFitsTableShortCol*)(&column))->fetch_data();
  311 +
  312 + // Copy attributes
  313 + m_type = column.m_type;
  314 + m_size = column.m_size;
  315 +
  316 + // Copy column data
  317 + if (column.m_data != NULL && m_size > 0) {
  318 + alloc_data();
  319 + for (int i = 0; i < m_size; ++i)
  320 + m_data[i] = column.m_data[i];
  321 + }
  322 +
  323 + // Copy NULL value
  324 + alloc_nulval(column.m_nulval);
  325 +
  326 + // Small memory option: release column if it was fetch above
  327 + #if defined(G_SMALL_MEMORY)
  328 + if (not_loaded) ((GFitsTableShortCol*)(&column))->release_data();
  329 + #endif
  330 +
  331 + // Return
  332 + return;
  333 +}
  334 +
  335 +
  336 +/***********************************************************************//**
  337 + * @brief Delete class members
  338 + ***************************************************************************/
  339 +void GFitsTableShortCol::free_members(void)
  340 +{
  341 + // Free memory
  342 + if (m_data != NULL) delete [] m_data;
  343 + if (m_nulval != NULL) delete m_nulval;
  344 +
  345 + // Mark memory as freed
  346 + m_data = NULL;
  347 + m_nulval = NULL;
  348 +
  349 + // Reset load flag
  350 + m_size = 0;
  351 +
  352 + // Return
  353 + return;
  354 +}
  355 +
  356 +
  357 +/***********************************************************************//**
  358 + * @brief Clone column
  359 + ***************************************************************************/
  360 +GFitsTableShortCol* GFitsTableShortCol::clone(void) const
  361 +{
  362 + return new GFitsTableShortCol(*this);
  363 +}
  364 +
  365 +
  366 +/***********************************************************************//**
  367 + * @brief Returns format string of ASCII table
  368 + ***************************************************************************/
  369 +std::string GFitsTableShortCol::ascii_format(void) const
  370 +{
  371 + // Initialize format string
  372 + std::string format;
  373 +
  374 + // Set type code
  375 + format.append("I");
  376 +
  377 + // Set width
  378 + format.append(str(m_width));
  379 +
  380 + // Return format
  381 + return format;
  382 +}
  383 +
  384 +
  385 +/***********************************************************************//**
  386 + * @brief Returns format string of binary table
  387 + ***************************************************************************/
  388 +std::string GFitsTableShortCol::binary_format(void) const
  389 +{
  390 + // Initialize format string
  391 + std::string format;
  392 +
  393 + // Set number of elements
  394 + format.append(str(m_number));
  395 +
  396 + // Set type code
  397 + format.append("I");
  398 +
  399 + // Return format
  400 + return format;
  401 +}
  402 +
  403 +
  404 +/***********************************************************************//**
  405 + * @brief Allocates column data
  406 + ***************************************************************************/
  407 +void GFitsTableShortCol::alloc_data(void)
  408 +{
  409 + // Free any existing memory
  410 + if (m_data != NULL) delete [] m_data;
  411 +
  412 + // Mark pointer as free
  413 + m_data = NULL;
  414 +
  415 + // Allocate new data
  416 + if (m_size > 0)
  417 + m_data = new short[m_size];
  418 +
  419 + // Return
  420 + return;
  421 +}
  422 +
  423 +
  424 +/***********************************************************************//**
  425 + * @brief Release column data
  426 + ***************************************************************************/
  427 +void GFitsTableShortCol::release_data(void)
  428 +{
  429 + // Free any existing memory
  430 + if (m_data != NULL) delete [] m_data;
  431 +
  432 + // Mark pointer as free and reset loaded vector size
  433 + m_data = NULL;
  434 + m_size = 0;
  435 +
  436 + // Return
  437 + return;
  438 +}
  439 +
  440 +
  441 +/***********************************************************************//**
  442 + * @brief Allocates null value
  443 + ***************************************************************************/
  444 +void GFitsTableShortCol::alloc_nulval(const short* value)
  445 +{
  446 + // Free any existing memory
  447 + if (m_nulval != NULL) delete m_nulval;
  448 +
  449 + // Mark pointer as free
  450 + m_nulval = NULL;
  451 +
  452 + // If we have valid value, allocate and set nul value
  453 + if (value != NULL) {
  454 + m_nulval = new short;
  455 + *m_nulval = *value;
  456 + }
  457 +
  458 + // Return
  459 + return;
  460 +}
  461 +
  462 +
  463 +/***********************************************************************//**
  464 + * @brief Initialise column data
  465 + ***************************************************************************/
  466 +void GFitsTableShortCol::init_data(void)
  467 +{
  468 + // Initialise data if they exist
  469 + if (m_data != NULL) {
  470 + for (int i = 0; i < m_size; ++i)
  471 + m_data[i] = 0;
  472 + }
  473 +
  474 + // Return
  475 + return;
  476 +}
  477 +
  478 +
  479 +/*==========================================================================
  480 + = =
  481 + = Friends =
  482 + = =
  483 + ==========================================================================*/
  484 +
  485 +/***********************************************************************//**
  486 + * @brief Output operator
  487 + *
  488 + * @param[in] os Output stream
  489 + * @param[in] column Column to put in output stream
  490 + ***************************************************************************/
  491 +std::ostream& operator<< (std::ostream& os, const GFitsTableShortCol& column)
  492 +{
  493 + // Dump column in output stream
  494 + column.dump_column(os, column.m_data);
  495 +
  496 + // Return output stream
  497 + return os;
  498 +}
... ...
src/fits/GFitsTableStrCol.cpp renamed to src/fits/GFitsTableStringCol.cpp
1 1 /***************************************************************************
2   - * GFitsTableStrCol.cpp - FITS table string column class *
  2 + * GFitsTableStringCol.cpp - FITS table string column class *
3 3 * ----------------------------------------------------------------------- *
4 4 * copyright (C) 2008-2010 by Jurgen Knodlseder *
5 5 * ----------------------------------------------------------------------- *
... ... @@ -19,12 +19,9 @@
19 19 #include <string.h>
20 20 #include "GException.hpp"
21 21 #include "GTools.hpp"
22   -#include "GFitsTableStrCol.hpp"
  22 +#include "GFitsTableStringCol.hpp"
23 23  
24 24 /* __ Method name definitions ____________________________________________ */
25   -#define G_STRING "GFitsTableStrCol::string(const int&, const int&)"
26   -#define G_REAL "GFitsTableStrCol::real(const int&, const int&)"
27   -#define G_INTEGER "GFitsTableStrCol::integer(const int&, const int&)"
28 25  
29 26 /* __ Macros _____________________________________________________________ */
30 27  
... ... @@ -42,7 +39,7 @@
42 39 /***********************************************************************//**
43 40 * @brief Constructor
44 41 ***************************************************************************/
45   -GFitsTableStrCol::GFitsTableStrCol() : GFitsTableCol()
  42 +GFitsTableStringCol::GFitsTableStringCol(void) : GFitsTableCol()
46 43 {
47 44 // Initialise class members for clean destruction
48 45 init_members();
... ... @@ -60,10 +57,10 @@ GFitsTableStrCol::GFitsTableStrCol() : GFitsTableCol()
60 57 * @param[in] width Length of individual string.
61 58 * @param[in] size Number of strings in each column.
62 59 ***************************************************************************/
63   -GFitsTableStrCol::GFitsTableStrCol(const std::string& name,
64   - const int& length,
65   - const int& width,
66   - const int& size)
  60 +GFitsTableStringCol::GFitsTableStringCol(const std::string& name,
  61 + const int& length,
  62 + const int& width,
  63 + const int& size)
67 64 : GFitsTableCol(name, length, size, width)
68 65 {
69 66 // Initialise class members for clean destruction
... ... @@ -79,7 +76,7 @@ GFitsTableStrCol::GFitsTableStrCol(const std::string&amp; name,
79 76 *
80 77 * @param[in] column Column from which class instance should be built.
81 78 ***************************************************************************/
82   -GFitsTableStrCol::GFitsTableStrCol(const GFitsTableStrCol& column)
  79 +GFitsTableStringCol::GFitsTableStringCol(const GFitsTableStringCol& column)
83 80 : GFitsTableCol(column)
84 81 {
85 82 // Initialise class members for clean destruction
... ... @@ -96,7 +93,7 @@ GFitsTableStrCol::GFitsTableStrCol(const GFitsTableStrCol&amp; column)
96 93 /***********************************************************************//**
97 94 * @brief Destructor
98 95 ***************************************************************************/
99   -GFitsTableStrCol::~GFitsTableStrCol()
  96 +GFitsTableStringCol::~GFitsTableStringCol(void)
100 97 {
101 98 // Free members
102 99 free_members();
... ... @@ -117,7 +114,7 @@ GFitsTableStrCol::~GFitsTableStrCol()
117 114 *
118 115 * @param[in] column Column which should be assigned
119 116 ***************************************************************************/
120   -GFitsTableStrCol& GFitsTableStrCol::operator= (const GFitsTableStrCol& column)
  117 +GFitsTableStringCol& GFitsTableStringCol::operator= (const GFitsTableStringCol& column)
121 118 {
122 119 // Execute only if object is not identical
123 120 if (this != &column) {
... ... @@ -147,23 +144,15 @@ GFitsTableStrCol&amp; GFitsTableStrCol::operator= (const GFitsTableStrCol&amp; column)
147 144 * @param[in] row Row of column to access.
148 145 * @param[in] inx Vector index in column row to access
149 146 *
150   - * Provides access to data in a column. No range checking is performed.
151   - * Use one of
152   - * GFitsTableStrCol::string(ix,iy),
153   - * GFitsTableStrCol::real(ix;iy) or
154   - * GFitsTableStrCol::integer(ix;iy)
155   - * if range checking is required.
  147 + * Provides access to data in a column.
156 148 ***************************************************************************/
157   -std::string& GFitsTableStrCol::operator() (const int& row, const int& inx)
  149 +std::string& GFitsTableStringCol::operator() (const int& row, const int& inx)
158 150 {
159 151 // If data are not available then load them now
160 152 if (m_data == NULL) fetch_data();
161 153  
162   - // Calculate pixel offset
163   - int offset = row * m_number + inx;
164   -
165 154 // Return data bin
166   - return m_data[offset];
  155 + return m_data[offset(row, inx)];
167 156 }
168 157  
169 158  
... ... @@ -173,24 +162,15 @@ std::string&amp; GFitsTableStrCol::operator() (const int&amp; row, const int&amp; inx)
173 162 * @param[in] row Row of column to access.
174 163 * @param[in] inx Vector index in column row to access
175 164 *
176   - * Provides access to data in a column. No range checking is performed.
177   - * Use one of
178   - * GFitsTableStrCol::string(ix,iy),
179   - * GFitsTableStrCol::real(ix;iy) or
180   - * GFitsTableStrCol::integer(ix;iy)
181   - * if range checking is required.
  165 + * Provides access to data in a column.
182 166 ***************************************************************************/
183   -const std::string& GFitsTableStrCol::operator() (const int& row, const int& inx)
184   - const
  167 +const std::string& GFitsTableStringCol::operator() (const int& row, const int& inx) const
185 168 {
186 169 // If data are not available then load them now
187   - if (m_data == NULL) ((GFitsTableStrCol*)this)->fetch_data();
188   -
189   - // Calculate pixel offset
190   - int offset = row * m_number + inx;
  170 + if (m_data == NULL) ((GFitsTableStringCol*)this)->fetch_data();
191 171  
192 172 // Return data bin
193   - return m_data[offset];
  173 + return m_data[offset(row, inx)];
194 174 }
195 175  
196 176  
... ... @@ -206,29 +186,15 @@ const std::string&amp; GFitsTableStrCol::operator() (const int&amp; row, const int&amp; inx)
206 186 * @param[in] row Table row.
207 187 * @param[in] inx Table column vector index.
208 188 *
209   - * @exception GException::out_of_range
210   - * Table row or vector index are out of valid range.
211   - *
212 189 * Returns value of specified row and vector index as string.
213 190 ***************************************************************************/
214   -std::string GFitsTableStrCol::string(const int& row, const int& inx)
  191 +std::string GFitsTableStringCol::string(const int& row, const int& inx)
215 192 {
216 193 // If data are not available then load them now
217 194 if (m_data == NULL) fetch_data();
218 195  
219   - // Check row value
220   - if (row < 0 || row >= m_length)
221   - throw GException::out_of_range(G_STRING, row, 0, m_length-1);
222   -
223   - // Check inx value
224   - if (inx < 0 || inx >= m_number)
225   - throw GException::out_of_range(G_STRING, inx, 0, m_number-1);
226   -
227   - // Get index
228   - int offset = row * m_number + inx;
229   -
230 196 // Return value
231   - return m_data[offset];
  197 + return m_data[offset(row,inx)];
232 198 }
233 199  
234 200  
... ... @@ -238,29 +204,15 @@ std::string GFitsTableStrCol::string(const int&amp; row, const int&amp; inx)
238 204 * @param[in] row Table row.
239 205 * @param[in] inx Table column vector index.
240 206 *
241   - * @exception GException::out_of_range
242   - * Table row or vector index are out of valid range.
243   - *
244 207 * Returns value of specified row and vector index as double precision.
245 208 ***************************************************************************/
246   -double GFitsTableStrCol::real(const int& row, const int& inx)
  209 +double GFitsTableStringCol::real(const int& row, const int& inx)
247 210 {
248 211 // If data are not available then load them now
249 212 if (m_data == NULL) fetch_data();
250 213  
251   - // Check row value
252   - if (row < 0 || row >= m_length)
253   - throw GException::out_of_range(G_REAL, row, 0, m_length-1);
254   -
255   - // Check inx value
256   - if (inx < 0 || inx >= m_number)
257   - throw GException::out_of_range(G_REAL, inx, 0, m_number-1);
258   -
259   - // Get index
260   - int offset = row * m_number + inx;
261   -
262   - // Assign C string to double
263   - double value = atof(m_data[offset].c_str());
  214 + // Assign string to double
  215 + double value = todouble(m_data[offset(row,inx)]);
264 216  
265 217 // Return value
266 218 return value;
... ... @@ -273,29 +225,15 @@ double GFitsTableStrCol::real(const int&amp; row, const int&amp; inx)
273 225 * @param[in] row Table row.
274 226 * @param[in] inx Table column vector index.
275 227 *
276   - * @exception GException::out_of_range
277   - * Table row or vector index are out of valid range.
278   - *
279 228 * Returns value of specified row and vector index as integer.
280 229 ***************************************************************************/
281   -int GFitsTableStrCol::integer(const int& row, const int& inx)
  230 +int GFitsTableStringCol::integer(const int& row, const int& inx)
282 231 {
283 232 // If data are not available then load them now
284 233 if (m_data == NULL) fetch_data();
285 234  
286   - // Check row value
287   - if (row < 0 || row >= m_length)
288   - throw GException::out_of_range(G_INTEGER, row, 0, m_length-1);
289   -
290   - // Check inx value
291   - if (inx < 0 || inx >= m_number)
292   - throw GException::out_of_range(G_INTEGER, inx, 0, m_number-1);
293   -
294   - // Get index
295   - int offset = row * m_number + inx;
296   -
297   - // Assign C string to int
298   - int value = int(atof(m_data[offset].c_str()));
  235 + // Assign string to int
  236 + int value = toint(m_data[offset(row,inx)]);
299 237  
300 238 // Return value
301 239 return value;
... ... @@ -303,16 +241,6 @@ int GFitsTableStrCol::integer(const int&amp; row, const int&amp; inx)
303 241  
304 242  
305 243 /***********************************************************************//**
306   - * @brief Return pointer to std::string column
307   - ***************************************************************************/
308   -std::string* GFitsTableStrCol::data(void)
309   -{
310   - return m_data;
311   -}
312   -
313   -
314   -
315   -/***********************************************************************//**
316 244 * @brief Set NULL string
317 245 *
318 246 * @param[in] value Pointer on NULL string
... ... @@ -320,28 +248,16 @@ std::string* GFitsTableStrCol::data(void)
320 248 * Allows the specification of the FITS table NULL string. If the string
321 249 * is empty the data will not be screened for NULL values.
322 250 ***************************************************************************/
323   -void GFitsTableStrCol::set_nullval(const std::string& string)
  251 +void GFitsTableStringCol::nullval(const std::string& value)
324 252 {
325   - // If NULL string is empty then reset the NULL string
326   - if (string.empty()) {
327   - if (m_nulval != NULL) delete [] m_nulval;
328   - m_nulval = NULL;
329   - }
  253 + // Allocate nul value
  254 + alloc_nulval(value);
330 255  
331   - // ... otherwise copy string into NULL string
332   - else {
333   - if (m_nulval != NULL) delete [] m_nulval;
334   - m_nulval = new char[m_width+1];
335   - strncpy(m_nulval, string.c_str(), m_width);
336   - }
337   -
338   - // Re-load column
339   -/*
340   - if (m_data != NULL) {
341   - save();
342   - load();
343   - }
344   -*/
  256 + // Update column
  257 +// if (m_data != NULL) {
  258 +// save();
  259 +// load();
  260 +// }
345 261  
346 262 // Return
347 263 return;
... ... @@ -357,7 +273,7 @@ void GFitsTableStrCol::set_nullval(const std::string&amp; string)
357 273 /***********************************************************************//**
358 274 * @brief Initialise class members
359 275 ***************************************************************************/
360   -void GFitsTableStrCol::init_members(void)
  276 +void GFitsTableStringCol::init_members(void)
361 277 {
362 278 // Initialise members
363 279 m_type = __TSTRING;
... ... @@ -374,13 +290,18 @@ void GFitsTableStrCol::init_members(void)
374 290 * @brief Copy class members
375 291 *
376 292 * @param[in] column Column for which members should be copied.
  293 + *
  294 + * Sets the content of the vector column by copying from another column.
  295 + * If the code is compiled with the small memory option, and if the source
  296 + * column has not yet been loaded, then we only load the column temporarily
  297 + * for copying purposes and release it again once copying is finished.
377 298 ***************************************************************************/
378   -void GFitsTableStrCol::copy_members(const GFitsTableStrCol& column)
  299 +void GFitsTableStringCol::copy_members(const GFitsTableStringCol& column)
379 300 {
380 301 // Fetch column data if not yet fetched. The casting circumvents the
381 302 // const correctness
382   - if (column.m_data == NULL)
383   - ((GFitsTableStrCol*)(&column))->fetch_data();
  303 + bool not_loaded = (column.m_data == NULL);
  304 + if (not_loaded) ((GFitsTableStringCol*)(&column))->fetch_data();
384 305  
385 306 // Copy attributes
386 307 m_type = column.m_type;
... ... @@ -393,11 +314,13 @@ void GFitsTableStrCol::copy_members(const GFitsTableStrCol&amp; column)
393 314 m_data[i] = column.m_data[i];
394 315 }
395 316  
396   - // Copy nulval data
397   - if (column.m_nulval != NULL) {
398   - m_nulval = new char[m_width+1];
399   - strncpy(m_nulval, column.m_nulval, m_width);
400   - }
  317 + // Copy NULL value
  318 + alloc_nulval(std::string(column.m_nulval));
  319 +
  320 + // Small memory option: release column if it was fetch above
  321 + #if defined(G_SMALL_MEMORY)
  322 + if (not_loaded) ((GFitsTableStringCol*)(&column))->release_data();
  323 + #endif
401 324  
402 325 // Return
403 326 return;
... ... @@ -407,7 +330,7 @@ void GFitsTableStrCol::copy_members(const GFitsTableStrCol&amp; column)
407 330 /***********************************************************************//**
408 331 * @brief Delete class members
409 332 ***************************************************************************/
410   -void GFitsTableStrCol::free_members(void)
  333 +void GFitsTableStringCol::free_members(void)
411 334 {
412 335 // Free memory
413 336 if (m_data != NULL) delete [] m_data;
... ... @@ -417,6 +340,9 @@ void GFitsTableStrCol::free_members(void)
417 340 m_data = NULL;
418 341 m_nulval = NULL;
419 342  
  343 + // Reset load flag
  344 + m_size = 0;
  345 +
420 346 // Free buffer
421 347 free_buffer();
422 348  
... ... @@ -434,7 +360,7 @@ void GFitsTableStrCol::free_members(void)
434 360 *
435 361 * Refer to GFitsTableCol::save_column() for more information.
436 362 ***************************************************************************/
437   -void GFitsTableStrCol::save(void)
  363 +void GFitsTableStringCol::save(void)
438 364 {
439 365 // Free buffer
440 366 free_buffer();
... ... @@ -460,16 +386,16 @@ void GFitsTableStrCol::save(void)
460 386 /***********************************************************************//**
461 387 * @brief Clone column
462 388 ***************************************************************************/
463   -GFitsTableStrCol* GFitsTableStrCol::clone(void) const
  389 +GFitsTableStringCol* GFitsTableStringCol::clone(void) const
464 390 {
465   - return new GFitsTableStrCol(*this);
  391 + return new GFitsTableStringCol(*this);
466 392 }
467 393  
468 394  
469 395 /***********************************************************************//**
470 396 * @brief Returns format string of ASCII table
471 397 ***************************************************************************/
472   -std::string GFitsTableStrCol::ascii_format(void) const
  398 +std::string GFitsTableStringCol::ascii_format(void) const
473 399 {
474 400 // Initialize format string
475 401 std::string format;
... ... @@ -488,7 +414,7 @@ std::string GFitsTableStrCol::ascii_format(void) const
488 414 /***********************************************************************//**
489 415 * @brief Returns format string of binary table
490 416 ***************************************************************************/
491   -std::string GFitsTableStrCol::binary_format(void) const
  417 +std::string GFitsTableStringCol::binary_format(void) const
492 418 {
493 419 // Initialize format string
494 420 std::string format;
... ... @@ -511,7 +437,7 @@ std::string GFitsTableStrCol::binary_format(void) const
511 437 /***********************************************************************//**
512 438 * @brief Allocates column data
513 439 ***************************************************************************/
514   -void GFitsTableStrCol::alloc_data(void)
  440 +void GFitsTableStringCol::alloc_data(void)
515 441 {
516 442 // Free memory
517 443 if (m_data != NULL) delete [] m_data;
... ... @@ -529,9 +455,48 @@ void GFitsTableStrCol::alloc_data(void)
529 455  
530 456  
531 457 /***********************************************************************//**
  458 + * @brief Release column data
  459 + ***************************************************************************/
  460 +void GFitsTableStringCol::release_data(void)
  461 +{
  462 + // Free any existing memory
  463 + if (m_data != NULL) delete [] m_data;
  464 +
  465 + // Mark pointer as free and reset loaded vector size
  466 + m_data = NULL;
  467 + m_size = 0;
  468 +
  469 + // Return
  470 + return;
  471 +}
  472 +
  473 +
  474 +/***********************************************************************//**
  475 + * @brief Allocate null value
  476 + ***************************************************************************/
  477 +void GFitsTableStringCol::alloc_nulval(const std::string& value)
  478 +{
  479 + // Free any existing memory
  480 + if (m_nulval != NULL) delete m_nulval;
  481 +
  482 + // Mark pointer as free
  483 + m_nulval = NULL;
  484 +
  485 + // If we have valid value, allocate and set nul value
  486 + if (value.empty()) {
  487 + m_nulval = new char[m_width+1];
  488 + strncpy(m_nulval, value.c_str(), m_width);
  489 + }
  490 +
  491 + // Return
  492 + return;
  493 +}
  494 +
  495 +
  496 +/***********************************************************************//**
532 497 * @brief Initialise column data
533 498 ***************************************************************************/
534   -void GFitsTableStrCol::init_data(void)
  499 +void GFitsTableStringCol::init_data(void)
535 500 {
536 501 // Initialise data if they exist
537 502 if (m_data != NULL) {
... ... @@ -553,7 +518,7 @@ void GFitsTableStrCol::init_data(void)
553 518 *
554 519 * Refer to GFitsTableCol::load_column for more information.
555 520 ***************************************************************************/
556   -void GFitsTableStrCol::fetch_data(void)
  521 +void GFitsTableStringCol::fetch_data(void)
557 522 {
558 523 // Calculate size of memory
559 524 m_size = m_number * m_length;
... ... @@ -582,9 +547,12 @@ void GFitsTableStrCol::fetch_data(void)
582 547  
583 548  
584 549 /***********************************************************************//**
585   - * @brief Allocate buffer memory
  550 + * @brief Allocate CFITSIO transfer buffer
  551 + *
  552 + * The CFITSIO transfer buffer allows transparent conversion from the CFITSIO
  553 + * storage format to a vector of strings.
586 554 ***************************************************************************/
587   -void GFitsTableStrCol::alloc_buffer(void)
  555 +void GFitsTableStringCol::alloc_buffer(void)
588 556 {
589 557 // Allocate buffer memory
590 558 if (m_size > 0) {
... ... @@ -607,9 +575,11 @@ void GFitsTableStrCol::alloc_buffer(void)
607 575  
608 576  
609 577 /***********************************************************************//**
610   - * @brief Free buffer memory
  578 + * @brief Free CFITSIO transfer buffer
  579 + *
  580 + * Release memory that has been allocated for the CFITSIO transfer buffer.
611 581 ***************************************************************************/
612   -void GFitsTableStrCol::free_buffer(void)
  582 +void GFitsTableStringCol::free_buffer(void)
613 583 {
614 584 // If there was a buffer allocated then free it
615 585 if (m_buffer != NULL) {
... ... @@ -637,7 +607,7 @@ void GFitsTableStrCol::free_buffer(void)
637 607 * @param[in] os Output stream.
638 608 * @param[in] column Column to put in output stream.
639 609 ***************************************************************************/
640   -std::ostream& operator<< (std::ostream& os, const GFitsTableStrCol& column)
  610 +std::ostream& operator<< (std::ostream& os, const GFitsTableStringCol& column)
641 611 {
642 612 // Dump column in output stream
643 613 column.dump_column(os, column.m_data);
... ...
src/fits/GFitsTableULongCol.cpp 0 → 100644
  1 +/***************************************************************************
  2 + * GFitsTableULongCol.cpp - FITS table unsigned long column class *
  3 + * ----------------------------------------------------------------------- *
  4 + * copyright (C) 2010 by Jurgen Knodlseder *
  5 + * ----------------------------------------------------------------------- *
  6 + * *
  7 + * This program is free software; you can redistribute it and/or modify *
  8 + * it under the terms of the GNU General Public License as published by *
  9 + * the Free Software Foundation; either version 2 of the License, or *
  10 + * (at your option) any later version. *
  11 + * *
  12 + ***************************************************************************/
  13 +
  14 +/* __ Includes ___________________________________________________________ */
  15 +#ifdef HAVE_CONFIG_H
  16 +#include <config.h>
  17 +#endif
  18 +#include <iostream>
  19 +#include "GException.hpp"
  20 +#include "GTools.hpp"
  21 +#include "GFitsTableULongCol.hpp"
  22 +
  23 +/* __ Method name definitions ____________________________________________ */
  24 +
  25 +/* __ Macros _____________________________________________________________ */
  26 +
  27 +/* __ Coding definitions _________________________________________________ */
  28 +
  29 +/* __ Debug definitions __________________________________________________ */
  30 +
  31 +
  32 +/*==========================================================================
  33 + = =
  34 + = Constructors/destructors =
  35 + = =
  36 + ==========================================================================*/
  37 +
  38 +/***********************************************************************//**
  39 + * @brief Constructor
  40 + ***************************************************************************/
  41 +GFitsTableULongCol::GFitsTableULongCol(void) : GFitsTableCol()
  42 +{
  43 + // Initialise class members for clean destruction
  44 + init_members();
  45 +
  46 + // Return
  47 + return;
  48 +}
  49 +
  50 +
  51 +/***********************************************************************//**
  52 + * @brief Constructor
  53 + *
  54 + * @param[in] name Name of column.
  55 + * @param[in] length Length of column.
  56 + * @param[in] size Vector size of column.
  57 + ***************************************************************************/
  58 +GFitsTableULongCol::GFitsTableULongCol(const std::string& name,
  59 + const int& length,
  60 + const int& size)
  61 + : GFitsTableCol(name, length, size, 2)
  62 +{
  63 + // Initialise class members for clean destruction
  64 + init_members();
  65 +
  66 + // Return
  67 + return;
  68 +}
  69 +
  70 +
  71 +/***********************************************************************//**
  72 + * @brief Copy constructor
  73 + *
  74 + * @param[in] column Column from which class instance should be built.
  75 + ***************************************************************************/
  76 +GFitsTableULongCol::GFitsTableULongCol(const GFitsTableULongCol& column)
  77 + : GFitsTableCol(column)
  78 +{
  79 + // Initialise class members for clean destruction
  80 + init_members();
  81 +
  82 + // Copy members
  83 + copy_members(column);
  84 +
  85 + // Return
  86 + return;
  87 +}
  88 +
  89 +
  90 +/***********************************************************************//**
  91 + * @brief Destructor
  92 + ***************************************************************************/
  93 +GFitsTableULongCol::~GFitsTableULongCol(void)
  94 +{
  95 + // Free members
  96 + free_members();
  97 +
  98 + // Return
  99 + return;
  100 +}
  101 +
  102 +
  103 +/*==========================================================================
  104 + = =
  105 + = Operators =
  106 + = =
  107 + ==========================================================================*/
  108 +
  109 +/***********************************************************************//**
  110 + * @brief Assignment operator
  111 + *
  112 + * @param[in] column Column which should be assigned
  113 + ***************************************************************************/
  114 +GFitsTableULongCol& GFitsTableULongCol::operator= (const GFitsTableULongCol& column)
  115 +{
  116 + // Execute only if object is not identical
  117 + if (this != &column) {
  118 +
  119 + // Copy base class members
  120 + this->GFitsTableCol::operator=(column);
  121 +
  122 + // Free members
  123 + free_members();
  124 +
  125 + // Initialise private members for clean destruction
  126 + init_members();
  127 +
  128 + // Copy members
  129 + copy_members(column);
  130 +
  131 + } // endif: object was not identical
  132 +
  133 + // Return this object
  134 + return *this;
  135 +}
  136 +
  137 +
  138 +/***********************************************************************//**
  139 + * @brief Column data access operator
  140 + *
  141 + * @param[in] row Row of column to access.
  142 + * @param[in] inx Vector index in column row to access
  143 + *
  144 + * Provides access to data in a column.
  145 + ***************************************************************************/
  146 +unsigned long& GFitsTableULongCol::operator() (const int& row, const int& inx)
  147 +{
  148 + // If data are not available then load them now
  149 + if (m_data == NULL) fetch_data();
  150 +
  151 + // Return data bin
  152 + return m_data[offset(row, inx)];
  153 +}
  154 +
  155 +
  156 +/***********************************************************************//**
  157 + * @brief Column data access operator (const variant)
  158 + *
  159 + * @param[in] row Row of column to access.
  160 + * @param[in] inx Vector index in column row to access
  161 + *
  162 + * Provides access to data in a column.
  163 + ***************************************************************************/
  164 +const unsigned long& GFitsTableULongCol::operator() (const int& row, const int& inx) const
  165 +{
  166 + // If data are not available then load them now
  167 + if (m_data == NULL) ((GFitsTableULongCol*)this)->fetch_data();
  168 +
  169 + // Return data bin
  170 + return m_data[offset(row, inx)];
  171 +}
  172 +
  173 +
  174 +/*==========================================================================
  175 + = =
  176 + = Public methods =
  177 + = =
  178 + ==========================================================================*/
  179 +
  180 +/***********************************************************************//**
  181 + * @brief Get string value
  182 + *
  183 + * @param[in] row Table row.
  184 + * @param[in] inx Table column vector index.
  185 + *
  186 + * Returns value of specified row and vector index as string.
  187 + ***************************************************************************/
  188 +std::string GFitsTableULongCol::string(const int& row, const int& inx)
  189 +{
  190 + // If data are not available then load them now
  191 + if (m_data == NULL) fetch_data();
  192 +
  193 + // Convert unsigned long into string
  194 + std::ostringstream s_value;
  195 + s_value << m_data[offset(row,inx)];
  196 +
  197 + // Return value
  198 + return s_value.str();
  199 +}
  200 +
  201 +
  202 +/***********************************************************************//**
  203 + * @brief Get double precision value
  204 + *
  205 + * @param[in] row Table row.
  206 + * @param[in] inx Table column vector index.
  207 + *
  208 + * Returns value of specified row and vector index as double precision.
  209 + ***************************************************************************/
  210 +double GFitsTableULongCol::real(const int& row, const int& inx)
  211 +{
  212 + // If data are not available then load them now
  213 + if (m_data == NULL) fetch_data();
  214 +
  215 + // Convert unsigned long into double
  216 + double value = (double)m_data[offset(row,inx)];
  217 +
  218 + // Return value
  219 + return value;
  220 +}
  221 +
  222 +
  223 +/***********************************************************************//**
  224 + * @brief Get integer value
  225 + *
  226 + * @param[in] row Table row.
  227 + * @param[in] inx Table column vector index.
  228 + *
  229 + * Returns value of specified row and vector index as integer.
  230 + ***************************************************************************/
  231 +int GFitsTableULongCol::integer(const int& row, const int& inx)
  232 +{
  233 + // If data are not available then load them now
  234 + if (m_data == NULL) fetch_data();
  235 +
  236 + // Convert unsigned long into int
  237 + int value = (int)m_data[offset(row,inx)];
  238 +
  239 + // Return value
  240 + return value;
  241 +}
  242 +
  243 +
  244 +/***********************************************************************//**
  245 + * @brief Set NULL value
  246 + *
  247 + * @param[in] value Pointer on NULL value
  248 + *
  249 + * Allows the specification of the FITS table NULL value. If value=NULL the
  250 + * data will not be screened for NULL values.
  251 + *
  252 + * @todo To correctly reflect the NULL value in the data, the column should
  253 + * be reloaded. However, the column may have been changed, so in principle
  254 + * saving is needed. However, we may not want to store the data, hence saving
  255 + * is also not desired. We thus have to develop a method to update the
  256 + * column information for a new NULL value in place ...
  257 + ***************************************************************************/
  258 +void GFitsTableULongCol::nullval(const unsigned long* value)
  259 +{
  260 + // Allocate nul value
  261 + alloc_nulval(value);
  262 +
  263 + // Update column
  264 +// if (m_data != NULL) {
  265 +// save();
  266 +// load();
  267 +// }
  268 +
  269 + // Return
  270 + return;
  271 +}
  272 +
  273 +
  274 +/*==========================================================================
  275 + = =
  276 + = Private methods =
  277 + = =
  278 + ==========================================================================*/
  279 +
  280 +/***********************************************************************//**
  281 + * @brief Initialise class members
  282 + ***************************************************************************/
  283 +void GFitsTableULongCol::init_members(void)
  284 +{
  285 + // Initialise members
  286 + m_type = __TULONG;
  287 + m_data = NULL;
  288 + m_nulval = NULL;
  289 +
  290 + // Return
  291 + return;
  292 +}
  293 +
  294 +
  295 +/***********************************************************************//**
  296 + * @brief Copy class members
  297 + *
  298 + * @param[in] column Column for which members should be copied.
  299 + *
  300 + * Sets the content of the vector column by copying from another column.
  301 + * If the code is compiled with the small memory option, and if the source
  302 + * column has not yet been loaded, then we only load the column temporarily
  303 + * for copying purposes and release it again once copying is finished.
  304 + ***************************************************************************/
  305 +void GFitsTableULongCol::copy_members(const GFitsTableULongCol& column)
  306 +{
  307 + // Fetch column data if not yet fetched. The casting circumvents the
  308 + // const correctness
  309 + bool not_loaded = (column.m_data == NULL);
  310 + if (not_loaded) ((GFitsTableULongCol*)(&column))->fetch_data();
  311 +
  312 + // Copy attributes
  313 + m_type = column.m_type;
  314 + m_size = column.m_size;
  315 +
  316 + // Copy column data
  317 + if (column.m_data != NULL && m_size > 0) {
  318 + alloc_data();
  319 + for (int i = 0; i < m_size; ++i)
  320 + m_data[i] = column.m_data[i];
  321 + }
  322 +
  323 + // Copy NULL value
  324 + alloc_nulval(column.m_nulval);
  325 +
  326 + // Small memory option: release column if it was fetch above
  327 + #if defined(G_SMALL_MEMORY)
  328 + if (not_loaded) ((GFitsTableULongCol*)(&column))->release_data();
  329 + #endif
  330 +
  331 + // Return
  332 + return;
  333 +}
  334 +
  335 +
  336 +/***********************************************************************//**
  337 + * @brief Delete class members
  338 + ***************************************************************************/
  339 +void GFitsTableULongCol::free_members(void)
  340 +{
  341 + // Free memory
  342 + if (m_data != NULL) delete [] m_data;
  343 + if (m_nulval != NULL) delete m_nulval;
  344 +
  345 + // Mark memory as freed
  346 + m_data = NULL;
  347 + m_nulval = NULL;
  348 +
  349 + // Return
  350 + return;
  351 +}
  352 +
  353 +
  354 +/***********************************************************************//**
  355 + * @brief Clone column
  356 + ***************************************************************************/
  357 +GFitsTableULongCol* GFitsTableULongCol::clone(void) const
  358 +{
  359 + return new GFitsTableULongCol(*this);
  360 +}
  361 +
  362 +
  363 +/***********************************************************************//**
  364 + * @brief Returns format string of ASCII table
  365 + ***************************************************************************/
  366 +std::string GFitsTableULongCol::ascii_format(void) const
  367 +{
  368 + // Initialize format string
  369 + std::string format;
  370 +
  371 + // Set type code
  372 + format.append("V");
  373 +
  374 + // Set width
  375 + format.append(str(m_width));
  376 +
  377 + // Return format
  378 + return format;
  379 +}
  380 +
  381 +
  382 +/***********************************************************************//**
  383 + * @brief Returns format string of binary table
  384 + ***************************************************************************/
  385 +std::string GFitsTableULongCol::binary_format(void) const
  386 +{
  387 + // Initialize format string
  388 + std::string format;
  389 +
  390 + // Set number of elements
  391 + format.append(str(m_number));
  392 +
  393 + // Set type code
  394 + format.append("V");
  395 +
  396 + // Return format
  397 + return format;
  398 +}
  399 +
  400 +
  401 +/***********************************************************************//**
  402 + * @brief Allocates column data
  403 + ***************************************************************************/
  404 +void GFitsTableULongCol::alloc_data(void)
  405 +{
  406 + // Free any existing memory
  407 + if (m_data != NULL) delete [] m_data;
  408 +
  409 + // Mark pointer as free
  410 + m_data = NULL;
  411 +
  412 + // Allocate new data
  413 + if (m_size > 0)
  414 + m_data = new unsigned long[m_size];
  415 +
  416 + // Return
  417 + return;
  418 +}
  419 +
  420 +
  421 +/***********************************************************************//**
  422 + * @brief Release column data
  423 + ***************************************************************************/
  424 +void GFitsTableULongCol::release_data(void)
  425 +{
  426 + // Free any existing memory
  427 + if (m_data != NULL) delete [] m_data;
  428 +
  429 + // Mark pointer as free and reset loaded vector size
  430 + m_data = NULL;
  431 + m_size = 0;
  432 +
  433 + // Return
  434 + return;
  435 +}
  436 +
  437 +
  438 +/***********************************************************************//**
  439 + * @brief Allocates null value
  440 + ***************************************************************************/
  441 +void GFitsTableULongCol::alloc_nulval(const unsigned long* value)
  442 +{
  443 + // Free any existing memory
  444 + if (m_nulval != NULL) delete m_nulval;
  445 +
  446 + // Mark pointer as free
  447 + m_nulval = NULL;
  448 +
  449 + // If we have valid value, allocate and set nul value
  450 + if (value != NULL) {
  451 + m_nulval = new unsigned long;
  452 + *m_nulval = *value;
  453 + }
  454 +
  455 + // Return
  456 + return;
  457 +}
  458 +
  459 +
  460 +/***********************************************************************//**
  461 + * @brief Initialise column data
  462 + ***************************************************************************/
  463 +void GFitsTableULongCol::init_data(void)
  464 +{
  465 + // Initialise data if they exist
  466 + if (m_data != NULL) {
  467 + for (int i = 0; i < m_size; ++i)
  468 + m_data[i] = 0;
  469 + }
  470 +
  471 + // Return
  472 + return;
  473 +}
  474 +
  475 +
  476 +/*==========================================================================
  477 + = =
  478 + = Friends =
  479 + = =
  480 + ==========================================================================*/
  481 +
  482 +/***********************************************************************//**
  483 + * @brief Output operator
  484 + *
  485 + * @param[in] os Output stream.
  486 + * @param[in] column Column to put in output stream.
  487 + ***************************************************************************/
  488 +std::ostream& operator<< (std::ostream& os, const GFitsTableULongCol& column)
  489 +{
  490 + // Dump column in output stream
  491 + column.dump_column(os, column.m_data);
  492 +
  493 + // Return output stream
  494 + return os;
  495 +}
... ...
src/fits/GFitsTableUShortCol.cpp 0 → 100644
  1 +/***************************************************************************
  2 + * GFitsTableUShortCol.cpp - FITS table unsigned short column class *
  3 + * ----------------------------------------------------------------------- *
  4 + * copyright (C) 2010 by Jurgen Knodlseder *
  5 + * ----------------------------------------------------------------------- *
  6 + * *
  7 + * This program is free software; you can redistribute it and/or modify *
  8 + * it under the terms of the GNU General Public License as published by *
  9 + * the Free Software Foundation; either version 2 of the License, or *
  10 + * (at your option) any later version. *
  11 + * *
  12 + ***************************************************************************/
  13 +
  14 +/* __ Includes ___________________________________________________________ */
  15 +#ifdef HAVE_CONFIG_H
  16 +#include <config.h>
  17 +#endif
  18 +#include <iostream>
  19 +#include "GException.hpp"
  20 +#include "GTools.hpp"
  21 +#include "GFitsTableUShortCol.hpp"
  22 +
  23 +/* __ Method name definitions ____________________________________________ */
  24 +
  25 +/* __ Macros _____________________________________________________________ */
  26 +
  27 +/* __ Coding definitions _________________________________________________ */
  28 +
  29 +/* __ Debug definitions __________________________________________________ */
  30 +
  31 +
  32 +/*==========================================================================
  33 + = =
  34 + = Constructors/destructors =
  35 + = =
  36 + ==========================================================================*/
  37 +
  38 +/***********************************************************************//**
  39 + * @brief Constructor
  40 + ***************************************************************************/
  41 +GFitsTableUShortCol::GFitsTableUShortCol(void) : GFitsTableCol()
  42 +{
  43 + // Initialise class members for clean destruction
  44 + init_members();
  45 +
  46 + // Return
  47 + return;
  48 +}
  49 +
  50 +
  51 +/***********************************************************************//**
  52 + * @brief Constructor
  53 + *
  54 + * @param[in] name Name of column.
  55 + * @param[in] length Length of column.
  56 + * @param[in] size Vector size of column.
  57 + ***************************************************************************/
  58 +GFitsTableUShortCol::GFitsTableUShortCol(const std::string& name,
  59 + const int& length,
  60 + const int& size)
  61 + : GFitsTableCol(name, length, size, 2)
  62 +{
  63 + // Initialise class members for clean destruction
  64 + init_members();
  65 +
  66 + // Return
  67 + return;
  68 +}
  69 +
  70 +
  71 +/***********************************************************************//**
  72 + * @brief Copy constructor
  73 + *
  74 + * @param[in] column Column from which class instance should be built.
  75 + ***************************************************************************/
  76 +GFitsTableUShortCol::GFitsTableUShortCol(const GFitsTableUShortCol& column)
  77 + : GFitsTableCol(column)
  78 +{
  79 + // Initialise class members for clean destruction
  80 + init_members();
  81 +
  82 + // Copy members
  83 + copy_members(column);
  84 +
  85 + // Return
  86 + return;
  87 +}
  88 +
  89 +
  90 +/***********************************************************************//**
  91 + * @brief Destructor
  92 + ***************************************************************************/
  93 +GFitsTableUShortCol::~GFitsTableUShortCol(void)
  94 +{
  95 + // Free members
  96 + free_members();
  97 +
  98 + // Return
  99 + return;
  100 +}
  101 +
  102 +
  103 +/*==========================================================================
  104 + = =
  105 + = Operators =
  106 + = =
  107 + ==========================================================================*/
  108 +
  109 +/***********************************************************************//**
  110 + * @brief Assignment operator
  111 + *
  112 + * @param[in] column Column which should be assigned
  113 + ***************************************************************************/
  114 +GFitsTableUShortCol& GFitsTableUShortCol::operator= (const GFitsTableUShortCol& column)
  115 +{
  116 + // Execute only if object is not identical
  117 + if (this != &column) {
  118 +
  119 + // Copy base class members
  120 + this->GFitsTableCol::operator=(column);
  121 +
  122 + // Free members
  123 + free_members();
  124 +
  125 + // Initialise private members for clean destruction
  126 + init_members();
  127 +
  128 + // Copy members
  129 + copy_members(column);
  130 +
  131 + } // endif: object was not identical
  132 +
  133 + // Return this object
  134 + return *this;
  135 +}
  136 +
  137 +
  138 +/***********************************************************************//**
  139 + * @brief Column data access operator
  140 + *
  141 + * @param[in] row Row of column to access.
  142 + * @param[in] inx Vector index in column row to access
  143 + *
  144 + * Provides access to data in a column.
  145 + ***************************************************************************/
  146 +unsigned short& GFitsTableUShortCol::operator() (const int& row, const int& inx)
  147 +{
  148 + // If data are not available then load them now
  149 + if (m_data == NULL) fetch_data();
  150 +
  151 + // Return data bin
  152 + return m_data[offset(row, inx)];
  153 +}
  154 +
  155 +
  156 +/***********************************************************************//**
  157 + * @brief Column data access operator (const variant)
  158 + *
  159 + * @param[in] row Row of column to access.
  160 + * @param[in] inx Vector index in column row to access
  161 + *
  162 + * Provides access to data in a column.
  163 + ***************************************************************************/
  164 +const unsigned short& GFitsTableUShortCol::operator() (const int& row, const int& inx) const
  165 +{
  166 + // If data are not available then load them now
  167 + if (m_data == NULL) ((GFitsTableUShortCol*)this)->fetch_data();
  168 +
  169 + // Return data bin
  170 + return m_data[offset(row, inx)];
  171 +}
  172 +
  173 +
  174 +/*==========================================================================
  175 + = =
  176 + = Public methods =
  177 + = =
  178 + ==========================================================================*/
  179 +
  180 +/***********************************************************************//**
  181 + * @brief Get string value
  182 + *
  183 + * @param[in] row Table row.
  184 + * @param[in] inx Table column vector index.
  185 + *
  186 + * Returns value of specified row and vector index as string.
  187 + ***************************************************************************/
  188 +std::string GFitsTableUShortCol::string(const int& row, const int& inx)
  189 +{
  190 + // If data are not available then load them now
  191 + if (m_data == NULL) fetch_data();
  192 +
  193 + // Convert unsigned short into string
  194 + std::ostringstream s_value;
  195 + s_value << m_data[offset(row,inx)];
  196 +
  197 + // Return value
  198 + return s_value.str();
  199 +}
  200 +
  201 +
  202 +/***********************************************************************//**
  203 + * @brief Get double precision value
  204 + *
  205 + * @param[in] row Table row.
  206 + * @param[in] inx Table column vector index.
  207 + *
  208 + * Returns value of specified row and vector index as double precision.
  209 + ***************************************************************************/
  210 +double GFitsTableUShortCol::real(const int& row, const int& inx)
  211 +{
  212 + // If data are not available then load them now
  213 + if (m_data == NULL) fetch_data();
  214 +
  215 + // Convert unsigned short into double
  216 + double value = (double)m_data[offset(row,inx)];
  217 +
  218 + // Return value
  219 + return value;
  220 +}
  221 +
  222 +
  223 +/***********************************************************************//**
  224 + * @brief Get integer value
  225 + *
  226 + * @param[in] row Table row.
  227 + * @param[in] inx Table column vector index.
  228 + *
  229 + * Returns value of specified row and vector index as integer.
  230 + ***************************************************************************/
  231 +int GFitsTableUShortCol::integer(const int& row, const int& inx)
  232 +{
  233 + // If data are not available then load them now
  234 + if (m_data == NULL) fetch_data();
  235 +
  236 + // Convert unsigned short into int
  237 + int value = (int)m_data[offset(row,inx)];
  238 +
  239 + // Return value
  240 + return value;
  241 +}
  242 +
  243 +
  244 +/***********************************************************************//**
  245 + * @brief Set NULL value
  246 + *
  247 + * @param[in] value Pointer on NULL value
  248 + *
  249 + * Allows the specification of the FITS table NULL value. If value=NULL the
  250 + * data will not be screened for NULL values.
  251 + *
  252 + * @todo To correctly reflect the NULL value in the data, the column should
  253 + * be reloaded. However, the column may have been changed, so in principle
  254 + * saving is needed. However, we may not want to store the data, hence saving
  255 + * is also not desired. We thus have to develop a method to update the
  256 + * column information for a new NULL value in place ...
  257 + ***************************************************************************/
  258 +void GFitsTableUShortCol::nullval(const unsigned short* value)
  259 +{
  260 + // Allocate nul value
  261 + alloc_nulval(value);
  262 +
  263 + // Update column
  264 +// if (m_data != NULL) {
  265 +// save();
  266 +// load();
  267 +// }
  268 +
  269 + // Return
  270 + return;
  271 +}
  272 +
  273 +
  274 +/*==========================================================================
  275 + = =
  276 + = Private methods =
  277 + = =
  278 + ==========================================================================*/
  279 +
  280 +/***********************************************************************//**
  281 + * @brief Initialise class members
  282 + ***************************************************************************/
  283 +void GFitsTableUShortCol::init_members(void)
  284 +{
  285 + // Initialise members
  286 + m_type = __TUSHORT;
  287 + m_data = NULL;
  288 + m_nulval = NULL;
  289 +
  290 + // Return
  291 + return;
  292 +}
  293 +
  294 +
  295 +/***********************************************************************//**
  296 + * @brief Copy class members
  297 + *
  298 + * @param[in] column Column for which members should be copied.
  299 + *
  300 + * Sets the content of the vector column by copying from another column.
  301 + * If the code is compiled with the small memory option, and if the source
  302 + * column has not yet been loaded, then we only load the column temporarily
  303 + * for copying purposes and release it again once copying is finished.
  304 + ***************************************************************************/
  305 +void GFitsTableUShortCol::copy_members(const GFitsTableUShortCol& column)
  306 +{
  307 + // Fetch column data if not yet fetched. The casting circumvents the
  308 + // const correctness
  309 + bool not_loaded = (column.m_data == NULL);
  310 + if (not_loaded) ((GFitsTableUShortCol*)(&column))->fetch_data();
  311 +
  312 + // Copy attributes
  313 + m_type = column.m_type;
  314 + m_size = column.m_size;
  315 +
  316 + // Copy column data
  317 + if (column.m_data != NULL && m_size > 0) {
  318 + alloc_data();
  319 + for (int i = 0; i < m_size; ++i)
  320 + m_data[i] = column.m_data[i];
  321 + }
  322 +
  323 + // Copy NULL value
  324 + alloc_nulval(column.m_nulval);
  325 +
  326 + // Small memory option: release column if it was fetch above
  327 + #if defined(G_SMALL_MEMORY)
  328 + if (not_loaded) ((GFitsTableUShortCol*)(&column))->release_data();
  329 + #endif
  330 +
  331 + // Return
  332 + return;
  333 +}
  334 +
  335 +
  336 +/***********************************************************************//**
  337 + * @brief Delete class members
  338 + ***************************************************************************/
  339 +void GFitsTableUShortCol::free_members(void)
  340 +{
  341 + // Free memory
  342 + if (m_data != NULL) delete [] m_data;
  343 + if (m_nulval != NULL) delete m_nulval;
  344 +
  345 + // Mark memory as freed
  346 + m_data = NULL;
  347 + m_nulval = NULL;
  348 +
  349 + // Return
  350 + return;
  351 +}
  352 +
  353 +
  354 +/***********************************************************************//**
  355 + * @brief Clone column
  356 + ***************************************************************************/
  357 +GFitsTableUShortCol* GFitsTableUShortCol::clone(void) const
  358 +{
  359 + return new GFitsTableUShortCol(*this);
  360 +}
  361 +
  362 +
  363 +/***********************************************************************//**
  364 + * @brief Returns format string of ASCII table
  365 + ***************************************************************************/
  366 +std::string GFitsTableUShortCol::ascii_format(void) const
  367 +{
  368 + // Initialize format string
  369 + std::string format;
  370 +
  371 + // Set type code
  372 + format.append("U");
  373 +
  374 + // Set width
  375 + format.append(str(m_width));
  376 +
  377 + // Return format
  378 + return format;
  379 +}
  380 +
  381 +
  382 +/***********************************************************************//**
  383 + * @brief Returns format string of binary table
  384 + ***************************************************************************/
  385 +std::string GFitsTableUShortCol::binary_format(void) const
  386 +{
  387 + // Initialize format string
  388 + std::string format;
  389 +
  390 + // Set number of elements
  391 + format.append(str(m_number));
  392 +
  393 + // Set type code
  394 + format.append("U");
  395 +
  396 + // Return format
  397 + return format;
  398 +}
  399 +
  400 +
  401 +/***********************************************************************//**
  402 + * @brief Allocates column data
  403 + ***************************************************************************/
  404 +void GFitsTableUShortCol::alloc_data(void)
  405 +{
  406 + // Free any existing memory
  407 + if (m_data != NULL) delete [] m_data;
  408 +
  409 + // Mark pointer as free
  410 + m_data = NULL;
  411 +
  412 + // Allocate new data
  413 + if (m_size > 0)
  414 + m_data = new unsigned short[m_size];
  415 +
  416 + // Return
  417 + return;
  418 +}
  419 +
  420 +
  421 +/***********************************************************************//**
  422 + * @brief Release column data
  423 + ***************************************************************************/
  424 +void GFitsTableUShortCol::release_data(void)
  425 +{
  426 + // Free any existing memory
  427 + if (m_data != NULL) delete [] m_data;
  428 +
  429 + // Mark pointer as free and reset loaded vector size
  430 + m_data = NULL;
  431 + m_size = 0;
  432 +
  433 + // Return
  434 + return;
  435 +}
  436 +
  437 +
  438 +/***********************************************************************//**
  439 + * @brief Allocates null value
  440 + ***************************************************************************/
  441 +void GFitsTableUShortCol::alloc_nulval(const unsigned short* value)
  442 +{
  443 + // Free any existing memory
  444 + if (m_nulval != NULL) delete m_nulval;
  445 +
  446 + // Mark pointer as free
  447 + m_nulval = NULL;
  448 +
  449 + // If we have valid value, allocate and set nul value
  450 + if (value != NULL) {
  451 + m_nulval = new unsigned short;
  452 + *m_nulval = *value;
  453 + }
  454 +
  455 + // Return
  456 + return;
  457 +}
  458 +
  459 +
  460 +/***********************************************************************//**
  461 + * @brief Initialise column data
  462 + ***************************************************************************/
  463 +void GFitsTableUShortCol::init_data(void)
  464 +{
  465 + // Initialise data if they exist
  466 + if (m_data != NULL) {
  467 + for (int i = 0; i < m_size; ++i)
  468 + m_data[i] = 0;
  469 + }
  470 +
  471 + // Return
  472 + return;
  473 +}
  474 +
  475 +
  476 +/*==========================================================================
  477 + = =
  478 + = Friends =
  479 + = =
  480 + ==========================================================================*/
  481 +
  482 +/***********************************************************************//**
  483 + * @brief Output operator
  484 + *
  485 + * @param[in] os Output stream.
  486 + * @param[in] column Column to put in output stream.
  487 + ***************************************************************************/
  488 +std::ostream& operator<< (std::ostream& os, const GFitsTableUShortCol& column)
  489 +{
  490 + // Dump column in output stream
  491 + column.dump_column(os, column.m_data);
  492 +
  493 + // Return output stream
  494 + return os;
  495 +}
... ...
src/fits/Makefile.am
... ... @@ -17,15 +17,15 @@ sources = GFitsHeaderCard.cpp \
17 17 GFitsBinTable.cpp \
18 18 GFitsTableCol.cpp \
19 19 GFitsTableBitCol.cpp \
20   - GFitsTableLogCol.cpp \
21   - GFitsTableStrCol.cpp \
22   - GFitsTableUStCol.cpp \
23   - GFitsTableShtCol.cpp \
24   - GFitsTableULgCol.cpp \
25   - GFitsTableLngCol.cpp \
26   - GFitsTableLlgCol.cpp \
27   - GFitsTableFltCol.cpp \
28   - GFitsTableDblCol.cpp \
  20 + GFitsTableBoolCol.cpp \
  21 + GFitsTableStringCol.cpp \
  22 + GFitsTableUShortCol.cpp \
  23 + GFitsTableShortCol.cpp \
  24 + GFitsTableULongCol.cpp \
  25 + GFitsTableLongCol.cpp \
  26 + GFitsTableLongLongCol.cpp \
  27 + GFitsTableFloatCol.cpp \
  28 + GFitsTableDoubleCol.cpp \
29 29 GFitsHDU.cpp \
30 30 GFits.cpp \
31 31 GException_fits.cpp
... ...
src/obs/GEbounds.cpp
... ... @@ -27,7 +27,7 @@
27 27 #include "GFits.hpp"
28 28 #include "GFitsHDU.hpp"
29 29 #include "GFitsBinTable.hpp"
30   -#include "GFitsTableDblCol.hpp"
  30 +#include "GFitsTableDoubleCol.hpp"
31 31  
32 32 /* __ Method name definitions ____________________________________________ */
33 33 #define G_EMIN "GEbounds::emin(int)"
... ... @@ -381,8 +381,8 @@ void GEbounds::read(GFitsHDU* hdu)
381 381 void GEbounds::write(GFits* file, const std::string& extname)
382 382 {
383 383 // Create energy boundary columns
384   - GFitsTableDblCol cemin = GFitsTableDblCol("E_MIN", m_num);
385   - GFitsTableDblCol cemax = GFitsTableDblCol("E_MAX", m_num);
  384 + GFitsTableDoubleCol cemin = GFitsTableDoubleCol("E_MIN", m_num);
  385 + GFitsTableDoubleCol cemax = GFitsTableDoubleCol("E_MAX", m_num);
386 386  
387 387 // Fill energy boundary columns
388 388 for (int i = 0; i < m_num; ++i) {
... ...
src/obs/GGti.cpp
... ... @@ -26,7 +26,7 @@
26 26 #include "GFits.hpp"
27 27 #include "GFitsHDU.hpp"
28 28 #include "GFitsBinTable.hpp"
29   -#include "GFitsTableDblCol.hpp"
  29 +#include "GFitsTableDoubleCol.hpp"
30 30  
31 31 /* __ Method name definitions ____________________________________________ */
32 32 #define G_TSTART "GGti::tstart(int)"
... ... @@ -354,8 +354,8 @@ void GGti::read(GFitsHDU* hdu)
354 354 void GGti::write(GFits* file, const std::string& extname)
355 355 {
356 356 // Create GTI columns
357   - GFitsTableDblCol cstart = GFitsTableDblCol("START", m_num);
358   - GFitsTableDblCol cstop = GFitsTableDblCol("STOP", m_num);
  357 + GFitsTableDoubleCol cstart = GFitsTableDoubleCol("START", m_num);
  358 + GFitsTableDoubleCol cstop = GFitsTableDoubleCol("STOP", m_num);
359 359  
360 360 // Fill GTI columns
361 361 for (int i = 0; i < m_num; ++i) {
... ...
src/sky/GSkymap.cpp
... ... @@ -27,7 +27,7 @@
27 27 #include "GWcsCAR.hpp"
28 28 #include "GWcsHPX.hpp"
29 29 #include "GFits.hpp"
30   -#include "GFitsTableDblCol.hpp"
  30 +#include "GFitsTableDoubleCol.hpp"
31 31 #include "GFitsImageDbl.hpp"
32 32  
33 33 /* __ Method name definitions ____________________________________________ */
... ... @@ -1250,7 +1250,7 @@ GFitsHDU* GSkymap::create_healpix_hdu(void)
1250 1250 int number = m_num_maps;
1251 1251  
1252 1252 // Create column to hold Healpix data
1253   - GFitsTableDblCol column = GFitsTableDblCol("DATA", rows, number);
  1253 + GFitsTableDoubleCol column = GFitsTableDoubleCol("DATA", rows, number);
1254 1254  
1255 1255 // Fill data into column
1256 1256 double* ptr = m_pixels;
... ...
test/test_GFits.cpp
... ... @@ -12,13 +12,12 @@
12 12 ***************************************************************************/
13 13  
14 14 /* __ Includes ___________________________________________________________ */
15   -#include <iostream> // cout, cerr
  15 +#include <iostream> // std::cout, cerr
16 16 #include <stdexcept> // std::exception
17 17 #include <stdlib.h>
18 18 #include "GammaLib.hpp"
19 19  
20 20 /* __ Namespaces _________________________________________________________ */
21   -using namespace std;
22 21  
23 22 /* __ Globals ____________________________________________________________ */
24 23  
... ... @@ -46,7 +45,7 @@ int dequal(double val, double ref)
46 45 void test_create(void)
47 46 {
48 47 // Dump header
49   - cout << "Test GFits: Create FITS file: ";
  48 + std::cout << "Test GFits: Create FITS file: ";
50 49  
51 50 // Remove FITS file
52 51 system("rm -rf test.fits");
... ... @@ -60,12 +59,14 @@ void test_create(void)
60 59 fits.append(hdu);
61 60 fits.save();
62 61 }
63   - catch (exception &e) {
64   - cout << endl << "TEST ERROR: Unable to create FITS file." << endl;
65   - cout << e.what() << endl;
  62 + catch (std::exception &e) {
  63 + std::cout << std::endl
  64 + << "TEST ERROR: Unable to create FITS file."
  65 + << std::endl;
  66 + std::cout << e.what() << std::endl;
66 67 throw;
67 68 }
68   - cout << ".";
  69 + std::cout << ".";
69 70  
70 71 // Attach double precision image
71 72 double sum = 0.0;
... ... @@ -87,12 +88,14 @@ void test_create(void)
87 88 fits.append(hdu);
88 89 fits.save();
89 90 }
90   - catch (exception &e) {
91   - cout << endl << "TEST ERROR: Unable to create FITS file." << endl;
92   - cout << e.what() << endl;
  91 + catch (std::exception &e) {
  92 + std::cout << std::endl
  93 + << "TEST ERROR: Unable to create FITS file."
  94 + << std::endl;
  95 + std::cout << e.what() << std::endl;
93 96 throw;
94 97 }
95   - cout << ".";
  98 + std::cout << ".";
96 99  
97 100 // Re-open double precision image
98 101 try {
... ... @@ -109,16 +112,20 @@ void test_create(void)
109 112 }
110 113 }
111 114 if (!dequal(total, sum)) {
112   - cout << endl << "TEST ERROR: Bad values in loaded image." << endl;
  115 + std::cout << std::endl
  116 + << "TEST ERROR: Bad values in loaded image."
  117 + << std::endl;
113 118 throw;
114 119 }
115 120 }
116   - catch (exception &e) {
117   - cout << endl << "TEST ERROR: Unable to re-open FITS file." << endl;
118   - cout << e.what() << endl;
  121 + catch (std::exception &e) {
  122 + std::cout << std::endl
  123 + << "TEST ERROR: Unable to re-open FITS file."
  124 + << std::endl;
  125 + std::cout << e.what() << std::endl;
119 126 throw;
120 127 }
121   - cout << ".";
  128 + std::cout << ".";
122 129  
123 130 // Attach binary table
124 131 try {
... ... @@ -128,18 +135,17 @@ void test_create(void)
128 135  
129 136 // Create binary Table with 10 rows
130 137 int nrows = 10;
131   - GFitsBinTable table = GFitsBinTable(nrows);
132   - GFitsTableDblCol first = GFitsTableDblCol("First", nrows);
133   - GFitsTableDblCol second = GFitsTableDblCol("Second", nrows);
  138 + GFitsBinTable table = GFitsBinTable(nrows);
  139 + GFitsTableDoubleCol first = GFitsTableDoubleCol("First", nrows);
  140 + GFitsTableDoubleCol second = GFitsTableDoubleCol("Second", nrows);
134 141 first(0) = 1.0;
135 142 first(1) = 2.0;
136 143 first(2) = 3.0;
137 144 second(0) = -99.0;
138   - cout << endl << first << endl;
139   - cout << second << endl;
  145 + std::cout << std::endl << first << std::endl;
  146 + std::cout << second << std::endl;
140 147 table.append_column(first);
141 148 table.append_column(second);
142   -// cout << table;
143 149  
144 150 // Create HDU and append to FILE file
145 151 GFitsHDU hdu(table);
... ... @@ -148,15 +154,17 @@ void test_create(void)
148 154 // Save FITS file
149 155 fits.save();
150 156 }
151   - catch (exception &e) {
152   - cout << endl << "TEST ERROR: Unable to attach binary table." << endl;
153   - cout << e.what() << endl;
  157 + catch (std::exception &e) {
  158 + std::cout << std::endl
  159 + << "TEST ERROR: Unable to attach binary table."
  160 + << std::endl;
  161 + std::cout << e.what() << std::endl;
154 162 throw;
155 163 }
156   - cout << ".";
  164 + std::cout << ".";
157 165  
158 166  
159   - cout << ". ok." << endl;
  167 + std::cout << ". ok." << std::endl;
160 168 }
161 169  
162 170  
... ... @@ -166,7 +174,7 @@ void test_create(void)
166 174 void test_image_double(void)
167 175 {
168 176 // Dump header
169   - cout << "Test GFitsDblImage: ";
  177 + std::cout << "Test GFitsDblImage: ";
170 178  
171 179 // Test 1D Image
172 180 try {
... ... @@ -174,7 +182,7 @@ void test_image_double(void)
174 182 int nx = 10;
175 183 int naxes[] = {nx};
176 184 GFitsImageDbl image(naxis, naxes);
177   - cout << ".";
  185 + std::cout << ".";
178 186  
179 187 // Fill and read image
180 188 try {
... ... @@ -184,27 +192,33 @@ void test_image_double(void)
184 192 for (int ix = 0; ix < nx; ++ix)
185 193 sum += image(ix);
186 194 if (!dequal(sum, 0.5*double(nx-1)*double(nx))) {
187   - cout << endl << "TEST ERROR: Bad fill/read of 1D image." << endl;
  195 + std::cout << std::endl
  196 + << "TEST ERROR: Bad fill/read of 1D image."
  197 + << std::endl;
188 198 throw;
189 199 }
190 200 }
191   - catch (exception &e) {
192   - cout << endl << "TEST ERROR: Unable to fill/read 1D image." << endl;
193   - cout << e.what() << endl;
  201 + catch (std::exception &e) {
  202 + std::cout << std::endl
  203 + << "TEST ERROR: Unable to fill/read 1D image."
  204 + << std::endl;
  205 + std::cout << e.what() << std::endl;
194 206 throw;
195 207 }
196   - cout << ".";
  208 + std::cout << ".";
197 209  
198 210 // Bad 2D operator
199 211 try {
200 212 double result = image(0,1);
201 213 }
202 214 catch (GException::fits_wrong_image_operator &e) {
203   - cout << ".";
  215 + std::cout << ".";
204 216 }
205   - catch (exception &e) {
206   - cout << endl << "TEST ERROR: Wrong operactor access error." << endl;
207   - cout << e.what() << endl;
  217 + catch (std::exception &e) {
  218 + std::cout << std::endl
  219 + << "TEST ERROR: Wrong operactor access error."
  220 + << std::endl;
  221 + std::cout << e.what() << std::endl;
208 222 throw;
209 223 }
210 224  
... ... @@ -213,11 +227,13 @@ void test_image_double(void)
213 227 double result = image(0,1,2);
214 228 }
215 229 catch (GException::fits_wrong_image_operator &e) {
216   - cout << ".";
  230 + std::cout << ".";
217 231 }
218   - catch (exception &e) {
219   - cout << endl << "TEST ERROR: Wrong operactor access error." << endl;
220   - cout << e.what() << endl;
  232 + catch (std::exception &e) {
  233 + std::cout << std::endl
  234 + << "TEST ERROR: Wrong operactor access error."
  235 + << std::endl;
  236 + std::cout << e.what() << std::endl;
221 237 throw;
222 238 }
223 239  
... ... @@ -226,21 +242,25 @@ void test_image_double(void)
226 242 double result = image(0,1,2,3);
227 243 }
228 244 catch (GException::fits_wrong_image_operator &e) {
229   - cout << ".";
  245 + std::cout << ".";
230 246 }
231   - catch (exception &e) {
232   - cout << endl << "TEST ERROR: Wrong operactor access error." << endl;
233   - cout << e.what() << endl;
  247 + catch (std::exception &e) {
  248 + std::cout << std::endl
  249 + << "TEST ERROR: Wrong operactor access error."
  250 + << std::endl;
  251 + std::cout << e.what() << std::endl;
234 252 throw;
235 253 }
236 254  
237 255 }
238   - catch (exception &e) {
239   - cout << endl << "TEST ERROR: Unable to test GFitsDblImage classes." << endl;
240   - cout << e.what() << endl;
  256 + catch (std::exception &e) {
  257 + std::cout << std::endl
  258 + << "TEST ERROR: Unable to test GFitsDblImage classes."
  259 + << std::endl;
  260 + std::cout << e.what() << std::endl;
241 261 throw;
242 262 }
243   - cout << ". ok." << endl;
  263 + std::cout << ". ok." << std::endl;
244 264 }
245 265  
246 266  
... ... @@ -253,7 +273,7 @@ void test_bintable_double(void)
253 273 std::string filename = "test_bintable_double.fits";
254 274  
255 275 // Dump header
256   - cout << "Test GFitsTableDblCol: ";
  276 + std::cout << "Test GFitsTableDoubleCol: ";
257 277  
258 278 // Remove FITS file
259 279 std::string cmd = "rm -rf "+ filename;
... ... @@ -290,84 +310,84 @@ void test_bintable_double(void)
290 310 //
291 311  
292 312 // Set double precision table
293   - GFitsTableDblCol col_dbl = GFitsTableDblCol("DOUBLE", nrows);
  313 + GFitsTableDoubleCol col_dbl = GFitsTableDoubleCol("DOUBLE", nrows);
294 314 for (int i = 0; i < nrows; ++i) {
295 315 double val_dbl = cos(double(i));
296 316 col_dbl(i) = val_dbl;
297 317 sum_dbl += val_dbl;
298 318 sum_dbl_int += int(val_dbl);
299   - ostringstream s_value;
300   - s_value << scientific << val_dbl;
  319 + std::ostringstream s_value;
  320 + s_value << std::scientific << val_dbl;
301 321 sum_dbl_str += ":"+s_value.str();
302 322 }
303   - cout << ".";
  323 + std::cout << ".";
304 324  
305 325 // Check double precision table (operator access)
306 326 tot_dbl = 0.0;
307 327 for (int i = 0; i < nrows; ++i)
308 328 tot_dbl += col_dbl(i);
309 329 if (!dequal(tot_dbl, sum_dbl)) {
310   - cout << endl << "TEST ERROR: GFitsTableDblCol::operator()";
311   - cout << endl << " Reference sum: " << sum_dbl;
312   - cout << endl << " Derived sum: " << tot_dbl << endl;
  330 + std::cout << std::endl << "TEST ERROR: GFitsTableDoubleCol::operator()";
  331 + std::cout << std::endl << " Reference sum: " << sum_dbl;
  332 + std::cout << std::endl << " Derived sum: " << tot_dbl << std::endl;
313 333 throw;
314 334 }
315   - cout << ".";
  335 + std::cout << ".";
316 336  
317 337 // Check double precision table (real access)
318 338 tot_dbl = 0.0;
319 339 for (int i = 0; i < nrows; ++i)
320 340 tot_dbl += col_dbl.real(i);
321 341 if (!dequal(tot_dbl, sum_dbl)) {
322   - cout << endl << "TEST ERROR: GFitsTableDblCol::real()";
323   - cout << endl << " Reference sum: " << sum_dbl;
324   - cout << endl << " Derived sum: " << tot_dbl << endl;
  342 + std::cout << std::endl << "TEST ERROR: GFitsTableDoubleCol::real()";
  343 + std::cout << std::endl << " Reference sum: " << sum_dbl;
  344 + std::cout << std::endl << " Derived sum: " << tot_dbl << std::endl;
325 345 throw;
326 346 }
327   - cout << ".";
  347 + std::cout << ".";
328 348  
329 349 // Check double precision table (int access)
330 350 tot_int = 0;
331 351 for (int i = 0; i < nrows; ++i)
332 352 tot_int += col_dbl.integer(i);
333 353 if (tot_int != sum_dbl_int) {
334   - cout << endl << "TEST ERROR: GFitsTableDblCol::integer()";
335   - cout << endl << " Reference sum: " << sum_dbl_int;
336   - cout << endl << " Derived sum: " << tot_int << endl;
  354 + std::cout << std::endl << "TEST ERROR: GFitsTableDoubleCol::integer()";
  355 + std::cout << std::endl << " Reference sum: " << sum_dbl_int;
  356 + std::cout << std::endl << " Derived sum: " << tot_int << std::endl;
337 357 throw;
338 358 }
339   - cout << ".";
  359 + std::cout << ".";
340 360  
341 361 // Check double precision table (string access)
342 362 tot_str.clear();
343 363 for (int i = 0; i < nrows; ++i)
344 364 tot_str += ":"+col_dbl.string(i);
345 365 if (tot_str != sum_dbl_str) {
346   - cout << endl << "TEST ERROR: GFitsTableDblCol::string()";
347   - cout << endl << " Reference sum: " << sum_dbl_str;
348   - cout << endl << " Derived sum: " << tot_str << endl;
  366 + std::cout << std::endl << "TEST ERROR: GFitsTableDoubleCol::string()";
  367 + std::cout << std::endl << " Reference sum: " << sum_dbl_str;
  368 + std::cout << std::endl << " Derived sum: " << tot_str << std::endl;
349 369 throw;
350 370 }
351   - cout << ".";
  371 + std::cout << ".";
352 372  
353 373 //
354 374 // ===== D O U B L E 1 0 =====
355 375 //
356 376  
357 377 // Set double precision table
358   - GFitsTableDblCol col_dbl10 = GFitsTableDblCol("DOUBLE10", nrows, nvec);
  378 + GFitsTableDoubleCol col_dbl10 = GFitsTableDoubleCol("DOUBLE10", nrows, nvec);
359 379 for (int i = 0; i < nrows; ++i) {
360 380 for (int j = 0; j < nvec; ++j) {
361 381 double val_dbl = cos(double(i))*cos(0.33*double(j));
362 382 col_dbl10(i,j) = val_dbl;
363 383 sum_dbl10 += val_dbl;
364 384 sum_dbl10_int += int(val_dbl);
365   - ostringstream s_value;
366   - s_value << scientific << val_dbl;
  385 + std::ostringstream s_value;
  386 + s_value << std::scientific << val_dbl;
367 387 sum_dbl10_str += ":"+s_value.str();
368 388 }
369 389 }
370   - cout << ".";
  390 + std::cout << ".";
371 391  
372 392 // Check double precision table (operator access)
373 393 tot_dbl = 0.0;
... ... @@ -376,12 +396,12 @@ void test_bintable_double(void)
376 396 tot_dbl += col_dbl10(i,j);
377 397 }
378 398 if (!dequal(tot_dbl, sum_dbl10)) {
379   - cout << endl << "TEST ERROR: GFitsTableDblCol::operator() - 10";
380   - cout << endl << " Reference sum: " << sum_dbl10;
381   - cout << endl << " Derived sum: " << tot_dbl << endl;
  399 + std::cout << std::endl << "TEST ERROR: GFitsTableDoubleCol::operator() - 10";
  400 + std::cout << std::endl << " Reference sum: " << sum_dbl10;
  401 + std::cout << std::endl << " Derived sum: " << tot_dbl << std::endl;
382 402 throw;
383 403 }
384   - cout << ".";
  404 + std::cout << ".";
385 405  
386 406 // Check double precision table (real access)
387 407 tot_dbl = 0.0;
... ... @@ -390,12 +410,12 @@ void test_bintable_double(void)
390 410 tot_dbl += col_dbl10.real(i,j);
391 411 }
392 412 if (!dequal(tot_dbl, sum_dbl10)) {
393   - cout << endl << "TEST ERROR: GFitsTableDblCol::real() - 10";
394   - cout << endl << " Reference sum: " << sum_dbl10;
395   - cout << endl << " Derived sum: " << tot_dbl << endl;
  413 + std::cout << std::endl << "TEST ERROR: GFitsTableDoubleCol::real() - 10";
  414 + std::cout << std::endl << " Reference sum: " << sum_dbl10;
  415 + std::cout << std::endl << " Derived sum: " << tot_dbl << std::endl;
396 416 throw;
397 417 }
398   - cout << ".";
  418 + std::cout << ".";
399 419  
400 420 // Check double precision table (int access)
401 421 tot_int = 0;
... ... @@ -404,12 +424,12 @@ void test_bintable_double(void)
404 424 tot_int += col_dbl10.integer(i,j);
405 425 }
406 426 if (tot_int != sum_dbl10_int) {
407   - cout << endl << "TEST ERROR: GFitsTableDblCol::integer() - 10";
408   - cout << endl << " Reference sum: " << sum_dbl10_int;
409   - cout << endl << " Derived sum: " << tot_int << endl;
  427 + std::cout << std::endl << "TEST ERROR: GFitsTableDoubleCol::integer() - 10";
  428 + std::cout << std::endl << " Reference sum: " << sum_dbl10_int;
  429 + std::cout << std::endl << " Derived sum: " << tot_int << std::endl;
410 430 throw;
411 431 }
412   - cout << ".";
  432 + std::cout << ".";
413 433  
414 434 // Check double precision table (string access)
415 435 tot_str.clear();
... ... @@ -418,12 +438,12 @@ void test_bintable_double(void)
418 438 tot_str += ":"+col_dbl10.string(i,j);
419 439 }
420 440 if (tot_str != sum_dbl10_str) {
421   - cout << endl << "TEST ERROR: GFitsTableDblCol::string() - 10";
422   - cout << endl << " Reference sum: " << sum_dbl10_str;
423   - cout << endl << " Derived sum: " << tot_str << endl;
  441 + std::cout << std::endl << "TEST ERROR: GFitsTableDoubleCol::string() - 10";
  442 + std::cout << std::endl << " Reference sum: " << sum_dbl10_str;
  443 + std::cout << std::endl << " Derived sum: " << tot_str << std::endl;
424 444 throw;
425 445 }
426   - cout << ".";
  446 + std::cout << ".";
427 447  
428 448 //
429 449 // ===== W R I T E T A B L E =====
... ... @@ -440,14 +460,14 @@ void test_bintable_double(void)
440 460  
441 461 // Save FITS file
442 462 fits.save();
443   - cout << ".";
  463 + std::cout << ".";
444 464 }
445   - catch (exception &e) {
446   - cout << endl << "TEST ERROR: Unable to build tables." << endl;
447   - cout << e.what() << endl;
  465 + catch (std::exception &e) {
  466 + std::cout << std::endl << "TEST ERROR: Unable to build tables." << std::endl;
  467 + std::cout << e.what() << std::endl;
448 468 throw;
449 469 }
450   - cout << ".";
  470 + std::cout << ".";
451 471  
452 472  
453 473 //================================================================
... ... @@ -477,64 +497,64 @@ void test_bintable_double(void)
477 497 //
478 498  
479 499 // Get column
480   - GFitsTableDblCol* col_dbl =
481   - (GFitsTableDblCol*)fits.hdu(1)->column("DOUBLE");
  500 + GFitsTableDoubleCol* col_dbl =
  501 + (GFitsTableDoubleCol*)fits.hdu(1)->column("DOUBLE");
482 502  
483 503 // Check double precision table (operator access)
484 504 tot_dbl = 0.0;
485 505 for (int i = 0; i < nrows; ++i)
486 506 tot_dbl += (*col_dbl)(i);
487 507 if (!dequal(tot_dbl, sum_dbl)) {
488   - cout << endl << "TEST ERROR: GFitsTableDblCol::operator()";
489   - cout << endl << " Reference sum: " << sum_dbl;
490   - cout << endl << " Derived sum: " << tot_dbl << endl;
  508 + std::cout << std::endl << "TEST ERROR: GFitsTableDoubleCol::operator()";
  509 + std::cout << std::endl << " Reference sum: " << sum_dbl;
  510 + std::cout << std::endl << " Derived sum: " << tot_dbl << std::endl;
491 511 throw;
492 512 }
493   - cout << ".";
  513 + std::cout << ".";
494 514  
495 515 // Check double precision table (real access)
496 516 tot_dbl = 0.0;
497 517 for (int i = 0; i < nrows; ++i)
498 518 tot_dbl += (*col_dbl).real(i);
499 519 if (!dequal(tot_dbl, sum_dbl)) {
500   - cout << endl << "TEST ERROR: GFitsTableDblCol::real()";
501   - cout << endl << " Reference sum: " << sum_dbl;
502   - cout << endl << " Derived sum: " << tot_dbl << endl;
  520 + std::cout << std::endl << "TEST ERROR: GFitsTableDoubleCol::real()";
  521 + std::cout << std::endl << " Reference sum: " << sum_dbl;
  522 + std::cout << std::endl << " Derived sum: " << tot_dbl << std::endl;
503 523 throw;
504 524 }
505   - cout << ".";
  525 + std::cout << ".";
506 526  
507 527 // Check double precision table (int access)
508 528 tot_int = 0;
509 529 for (int i = 0; i < nrows; ++i)
510 530 tot_int += (*col_dbl).integer(i);
511 531 if (tot_int != sum_dbl_int) {
512   - cout << endl << "TEST ERROR: GFitsTableDblCol::integer()";
513   - cout << endl << " Reference sum: " << sum_dbl_int;
514   - cout << endl << " Derived sum: " << tot_int << endl;
  532 + std::cout << std::endl << "TEST ERROR: GFitsTableDoubleCol::integer()";
  533 + std::cout << std::endl << " Reference sum: " << sum_dbl_int;
  534 + std::cout << std::endl << " Derived sum: " << tot_int << std::endl;
515 535 throw;
516 536 }
517   - cout << ".";
  537 + std::cout << ".";
518 538  
519 539 // Check double precision table (string access)
520 540 tot_str.clear();
521 541 for (int i = 0; i < nrows; ++i)
522 542 tot_str += ":"+ (*col_dbl).string(i);
523 543 if (tot_str != sum_dbl_str) {
524   - cout << endl << "TEST ERROR: GFitsTableDblCol::string()";
525   - cout << endl << " Reference sum: " << sum_dbl_str;
526   - cout << endl << " Derived sum: " << tot_str << endl;
  544 + std::cout << std::endl << "TEST ERROR: GFitsTableDoubleCol::string()";
  545 + std::cout << std::endl << " Reference sum: " << sum_dbl_str;
  546 + std::cout << std::endl << " Derived sum: " << tot_str << std::endl;
527 547 throw;
528 548 }
529   - cout << ".";
  549 + std::cout << ".";
530 550  
531 551 //
532 552 // ===== D O U B L E 1 0 =====
533 553 //
534 554  
535 555 // Get column
536   - GFitsTableDblCol* col_dbl10 =
537   - (GFitsTableDblCol*)fits.hdu(1)->column("DOUBLE10");
  556 + GFitsTableDoubleCol* col_dbl10 =
  557 + (GFitsTableDoubleCol*)fits.hdu(1)->column("DOUBLE10");
538 558  
539 559 // Check double precision table (operator access)
540 560 tot_dbl = 0.0;
... ... @@ -543,12 +563,12 @@ void test_bintable_double(void)
543 563 tot_dbl += (*col_dbl10)(i,j);
544 564 }
545 565 if (!dequal(tot_dbl, sum_dbl10)) {
546   - cout << endl << "TEST ERROR: GFitsTableDblCol::operator() - 10";
547   - cout << endl << " Reference sum: " << sum_dbl10;
548   - cout << endl << " Derived sum: " << tot_dbl << endl;
  566 + std::cout << std::endl << "TEST ERROR: GFitsTableDoubleCol::operator() - 10";
  567 + std::cout << std::endl << " Reference sum: " << sum_dbl10;
  568 + std::cout << std::endl << " Derived sum: " << tot_dbl << std::endl;
549 569 throw;
550 570 }
551   - cout << ".";
  571 + std::cout << ".";
552 572  
553 573 // Check double precision table (real access)
554 574 tot_dbl = 0.0;
... ... @@ -557,12 +577,12 @@ void test_bintable_double(void)
557 577 tot_dbl += col_dbl10->real(i,j);
558 578 }
559 579 if (!dequal(tot_dbl, sum_dbl10)) {
560   - cout << endl << "TEST ERROR: GFitsTableDblCol::real() - 10";
561   - cout << endl << " Reference sum: " << sum_dbl10;
562   - cout << endl << " Derived sum: " << tot_dbl << endl;
  580 + std::cout << std::endl << "TEST ERROR: GFitsTableDoubleCol::real() - 10";
  581 + std::cout << std::endl << " Reference sum: " << sum_dbl10;
  582 + std::cout << std::endl << " Derived sum: " << tot_dbl << std::endl;
563 583 throw;
564 584 }
565   - cout << ".";
  585 + std::cout << ".";
566 586  
567 587 // Check double precision table (int access)
568 588 tot_int = 0;
... ... @@ -571,12 +591,12 @@ void test_bintable_double(void)
571 591 tot_int += col_dbl10->integer(i,j);
572 592 }
573 593 if (tot_int != sum_dbl10_int) {
574   - cout << endl << "TEST ERROR: GFitsTableDblCol::integer() - 10";
575   - cout << endl << " Reference sum: " << sum_dbl10_int;
576   - cout << endl << " Derived sum: " << tot_int << endl;
  594 + std::cout << std::endl << "TEST ERROR: GFitsTableDoubleCol::integer() - 10";
  595 + std::cout << std::endl << " Reference sum: " << sum_dbl10_int;
  596 + std::cout << std::endl << " Derived sum: " << tot_int << std::endl;
577 597 throw;
578 598 }
579   - cout << ".";
  599 + std::cout << ".";
580 600  
581 601 // Check double precision table (string access)
582 602 tot_str.clear();
... ... @@ -585,19 +605,19 @@ void test_bintable_double(void)
585 605 tot_str += ":"+col_dbl10->string(i,j);
586 606 }
587 607 if (tot_str != sum_dbl10_str) {
588   - cout << endl << "TEST ERROR: GFitsTableDblCol::string() - 10";
589   - cout << endl << " Reference sum: " << sum_dbl10_str;
590   - cout << endl << " Derived sum: " << tot_str << endl;
  608 + std::cout << std::endl << "TEST ERROR: GFitsTableDoubleCol::string() - 10";
  609 + std::cout << std::endl << " Reference sum: " << sum_dbl10_str;
  610 + std::cout << std::endl << " Derived sum: " << tot_str << std::endl;
591 611 throw;
592 612 }
593   - cout << ".";
  613 + std::cout << ".";
594 614 }
595   - catch (exception &e) {
596   - cout << endl << "TEST ERROR: Unable to build tables." << endl;
597   - cout << e.what() << endl;
  615 + catch (std::exception &e) {
  616 + std::cout << std::endl << "TEST ERROR: Unable to build tables." << std::endl;
  617 + std::cout << e.what() << std::endl;
598 618 throw;
599 619 }
600   - cout << ". ok." << endl;
  620 + std::cout << ". ok." << std::endl;
601 621  
602 622 }
603 623  
... ... @@ -611,7 +631,7 @@ void test_bintable_float(void)
611 631 std::string filename = "test_bintable_float.fits";
612 632  
613 633 // Dump header
614   - cout << "Test GFitsTableFltCol: ";
  634 + std::cout << "Test GFitsTableFloatCol: ";
615 635  
616 636 // Remove FITS file
617 637 std::string cmd = "rm -rf "+ filename;
... ... @@ -648,84 +668,84 @@ void test_bintable_float(void)
648 668 //
649 669  
650 670 // Set single precision table
651   - GFitsTableFltCol col_flt = GFitsTableFltCol("FLOAT", nrows);
  671 + GFitsTableFloatCol col_flt = GFitsTableFloatCol("FLOAT", nrows);
652 672 for (int i = 0; i < nrows; ++i) {
653 673 float val_flt = cos(0.1*float(i));
654 674 col_flt(i) = val_flt;
655 675 sum_flt += val_flt;
656 676 sum_flt_int += int(val_flt);
657   - ostringstream s_value;
658   - s_value << scientific << val_flt;
  677 + std::ostringstream s_value;
  678 + s_value << std::scientific << val_flt;
659 679 sum_flt_str += ":"+s_value.str();
660 680 }
661   - cout << ".";
  681 + std::cout << ".";
662 682  
663 683 // Check single precision table (operator access)
664 684 tot_flt = 0.0;
665 685 for (int i = 0; i < nrows; ++i)
666 686 tot_flt += col_flt(i);
667 687 if (!fequal(tot_flt, sum_flt)) {
668   - cout << endl << "TEST ERROR: GFitsTableFltCol::operator()";
669   - cout << endl << " Reference sum: " << sum_flt;
670   - cout << endl << " Derived sum: " << tot_flt << endl;
  688 + std::cout << std::endl << "TEST ERROR: GFitsTableFloatCol::operator()";
  689 + std::cout << std::endl << " Reference sum: " << sum_flt;
  690 + std::cout << std::endl << " Derived sum: " << tot_flt << std::endl;
671 691 throw;
672 692 }
673   - cout << ".";
  693 + std::cout << ".";
674 694  
675 695 // Check single precision table (real access)
676 696 tot_flt = 0.0;
677 697 for (int i = 0; i < nrows; ++i)
678 698 tot_flt += col_flt.real(i);
679 699 if (!fequal(tot_flt, sum_flt)) {
680   - cout << endl << "TEST ERROR: GFitsTableFltCol::real()";
681   - cout << endl << " Reference sum: " << sum_flt;
682   - cout << endl << " Derived sum: " << tot_flt << endl;
  700 + std::cout << std::endl << "TEST ERROR: GFitsTableFloatCol::real()";
  701 + std::cout << std::endl << " Reference sum: " << sum_flt;
  702 + std::cout << std::endl << " Derived sum: " << tot_flt << std::endl;
683 703 throw;
684 704 }
685   - cout << ".";
  705 + std::cout << ".";
686 706  
687 707 // Check single precision table (int access)
688 708 tot_int = 0;
689 709 for (int i = 0; i < nrows; ++i)
690 710 tot_int += col_flt.integer(i);
691 711 if (tot_int != sum_flt_int) {
692   - cout << endl << "TEST ERROR: GFitsTableFltCol::integer()";
693   - cout << endl << " Reference sum: " << sum_flt_int;
694   - cout << endl << " Derived sum: " << tot_int << endl;
  712 + std::cout << std::endl << "TEST ERROR: GFitsTableFloatCol::integer()";
  713 + std::cout << std::endl << " Reference sum: " << sum_flt_int;
  714 + std::cout << std::endl << " Derived sum: " << tot_int << std::endl;
695 715 throw;
696 716 }
697   - cout << ".";
  717 + std::cout << ".";
698 718  
699 719 // Check single precision table (string access)
700 720 tot_str.clear();
701 721 for (int i = 0; i < nrows; ++i)
702 722 tot_str += ":"+col_flt.string(i);
703 723 if (tot_str != sum_flt_str) {
704   - cout << endl << "TEST ERROR: GFitsTableFltCol::string()";
705   - cout << endl << " Reference sum: " << sum_flt_str;
706   - cout << endl << " Derived sum: " << tot_str << endl;
  724 + std::cout << std::endl << "TEST ERROR: GFitsTableFloatCol::string()";
  725 + std::cout << std::endl << " Reference sum: " << sum_flt_str;
  726 + std::cout << std::endl << " Derived sum: " << tot_str << std::endl;
707 727 throw;
708 728 }
709   - cout << ".";
  729 + std::cout << ".";
710 730  
711 731 //
712 732 // ===== F L O A T 1 0 =====
713 733 //
714 734  
715 735 // Set single precision table
716   - GFitsTableFltCol col_flt10 = GFitsTableFltCol("FLOAT10", nrows, nvec);
  736 + GFitsTableFloatCol col_flt10 = GFitsTableFloatCol("FLOAT10", nrows, nvec);
717 737 for (int i = 0; i < nrows; ++i) {
718 738 for (int j = 0; j < nvec; ++j) {
719 739 float val_flt = cos(0.1*float(i))*cos(0.33*float(j));
720 740 col_flt10(i,j) = val_flt;
721 741 sum_flt10 += val_flt;
722 742 sum_flt10_int += int(val_flt);
723   - ostringstream s_value;
724   - s_value << scientific << val_flt;
  743 + std::ostringstream s_value;
  744 + s_value << std::scientific << val_flt;
725 745 sum_flt10_str += ":"+s_value.str();
726 746 }
727 747 }
728   - cout << ".";
  748 + std::cout << ".";
729 749  
730 750 // Check single precision table (operator access)
731 751 tot_flt = 0.0;
... ... @@ -734,12 +754,12 @@ void test_bintable_float(void)
734 754 tot_flt += col_flt10(i,j);
735 755 }
736 756 if (!fequal(tot_flt, sum_flt10)) {
737   - cout << endl << "TEST ERROR: GFitsTableFltCol::operator() - 10";
738   - cout << endl << " Reference sum: " << sum_flt10;
739   - cout << endl << " Derived sum: " << tot_flt << endl;
  757 + std::cout << std::endl << "TEST ERROR: GFitsTableFloatCol::operator() - 10";
  758 + std::cout << std::endl << " Reference sum: " << sum_flt10;
  759 + std::cout << std::endl << " Derived sum: " << tot_flt << std::endl;
740 760 throw;
741 761 }
742   - cout << ".";
  762 + std::cout << ".";
743 763  
744 764 // Check single precision table (real access)
745 765 tot_flt = 0.0;
... ... @@ -748,12 +768,12 @@ void test_bintable_float(void)
748 768 tot_flt += col_flt10.real(i,j);
749 769 }
750 770 if (!fequal(tot_flt, sum_flt10)) {
751   - cout << endl << "TEST ERROR: GFitsTableFltCol::real() - 10";
752   - cout << endl << " Reference sum: " << sum_flt10;
753   - cout << endl << " Derived sum: " << tot_flt << endl;
  771 + std::cout << std::endl << "TEST ERROR: GFitsTableFloatCol::real() - 10";
  772 + std::cout << std::endl << " Reference sum: " << sum_flt10;
  773 + std::cout << std::endl << " Derived sum: " << tot_flt << std::endl;
754 774 throw;
755 775 }
756   - cout << ".";
  776 + std::cout << ".";
757 777  
758 778 // Check double precision table (int access)
759 779 tot_int = 0;
... ... @@ -762,12 +782,12 @@ void test_bintable_float(void)
762 782 tot_int += col_flt10.integer(i,j);
763 783 }
764 784 if (tot_int != sum_flt10_int) {
765   - cout << endl << "TEST ERROR: GFitsTableFltCol::integer() - 10";
766   - cout << endl << " Reference sum: " << sum_flt10_int;
767   - cout << endl << " Derived sum: " << tot_int << endl;
  785 + std::cout << std::endl << "TEST ERROR: GFitsTableFloatCol::integer() - 10";
  786 + std::cout << std::endl << " Reference sum: " << sum_flt10_int;
  787 + std::cout << std::endl << " Derived sum: " << tot_int << std::endl;
768 788 throw;
769 789 }
770   - cout << ".";
  790 + std::cout << ".";
771 791  
772 792 // Check single precision table (string access)
773 793 tot_str.clear();
... ... @@ -776,12 +796,12 @@ void test_bintable_float(void)
776 796 tot_str += ":"+col_flt10.string(i,j);
777 797 }
778 798 if (tot_str != sum_flt10_str) {
779   - cout << endl << "TEST ERROR: GFitsTableFltCol::string() - 10";
780   - cout << endl << " Reference sum: " << sum_flt10_str;
781   - cout << endl << " Derived sum: " << tot_str << endl;
  799 + std::cout << std::endl << "TEST ERROR: GFitsTableFloatCol::string() - 10";
  800 + std::cout << std::endl << " Reference sum: " << sum_flt10_str;
  801 + std::cout << std::endl << " Derived sum: " << tot_str << std::endl;
782 802 throw;
783 803 }
784   - cout << ".";
  804 + std::cout << ".";
785 805  
786 806 //
787 807 // ===== W R I T E T A B L E =====
... ... @@ -798,15 +818,15 @@ void test_bintable_float(void)
798 818  
799 819 // Save FITS file
800 820 fits.save();
801   - cout << ".";
  821 + std::cout << ".";
802 822 }
803   - catch (exception &e) {
804   - cout << endl << "TEST ERROR: Unable to test floating point column in"
805   - " binary tables." << endl;
806   - cout << e.what() << endl;
  823 + catch (std::exception &e) {
  824 + std::cout << std::endl << "TEST ERROR: Unable to test floating point column in"
  825 + " binary tables." << std::endl;
  826 + std::cout << e.what() << std::endl;
807 827 throw;
808 828 }
809   - cout << ".";
  829 + std::cout << ".";
810 830  
811 831  
812 832 //================================================================
... ... @@ -836,64 +856,64 @@ void test_bintable_float(void)
836 856 //
837 857  
838 858 // Get column
839   - GFitsTableFltCol* col_flt =
840   - (GFitsTableFltCol*)fits.hdu(1)->column("FLOAT");
  859 + GFitsTableFloatCol* col_flt =
  860 + (GFitsTableFloatCol*)fits.hdu(1)->column("FLOAT");
841 861  
842 862 // Check single precision table (operator access)
843 863 tot_flt = 0.0;
844 864 for (int i = 0; i < nrows; ++i)
845 865 tot_flt += (*col_flt)(i);
846 866 if (!fequal(tot_flt, sum_flt)) {
847   - cout << endl << "TEST ERROR: GFitsTableFltCol::operator()";
848   - cout << endl << " Reference sum: " << sum_flt;
849   - cout << endl << " Derived sum: " << tot_flt << endl;
  867 + std::cout << std::endl << "TEST ERROR: GFitsTableFloatCol::operator()";
  868 + std::cout << std::endl << " Reference sum: " << sum_flt;
  869 + std::cout << std::endl << " Derived sum: " << tot_flt << std::endl;
850 870 throw;
851 871 }
852   - cout << ".";
  872 + std::cout << ".";
853 873  
854 874 // Check single precision table (real access)
855 875 tot_flt = 0.0;
856 876 for (int i = 0; i < nrows; ++i)
857 877 tot_flt += col_flt->real(i);
858 878 if (!fequal(tot_flt, sum_flt)) {
859   - cout << endl << "TEST ERROR: GFitsTableFltCol::real()";
860   - cout << endl << " Reference sum: " << sum_flt;
861   - cout << endl << " Derived sum: " << tot_flt << endl;
  879 + std::cout << std::endl << "TEST ERROR: GFitsTableFloatCol::real()";
  880 + std::cout << std::endl << " Reference sum: " << sum_flt;
  881 + std::cout << std::endl << " Derived sum: " << tot_flt << std::endl;
862 882 throw;
863 883 }
864   - cout << ".";
  884 + std::cout << ".";
865 885  
866 886 // Check single precision table (int access)
867 887 tot_int = 0;
868 888 for (int i = 0; i < nrows; ++i)
869 889 tot_int += col_flt->integer(i);
870 890 if (tot_int != sum_flt_int) {
871   - cout << endl << "TEST ERROR: GFitsTableFltCol::integer()";
872   - cout << endl << " Reference sum: " << sum_flt_int;
873   - cout << endl << " Derived sum: " << tot_int << endl;
  891 + std::cout << std::endl << "TEST ERROR: GFitsTableFloatCol::integer()";
  892 + std::cout << std::endl << " Reference sum: " << sum_flt_int;
  893 + std::cout << std::endl << " Derived sum: " << tot_int << std::endl;
874 894 throw;
875 895 }
876   - cout << ".";
  896 + std::cout << ".";
877 897  
878 898 // Check single precision table (string access)
879 899 tot_str.clear();
880 900 for (int i = 0; i < nrows; ++i)
881 901 tot_str += ":"+col_flt->string(i);
882 902 if (tot_str != sum_flt_str) {
883   - cout << endl << "TEST ERROR: GFitsTableFltCol::string()";
884   - cout << endl << " Reference sum: " << sum_flt_str;
885   - cout << endl << " Derived sum: " << tot_str << endl;
  903 + std::cout << std::endl << "TEST ERROR: GFitsTableFloatCol::string()";
  904 + std::cout << std::endl << " Reference sum: " << sum_flt_str;
  905 + std::cout << std::endl << " Derived sum: " << tot_str << std::endl;
886 906 throw;
887 907 }
888   - cout << ".";
  908 + std::cout << ".";
889 909  
890 910 //
891 911 // ===== F L O A T 1 0 =====
892 912 //
893 913  
894 914 // Get column
895   - GFitsTableFltCol* col_flt10 =
896   - (GFitsTableFltCol*)fits.hdu(1)->column("FLOAT10");
  915 + GFitsTableFloatCol* col_flt10 =
  916 + (GFitsTableFloatCol*)fits.hdu(1)->column("FLOAT10");
897 917  
898 918 // Check single precision table (operator access)
899 919 tot_flt = 0.0;
... ... @@ -902,12 +922,12 @@ void test_bintable_float(void)
902 922 tot_flt += (*col_flt10)(i,j);
903 923 }
904 924 if (!fequal(tot_flt, sum_flt10)) {
905   - cout << endl << "TEST ERROR: GFitsTableFltCol::operator() - 10";
906   - cout << endl << " Reference sum: " << sum_flt10;
907   - cout << endl << " Derived sum: " << tot_flt << endl;
  925 + std::cout << std::endl << "TEST ERROR: GFitsTableFloatCol::operator() - 10";
  926 + std::cout << std::endl << " Reference sum: " << sum_flt10;
  927 + std::cout << std::endl << " Derived sum: " << tot_flt << std::endl;
908 928 throw;
909 929 }
910   - cout << ".";
  930 + std::cout << ".";
911 931  
912 932 // Check single precision table (real access)
913 933 tot_flt = 0.0;
... ... @@ -916,12 +936,12 @@ void test_bintable_float(void)
916 936 tot_flt += col_flt10->real(i,j);
917 937 }
918 938 if (!fequal(tot_flt, sum_flt10)) {
919   - cout << endl << "TEST ERROR: GFitsTableFltCol::real() - 10";
920   - cout << endl << " Reference sum: " << sum_flt10;
921   - cout << endl << " Derived sum: " << tot_flt << endl;
  939 + std::cout << std::endl << "TEST ERROR: GFitsTableFloatCol::real() - 10";
  940 + std::cout << std::endl << " Reference sum: " << sum_flt10;
  941 + std::cout << std::endl << " Derived sum: " << tot_flt << std::endl;
922 942 throw;
923 943 }
924   - cout << ".";
  944 + std::cout << ".";
925 945  
926 946 // Check double precision table (int access)
927 947 tot_int = 0;
... ... @@ -930,12 +950,12 @@ void test_bintable_float(void)
930 950 tot_int += col_flt10->integer(i,j);
931 951 }
932 952 if (tot_int != sum_flt10_int) {
933   - cout << endl << "TEST ERROR: GFitsTableFltCol::integer() - 10";
934   - cout << endl << " Reference sum: " << sum_flt10_int;
935   - cout << endl << " Derived sum: " << tot_int << endl;
  953 + std::cout << std::endl << "TEST ERROR: GFitsTableFloatCol::integer() - 10";
  954 + std::cout << std::endl << " Reference sum: " << sum_flt10_int;
  955 + std::cout << std::endl << " Derived sum: " << tot_int << std::endl;
936 956 throw;
937 957 }
938   - cout << ".";
  958 + std::cout << ".";
939 959  
940 960 // Check single precision table (string access)
941 961 tot_str.clear();
... ... @@ -944,20 +964,20 @@ void test_bintable_float(void)
944 964 tot_str += ":"+col_flt10->string(i,j);
945 965 }
946 966 if (tot_str != sum_flt10_str) {
947   - cout << endl << "TEST ERROR: GFitsTableFltCol::string() - 10";
948   - cout << endl << " Reference sum: " << sum_flt10_str;
949   - cout << endl << " Derived sum: " << tot_str << endl;
  967 + std::cout << std::endl << "TEST ERROR: GFitsTableFloatCol::string() - 10";
  968 + std::cout << std::endl << " Reference sum: " << sum_flt10_str;
  969 + std::cout << std::endl << " Derived sum: " << tot_str << std::endl;
950 970 throw;
951 971 }
952   - cout << ".";
  972 + std::cout << ".";
953 973  
954 974 }
955   - catch (exception &e) {
956   - cout << endl << "TEST ERROR: Unable to build tables." << endl;
957   - cout << e.what() << endl;
  975 + catch (std::exception &e) {
  976 + std::cout << std::endl << "TEST ERROR: Unable to build tables." << std::endl;
  977 + std::cout << e.what() << std::endl;
958 978 throw;
959 979 }
960   - cout << ". ok." << endl;
  980 + std::cout << ". ok." << std::endl;
961 981  
962 982 }
963 983  
... ... @@ -971,7 +991,7 @@ void test_bintable_short(void)
971 991 std::string filename = "test_bintable_short.fits";
972 992  
973 993 // Dump header
974   - cout << "Test GFitsTableShtCol: ";
  994 + std::cout << "Test GFitsTableShortCol: ";
975 995  
976 996 // Remove FITS file
977 997 std::string cmd = "rm -rf "+ filename;
... ... @@ -1008,72 +1028,72 @@ void test_bintable_short(void)
1008 1028 //
1009 1029  
1010 1030 // Set short table
1011   - GFitsTableShtCol col_sht = GFitsTableShtCol("SHORT", nrows);
  1031 + GFitsTableShortCol col_sht = GFitsTableShortCol("SHORT", nrows);
1012 1032 for (int i = 0; i < nrows; ++i) {
1013 1033 short val_sht = short(1000.0 * cos(0.1*float(i)));
1014 1034 col_sht(i) = val_sht;
1015 1035 sum_sht += val_sht;
1016 1036 sum_sht_int += int(val_sht);
1017   - ostringstream s_value;
  1037 + std::ostringstream s_value;
1018 1038 s_value << val_sht;
1019 1039 sum_sht_str += ":"+s_value.str();
1020 1040 }
1021   - cout << ".";
  1041 + std::cout << ".";
1022 1042  
1023 1043 // Check short table (operator access)
1024 1044 tot_sht = 0;
1025 1045 for (int i = 0; i < nrows; ++i)
1026 1046 tot_sht += col_sht(i);
1027 1047 if (tot_sht != sum_sht) {
1028   - cout << endl << "TEST ERROR: GFitsTableShtCol::operator()";
1029   - cout << endl << " Reference sum: " << sum_sht;
1030   - cout << endl << " Derived sum: " << tot_sht << endl;
  1048 + std::cout << std::endl << "TEST ERROR: GFitsTableShortCol::operator()";
  1049 + std::cout << std::endl << " Reference sum: " << sum_sht;
  1050 + std::cout << std::endl << " Derived sum: " << tot_sht << std::endl;
1031 1051 throw;
1032 1052 }
1033   - cout << ".";
  1053 + std::cout << ".";
1034 1054  
1035 1055 // Check short table (real access)
1036 1056 tot_dbl = 0.0;
1037 1057 for (int i = 0; i < nrows; ++i)
1038 1058 tot_dbl += col_sht.real(i);
1039 1059 if (!dequal(tot_dbl, double(sum_sht))) {
1040   - cout << endl << "TEST ERROR: GFitsTableShtCol::real()";
1041   - cout << endl << " Reference sum: " << sum_sht;
1042   - cout << endl << " Derived sum: " << tot_dbl << endl;
  1060 + std::cout << std::endl << "TEST ERROR: GFitsTableShortCol::real()";
  1061 + std::cout << std::endl << " Reference sum: " << sum_sht;
  1062 + std::cout << std::endl << " Derived sum: " << tot_dbl << std::endl;
1043 1063 throw;
1044 1064 }
1045   - cout << ".";
  1065 + std::cout << ".";
1046 1066  
1047 1067 // Check short table (int access)
1048 1068 tot_int = 0;
1049 1069 for (int i = 0; i < nrows; ++i)
1050 1070 tot_int += col_sht.integer(i);
1051 1071 if (tot_int != sum_sht_int) {
1052   - cout << endl << "TEST ERROR: GFitsTableShtCol::integer()";
1053   - cout << endl << " Reference sum: " << sum_sht_int;
1054   - cout << endl << " Derived sum: " << tot_int << endl;
  1072 + std::cout << std::endl << "TEST ERROR: GFitsTableShortCol::integer()";
  1073 + std::cout << std::endl << " Reference sum: " << sum_sht_int;
  1074 + std::cout << std::endl << " Derived sum: " << tot_int << std::endl;
1055 1075 throw;
1056 1076 }
1057   - cout << ".";
  1077 + std::cout << ".";
1058 1078  
1059 1079 // Check single precision table (string access)
1060 1080 tot_str.clear();
1061 1081 for (int i = 0; i < nrows; ++i)
1062 1082 tot_str += ":"+col_sht.string(i);
1063 1083 if (tot_str != sum_sht_str) {
1064   - cout << endl << "TEST ERROR: GFitsTableShtCol::string()";
1065   - cout << endl << " Reference sum: " << sum_sht_str;
1066   - cout << endl << " Derived sum: " << tot_str << endl;
  1084 + std::cout << std::endl << "TEST ERROR: GFitsTableShortCol::string()";
  1085 + std::cout << std::endl << " Reference sum: " << sum_sht_str;
  1086 + std::cout << std::endl << " Derived sum: " << tot_str << std::endl;
1067 1087 throw;
1068 1088 }
1069   - cout << ".";
  1089 + std::cout << ".";
1070 1090  
1071 1091 //
1072 1092 // ===== S H O R T 1 0 =====
1073 1093 //
1074 1094  
1075 1095 // Set short table
1076   - GFitsTableShtCol col_sht10 = GFitsTableShtCol("SHORT10", nrows, nvec);
  1096 + GFitsTableShortCol col_sht10 = GFitsTableShortCol("SHORT10", nrows, nvec);
1077 1097 for (int i = 0; i < nrows; ++i) {
1078 1098 for (int j = 0; j < nvec; ++j) {
1079 1099 short val_sht = short(100.0*cos(0.1*float(i))*
... ... @@ -1081,12 +1101,12 @@ void test_bintable_short(void)
1081 1101 col_sht10(i,j) = val_sht;
1082 1102 sum_sht10 += val_sht;
1083 1103 sum_sht10_int += int(val_sht);
1084   - ostringstream s_value;
  1104 + std::ostringstream s_value;
1085 1105 s_value << val_sht;
1086 1106 sum_sht10_str += ":"+s_value.str();
1087 1107 }
1088 1108 }
1089   - cout << ".";
  1109 + std::cout << ".";
1090 1110  
1091 1111 // Check short table (operator access)
1092 1112 tot_sht = 0;
... ... @@ -1095,12 +1115,12 @@ void test_bintable_short(void)
1095 1115 tot_sht += col_sht10(i,j);
1096 1116 }
1097 1117 if (tot_sht != sum_sht10) {
1098   - cout << endl << "TEST ERROR: GFitsTableShtCol::operator() - 10";
1099   - cout << endl << " Reference sum: " << sum_sht10;
1100   - cout << endl << " Derived sum: " << tot_sht << endl;
  1118 + std::cout << std::endl << "TEST ERROR: GFitsTableShortCol::operator() - 10";
  1119 + std::cout << std::endl << " Reference sum: " << sum_sht10;
  1120 + std::cout << std::endl << " Derived sum: " << tot_sht << std::endl;
1101 1121 throw;
1102 1122 }
1103   - cout << ".";
  1123 + std::cout << ".";
1104 1124  
1105 1125 // Check short table (real access)
1106 1126 tot_dbl = 0.0;
... ... @@ -1109,12 +1129,12 @@ void test_bintable_short(void)
1109 1129 tot_dbl += col_sht10.real(i,j);
1110 1130 }
1111 1131 if (!dequal(tot_dbl, sum_sht10)) {
1112   - cout << endl << "TEST ERROR: GFitsTableShtCol::real() - 10";
1113   - cout << endl << " Reference sum: " << sum_sht10;
1114   - cout << endl << " Derived sum: " << tot_dbl << endl;
  1132 + std::cout << std::endl << "TEST ERROR: GFitsTableShortCol::real() - 10";
  1133 + std::cout << std::endl << " Reference sum: " << sum_sht10;
  1134 + std::cout << std::endl << " Derived sum: " << tot_dbl << std::endl;
1115 1135 throw;
1116 1136 }
1117   - cout << ".";
  1137 + std::cout << ".";
1118 1138  
1119 1139 // Check short table (int access)
1120 1140 tot_int = 0;
... ... @@ -1123,12 +1143,12 @@ void test_bintable_short(void)
1123 1143 tot_int += col_sht10.integer(i,j);
1124 1144 }
1125 1145 if (tot_int != sum_sht10_int) {
1126   - cout << endl << "TEST ERROR: GFitsTableShtCol::integer() - 10";
1127   - cout << endl << " Reference sum: " << sum_sht10_int;
1128   - cout << endl << " Derived sum: " << tot_int << endl;
  1146 + std::cout << std::endl << "TEST ERROR: GFitsTableShortCol::integer() - 10";
  1147 + std::cout << std::endl << " Reference sum: " << sum_sht10_int;
  1148 + std::cout << std::endl << " Derived sum: " << tot_int << std::endl;
1129 1149 throw;
1130 1150 }
1131   - cout << ".";
  1151 + std::cout << ".";
1132 1152  
1133 1153 // Check single precision table (string access)
1134 1154 tot_str.clear();
... ... @@ -1137,12 +1157,12 @@ void test_bintable_short(void)
1137 1157 tot_str += ":"+col_sht10.string(i,j);
1138 1158 }
1139 1159 if (tot_str != sum_sht10_str) {
1140   - cout << endl << "TEST ERROR: GFitsTableShtCol::string() - 10";
1141   - cout << endl << " Reference sum: " << sum_sht10_str;
1142   - cout << endl << " Derived sum: " << tot_str << endl;
  1160 + std::cout << std::endl << "TEST ERROR: GFitsTableShortCol::string() - 10";
  1161 + std::cout << std::endl << " Reference sum: " << sum_sht10_str;
  1162 + std::cout << std::endl << " Derived sum: " << tot_str << std::endl;
1143 1163 throw;
1144 1164 }
1145   - cout << ".";
  1165 + std::cout << ".";
1146 1166  
1147 1167 //
1148 1168 // ===== W R I T E T A B L E =====
... ... @@ -1159,15 +1179,15 @@ void test_bintable_short(void)
1159 1179  
1160 1180 // Save FITS file
1161 1181 fits.save();
1162   - cout << ".";
  1182 + std::cout << ".";
1163 1183  
1164 1184 }
1165   - catch (exception &e) {
1166   - cout << endl << "TEST ERROR: Unable to build tables." << endl;
1167   - cout << e.what() << endl;
  1185 + catch (std::exception &e) {
  1186 + std::cout << std::endl << "TEST ERROR: Unable to build tables." << std::endl;
  1187 + std::cout << e.what() << std::endl;
1168 1188 throw;
1169 1189 }
1170   - cout << ".";
  1190 + std::cout << ".";
1171 1191  
1172 1192  
1173 1193 //================================================================
... ... @@ -1198,64 +1218,64 @@ void test_bintable_short(void)
1198 1218 //
1199 1219  
1200 1220 // Get column
1201   - GFitsTableShtCol* col_sht =
1202   - (GFitsTableShtCol*)fits.hdu(1)->column("SHORT");
  1221 + GFitsTableShortCol* col_sht =
  1222 + (GFitsTableShortCol*)fits.hdu(1)->column("SHORT");
1203 1223  
1204 1224 // Check short table (operator access)
1205 1225 tot_sht = 0;
1206 1226 for (int i = 0; i < nrows; ++i)
1207 1227 tot_sht += (*col_sht)(i);
1208 1228 if (tot_sht != sum_sht) {
1209   - cout << endl << "TEST ERROR: GFitsTableShtCol::operator()";
1210   - cout << endl << " Reference sum: " << sum_sht;
1211   - cout << endl << " Derived sum: " << tot_sht << endl;
  1229 + std::cout << std::endl << "TEST ERROR: GFitsTableShortCol::operator()";
  1230 + std::cout << std::endl << " Reference sum: " << sum_sht;
  1231 + std::cout << std::endl << " Derived sum: " << tot_sht << std::endl;
1212 1232 throw;
1213 1233 }
1214   - cout << ".";
  1234 + std::cout << ".";
1215 1235  
1216 1236 // Check short table (real access)
1217 1237 tot_dbl = 0.0;
1218 1238 for (int i = 0; i < nrows; ++i)
1219 1239 tot_dbl += col_sht->real(i);
1220 1240 if (!dequal(tot_dbl, double(sum_sht))) {
1221   - cout << endl << "TEST ERROR: GFitsTableShtCol::real()";
1222   - cout << endl << " Reference sum: " << sum_sht;
1223   - cout << endl << " Derived sum: " << tot_dbl << endl;
  1241 + std::cout << std::endl << "TEST ERROR: GFitsTableShortCol::real()";
  1242 + std::cout << std::endl << " Reference sum: " << sum_sht;
  1243 + std::cout << std::endl << " Derived sum: " << tot_dbl << std::endl;
1224 1244 throw;
1225 1245 }
1226   - cout << ".";
  1246 + std::cout << ".";
1227 1247  
1228 1248 // Check short table (int access)
1229 1249 tot_int = 0;
1230 1250 for (int i = 0; i < nrows; ++i)
1231 1251 tot_int += col_sht->integer(i);
1232 1252 if (tot_int != sum_sht_int) {
1233   - cout << endl << "TEST ERROR: GFitsTableShtCol::integer()";
1234   - cout << endl << " Reference sum: " << sum_sht_int;
1235   - cout << endl << " Derived sum: " << tot_int << endl;
  1253 + std::cout << std::endl << "TEST ERROR: GFitsTableShortCol::integer()";
  1254 + std::cout << std::endl << " Reference sum: " << sum_sht_int;
  1255 + std::cout << std::endl << " Derived sum: " << tot_int << std::endl;
1236 1256 throw;
1237 1257 }
1238   - cout << ".";
  1258 + std::cout << ".";
1239 1259  
1240 1260 // Check single precision table (string access)
1241 1261 tot_str.clear();
1242 1262 for (int i = 0; i < nrows; ++i)
1243 1263 tot_str += ":"+col_sht->string(i);
1244 1264 if (tot_str != sum_sht_str) {
1245   - cout << endl << "TEST ERROR: GFitsTableShtCol::string()";
1246   - cout << endl << " Reference sum: " << sum_sht_str;
1247   - cout << endl << " Derived sum: " << tot_str << endl;
  1265 + std::cout << std::endl << "TEST ERROR: GFitsTableShortCol::string()";
  1266 + std::cout << std::endl << " Reference sum: " << sum_sht_str;
  1267 + std::cout << std::endl << " Derived sum: " << tot_str << std::endl;
1248 1268 throw;
1249 1269 }
1250   - cout << ".";
  1270 + std::cout << ".";
1251 1271  
1252 1272 //
1253 1273 // ===== S H O R T 1 0 =====
1254 1274 //
1255 1275  
1256 1276 // Get column
1257   - GFitsTableShtCol* col_sht10 =
1258   - (GFitsTableShtCol*)fits.hdu(1)->column("SHORT10");
  1277 + GFitsTableShortCol* col_sht10 =
  1278 + (GFitsTableShortCol*)fits.hdu(1)->column("SHORT10");
1259 1279  
1260 1280 // Check short table (operator access)
1261 1281 tot_sht = 0;
... ... @@ -1264,12 +1284,12 @@ void test_bintable_short(void)
1264 1284 tot_sht += (*col_sht10)(i,j);
1265 1285 }
1266 1286 if (tot_sht != sum_sht10) {
1267   - cout << endl << "TEST ERROR: GFitsTableShtCol::operator() - 10";
1268   - cout << endl << " Reference sum: " << sum_sht10;
1269   - cout << endl << " Derived sum: " << tot_sht << endl;
  1287 + std::cout << std::endl << "TEST ERROR: GFitsTableShortCol::operator() - 10";
  1288 + std::cout << std::endl << " Reference sum: " << sum_sht10;
  1289 + std::cout << std::endl << " Derived sum: " << tot_sht << std::endl;
1270 1290 throw;
1271 1291 }
1272   - cout << ".";
  1292 + std::cout << ".";
1273 1293  
1274 1294 // Check short table (real access)
1275 1295 tot_dbl = 0.0;
... ... @@ -1278,12 +1298,12 @@ void test_bintable_short(void)
1278 1298 tot_dbl += col_sht10->real(i,j);
1279 1299 }
1280 1300 if (!dequal(tot_dbl, sum_sht10)) {
1281   - cout << endl << "TEST ERROR: GFitsTableShtCol::real() - 10";
1282   - cout << endl << " Reference sum: " << sum_sht10;
1283   - cout << endl << " Derived sum: " << tot_dbl << endl;
  1301 + std::cout << std::endl << "TEST ERROR: GFitsTableShortCol::real() - 10";
  1302 + std::cout << std::endl << " Reference sum: " << sum_sht10;
  1303 + std::cout << std::endl << " Derived sum: " << tot_dbl << std::endl;
1284 1304 throw;
1285 1305 }
1286   - cout << ".";
  1306 + std::cout << ".";
1287 1307  
1288 1308 // Check short table (int access)
1289 1309 tot_int = 0;
... ... @@ -1292,12 +1312,12 @@ void test_bintable_short(void)
1292 1312 tot_int += col_sht10->integer(i,j);
1293 1313 }
1294 1314 if (tot_int != sum_sht10_int) {
1295   - cout << endl << "TEST ERROR: GFitsTableShtCol::integer() - 10";
1296   - cout << endl << " Reference sum: " << sum_sht10_int;
1297   - cout << endl << " Derived sum: " << tot_int << endl;
  1315 + std::cout << std::endl << "TEST ERROR: GFitsTableShortCol::integer() - 10";
  1316 + std::cout << std::endl << " Reference sum: " << sum_sht10_int;
  1317 + std::cout << std::endl << " Derived sum: " << tot_int << std::endl;
1298 1318 throw;
1299 1319 }
1300   - cout << ".";
  1320 + std::cout << ".";
1301 1321  
1302 1322 // Check single precision table (string access)
1303 1323 tot_str.clear();
... ... @@ -1306,19 +1326,19 @@ void test_bintable_short(void)
1306 1326 tot_str += ":"+col_sht10->string(i,j);
1307 1327 }
1308 1328 if (tot_str != sum_sht10_str) {
1309   - cout << endl << "TEST ERROR: GFitsTableShtCol::string() - 10";
1310   - cout << endl << " Reference sum: " << sum_sht10_str;
1311   - cout << endl << " Derived sum: " << tot_str << endl;
  1329 + std::cout << std::endl << "TEST ERROR: GFitsTableShortCol::string() - 10";
  1330 + std::cout << std::endl << " Reference sum: " << sum_sht10_str;
  1331 + std::cout << std::endl << " Derived sum: " << tot_str << std::endl;
1312 1332 throw;
1313 1333 }
1314   - cout << ".";
  1334 + std::cout << ".";
1315 1335 }
1316   - catch (exception &e) {
1317   - cout << endl << "TEST ERROR: Unable to build tables." << endl;
1318   - cout << e.what() << endl;
  1336 + catch (std::exception &e) {
  1337 + std::cout << std::endl << "TEST ERROR: Unable to build tables." << std::endl;
  1338 + std::cout << e.what() << std::endl;
1319 1339 throw;
1320 1340 }
1321   - cout << ". ok." << endl;
  1341 + std::cout << ". ok." << std::endl;
1322 1342  
1323 1343 }
1324 1344  
... ... @@ -1332,7 +1352,7 @@ void test_bintable_long(void)
1332 1352 std::string filename = "test_bintable_long.fits";
1333 1353  
1334 1354 // Dump header
1335   - cout << "Test GFitsTableLngCol: ";
  1355 + std::cout << "Test GFitsTableLongCol: ";
1336 1356  
1337 1357 // Remove FITS file
1338 1358 std::string cmd = "rm -rf "+ filename;
... ... @@ -1369,72 +1389,72 @@ void test_bintable_long(void)
1369 1389 //
1370 1390  
1371 1391 // Set long table
1372   - GFitsTableLngCol col_lng = GFitsTableLngCol("LONG", nrows);
  1392 + GFitsTableLongCol col_lng = GFitsTableLongCol("LONG", nrows);
1373 1393 for (int i = 0; i < nrows; ++i) {
1374 1394 long val_lng = long(100000.0 * cos(0.1*float(i)));
1375 1395 col_lng(i) = val_lng;
1376 1396 sum_lng += val_lng;
1377 1397 sum_lng_int += int(val_lng);
1378   - ostringstream s_value;
  1398 + std::ostringstream s_value;
1379 1399 s_value << val_lng;
1380 1400 sum_lng_str += ":"+s_value.str();
1381 1401 }
1382   - cout << ".";
  1402 + std::cout << ".";
1383 1403  
1384 1404 // Check long table (operator access)
1385 1405 tot_lng = 0;
1386 1406 for (int i = 0; i < nrows; ++i)
1387 1407 tot_lng += col_lng(i);
1388 1408 if (tot_lng != sum_lng) {
1389   - cout << endl << "TEST ERROR: GFitsTableLngCol::operator()";
1390   - cout << endl << " Reference sum: " << sum_lng;
1391   - cout << endl << " Derived sum: " << tot_lng << endl;
  1409 + std::cout << std::endl << "TEST ERROR: GFitsTableLongCol::operator()";
  1410 + std::cout << std::endl << " Reference sum: " << sum_lng;
  1411 + std::cout << std::endl << " Derived sum: " << tot_lng << std::endl;
1392 1412 throw;
1393 1413 }
1394   - cout << ".";
  1414 + std::cout << ".";
1395 1415  
1396 1416 // Check long table (real access)
1397 1417 tot_dbl = 0.0;
1398 1418 for (int i = 0; i < nrows; ++i)
1399 1419 tot_dbl += col_lng.real(i);
1400 1420 if (!dequal(tot_dbl, double(sum_lng))) {
1401   - cout << endl << "TEST ERROR: GFitsTableLngCol::real()";
1402   - cout << endl << " Reference sum: " << sum_lng;
1403   - cout << endl << " Derived sum: " << tot_dbl << endl;
  1421 + std::cout << std::endl << "TEST ERROR: GFitsTableLongCol::real()";
  1422 + std::cout << std::endl << " Reference sum: " << sum_lng;
  1423 + std::cout << std::endl << " Derived sum: " << tot_dbl << std::endl;
1404 1424 throw;
1405 1425 }
1406   - cout << ".";
  1426 + std::cout << ".";
1407 1427  
1408 1428 // Check long table (int access)
1409 1429 tot_int = 0;
1410 1430 for (int i = 0; i < nrows; ++i)
1411 1431 tot_int += col_lng.integer(i);
1412 1432 if (tot_int != sum_lng_int) {
1413   - cout << endl << "TEST ERROR: GFitsTableLngCol::integer()";
1414   - cout << endl << " Reference sum: " << sum_lng_int;
1415   - cout << endl << " Derived sum: " << tot_int << endl;
  1433 + std::cout << std::endl << "TEST ERROR: GFitsTableLongCol::integer()";
  1434 + std::cout << std::endl << " Reference sum: " << sum_lng_int;
  1435 + std::cout << std::endl << " Derived sum: " << tot_int << std::endl;
1416 1436 throw;
1417 1437 }
1418   - cout << ".";
  1438 + std::cout << ".";
1419 1439  
1420 1440 // Check long table (string access)
1421 1441 tot_str.clear();
1422 1442 for (int i = 0; i < nrows; ++i)
1423 1443 tot_str += ":"+col_lng.string(i);
1424 1444 if (tot_str != sum_lng_str) {
1425   - cout << endl << "TEST ERROR: GFitsTableLngCol::string()";
1426   - cout << endl << " Reference sum: " << sum_lng_str;
1427   - cout << endl << " Derived sum: " << tot_str << endl;
  1445 + std::cout << std::endl << "TEST ERROR: GFitsTableLongCol::string()";
  1446 + std::cout << std::endl << " Reference sum: " << sum_lng_str;
  1447 + std::cout << std::endl << " Derived sum: " << tot_str << std::endl;
1428 1448 throw;
1429 1449 }
1430   - cout << ".";
  1450 + std::cout << ".";
1431 1451  
1432 1452 //
1433 1453 // ===== L O N G 1 0 =====
1434 1454 //
1435 1455  
1436 1456 // Set long table
1437   - GFitsTableLngCol col_lng10 = GFitsTableLngCol("LONG10", nrows, nvec);
  1457 + GFitsTableLongCol col_lng10 = GFitsTableLongCol("LONG10", nrows, nvec);
1438 1458 for (int i = 0; i < nrows; ++i) {
1439 1459 for (int j = 0; j < nvec; ++j) {
1440 1460 long val_lng = long(1000.0*cos(0.1*float(i))*
... ... @@ -1442,12 +1462,12 @@ void test_bintable_long(void)
1442 1462 col_lng10(i,j) = val_lng;
1443 1463 sum_lng10 += val_lng;
1444 1464 sum_lng10_int += int(val_lng);
1445   - ostringstream s_value;
  1465 + std::ostringstream s_value;
1446 1466 s_value << val_lng;
1447 1467 sum_lng10_str += ":"+s_value.str();
1448 1468 }
1449 1469 }
1450   - cout << ".";
  1470 + std::cout << ".";
1451 1471  
1452 1472 // Check long table (operator access)
1453 1473 tot_lng = 0;
... ... @@ -1456,12 +1476,12 @@ void test_bintable_long(void)
1456 1476 tot_lng += col_lng10(i,j);
1457 1477 }
1458 1478 if (tot_lng != sum_lng10) {
1459   - cout << endl << "TEST ERROR: GFitsTableLngCol::operator() - 10";
1460   - cout << endl << " Reference sum: " << sum_lng10;
1461   - cout << endl << " Derived sum: " << tot_lng << endl;
  1479 + std::cout << std::endl << "TEST ERROR: GFitsTableLongCol::operator() - 10";
  1480 + std::cout << std::endl << " Reference sum: " << sum_lng10;
  1481 + std::cout << std::endl << " Derived sum: " << tot_lng << std::endl;
1462 1482 throw;
1463 1483 }
1464   - cout << ".";
  1484 + std::cout << ".";
1465 1485  
1466 1486 // Check long table (real access)
1467 1487 tot_dbl = 0.0;
... ... @@ -1470,12 +1490,12 @@ void test_bintable_long(void)
1470 1490 tot_dbl += col_lng10.real(i,j);
1471 1491 }
1472 1492 if (!dequal(tot_dbl, sum_lng10)) {
1473   - cout << endl << "TEST ERROR: GFitsTableLngCol::real() - 10";
1474   - cout << endl << " Reference sum: " << sum_lng10;
1475   - cout << endl << " Derived sum: " << tot_dbl << endl;
  1493 + std::cout << std::endl << "TEST ERROR: GFitsTableLongCol::real() - 10";
  1494 + std::cout << std::endl << " Reference sum: " << sum_lng10;
  1495 + std::cout << std::endl << " Derived sum: " << tot_dbl << std::endl;
1476 1496 throw;
1477 1497 }
1478   - cout << ".";
  1498 + std::cout << ".";
1479 1499  
1480 1500 // Check long table (int access)
1481 1501 tot_int = 0;
... ... @@ -1484,12 +1504,12 @@ void test_bintable_long(void)
1484 1504 tot_int += col_lng10.integer(i,j);
1485 1505 }
1486 1506 if (tot_int != sum_lng10_int) {
1487   - cout << endl << "TEST ERROR: GFitsTableLngCol::integer() - 10";
1488   - cout << endl << " Reference sum: " << sum_lng10_int;
1489   - cout << endl << " Derived sum: " << tot_int << endl;
  1507 + std::cout << std::endl << "TEST ERROR: GFitsTableLongCol::integer() - 10";
  1508 + std::cout << std::endl << " Reference sum: " << sum_lng10_int;
  1509 + std::cout << std::endl << " Derived sum: " << tot_int << std::endl;
1490 1510 throw;
1491 1511 }
1492   - cout << ".";
  1512 + std::cout << ".";
1493 1513  
1494 1514 // Check single precision table (string access)
1495 1515 tot_str.clear();
... ... @@ -1498,12 +1518,12 @@ void test_bintable_long(void)
1498 1518 tot_str += ":"+col_lng10.string(i,j);
1499 1519 }
1500 1520 if (tot_str != sum_lng10_str) {
1501   - cout << endl << "TEST ERROR: GFitsTableLngCol::string() - 10";
1502   - cout << endl << " Reference sum: " << sum_lng10_str;
1503   - cout << endl << " Derived sum: " << tot_str << endl;
  1521 + std::cout << std::endl << "TEST ERROR: GFitsTableLongCol::string() - 10";
  1522 + std::cout << std::endl << " Reference sum: " << sum_lng10_str;
  1523 + std::cout << std::endl << " Derived sum: " << tot_str << std::endl;
1504 1524 throw;
1505 1525 }
1506   - cout << ".";
  1526 + std::cout << ".";
1507 1527  
1508 1528 //
1509 1529 // ===== W R I T E T A B L E =====
... ... @@ -1520,14 +1540,14 @@ void test_bintable_long(void)
1520 1540  
1521 1541 // Save FITS file
1522 1542 fits.save();
1523   - cout << ".";
  1543 + std::cout << ".";
1524 1544 }
1525   - catch (exception &e) {
1526   - cout << endl << "TEST ERROR: Unable to build tables." << endl;
1527   - cout << e.what() << endl;
  1545 + catch (std::exception &e) {
  1546 + std::cout << std::endl << "TEST ERROR: Unable to build tables." << std::endl;
  1547 + std::cout << e.what() << std::endl;
1528 1548 throw;
1529 1549 }
1530   - cout << ".";
  1550 + std::cout << ".";
1531 1551  
1532 1552  
1533 1553 //================================================================
... ... @@ -1558,64 +1578,64 @@ void test_bintable_long(void)
1558 1578 //
1559 1579  
1560 1580 // Get column
1561   - GFitsTableLngCol* col_lng =
1562   - (GFitsTableLngCol*)fits.hdu(1)->column("LONG");
  1581 + GFitsTableLongCol* col_lng =
  1582 + (GFitsTableLongCol*)fits.hdu(1)->column("LONG");
1563 1583  
1564 1584 // Check long table (operator access)
1565 1585 tot_lng = 0;
1566 1586 for (int i = 0; i < nrows; ++i)
1567 1587 tot_lng += (*col_lng)(i);
1568 1588 if (tot_lng != sum_lng) {
1569   - cout << endl << "TEST ERROR: GFitsTableLngCol::operator()";
1570   - cout << endl << " Reference sum: " << sum_lng;
1571   - cout << endl << " Derived sum: " << tot_lng << endl;
  1589 + std::cout << std::endl << "TEST ERROR: GFitsTableLongCol::operator()";
  1590 + std::cout << std::endl << " Reference sum: " << sum_lng;
  1591 + std::cout << std::endl << " Derived sum: " << tot_lng << std::endl;
1572 1592 throw;
1573 1593 }
1574   - cout << ".";
  1594 + std::cout << ".";
1575 1595  
1576 1596 // Check long table (real access)
1577 1597 tot_dbl = 0.0;
1578 1598 for (int i = 0; i < nrows; ++i)
1579 1599 tot_dbl += col_lng->real(i);
1580 1600 if (!dequal(tot_dbl, double(sum_lng))) {
1581   - cout << endl << "TEST ERROR: GFitsTableLngCol::real()";
1582   - cout << endl << " Reference sum: " << sum_lng;
1583   - cout << endl << " Derived sum: " << tot_dbl << endl;
  1601 + std::cout << std::endl << "TEST ERROR: GFitsTableLongCol::real()";
  1602 + std::cout << std::endl << " Reference sum: " << sum_lng;
  1603 + std::cout << std::endl << " Derived sum: " << tot_dbl << std::endl;
1584 1604 throw;
1585 1605 }
1586   - cout << ".";
  1606 + std::cout << ".";
1587 1607  
1588 1608 // Check long table (int access)
1589 1609 tot_int = 0;
1590 1610 for (int i = 0; i < nrows; ++i)
1591 1611 tot_int += col_lng->integer(i);
1592 1612 if (tot_int != sum_lng_int) {
1593   - cout << endl << "TEST ERROR: GFitsTableLngCol::integer()";
1594   - cout << endl << " Reference sum: " << sum_lng_int;
1595   - cout << endl << " Derived sum: " << tot_int << endl;
  1613 + std::cout << std::endl << "TEST ERROR: GFitsTableLongCol::integer()";
  1614 + std::cout << std::endl << " Reference sum: " << sum_lng_int;
  1615 + std::cout << std::endl << " Derived sum: " << tot_int << std::endl;
1596 1616 throw;
1597 1617 }
1598   - cout << ".";
  1618 + std::cout << ".";
1599 1619  
1600 1620 // Check long table (string access)
1601 1621 tot_str.clear();
1602 1622 for (int i = 0; i < nrows; ++i)
1603 1623 tot_str += ":"+col_lng->string(i);
1604 1624 if (tot_str != sum_lng_str) {
1605   - cout << endl << "TEST ERROR: GFitsTableLngCol::string()";
1606   - cout << endl << " Reference sum: " << sum_lng_str;
1607   - cout << endl << " Derived sum: " << tot_str << endl;
  1625 + std::cout << std::endl << "TEST ERROR: GFitsTableLongCol::string()";
  1626 + std::cout << std::endl << " Reference sum: " << sum_lng_str;
  1627 + std::cout << std::endl << " Derived sum: " << tot_str << std::endl;
1608 1628 throw;
1609 1629 }
1610   - cout << ".";
  1630 + std::cout << ".";
1611 1631  
1612 1632 //
1613 1633 // ===== L O N G 1 0 =====
1614 1634 //
1615 1635  
1616 1636 // Get column
1617   - GFitsTableLngCol* col_lng10 =
1618   - (GFitsTableLngCol*)fits.hdu(1)->column("LONG10");
  1637 + GFitsTableLongCol* col_lng10 =
  1638 + (GFitsTableLongCol*)fits.hdu(1)->column("LONG10");
1619 1639  
1620 1640 // Check long table (operator access)
1621 1641 tot_lng = 0;
... ... @@ -1624,12 +1644,12 @@ void test_bintable_long(void)
1624 1644 tot_lng += (*col_lng10)(i,j);
1625 1645 }
1626 1646 if (tot_lng != sum_lng10) {
1627   - cout << endl << "TEST ERROR: GFitsTableLngCol::operator() - 10";
1628   - cout << endl << " Reference sum: " << sum_lng10;
1629   - cout << endl << " Derived sum: " << tot_lng << endl;
  1647 + std::cout << std::endl << "TEST ERROR: GFitsTableLongCol::operator() - 10";
  1648 + std::cout << std::endl << " Reference sum: " << sum_lng10;
  1649 + std::cout << std::endl << " Derived sum: " << tot_lng << std::endl;
1630 1650 throw;
1631 1651 }
1632   - cout << ".";
  1652 + std::cout << ".";
1633 1653  
1634 1654 // Check long table (real access)
1635 1655 tot_dbl = 0.0;
... ... @@ -1638,12 +1658,12 @@ void test_bintable_long(void)
1638 1658 tot_dbl += col_lng10->real(i,j);
1639 1659 }
1640 1660 if (!dequal(tot_dbl, sum_lng10)) {
1641   - cout << endl << "TEST ERROR: GFitsTableLngCol::real() - 10";
1642   - cout << endl << " Reference sum: " << sum_lng10;
1643   - cout << endl << " Derived sum: " << tot_dbl << endl;
  1661 + std::cout << std::endl << "TEST ERROR: GFitsTableLongCol::real() - 10";
  1662 + std::cout << std::endl << " Reference sum: " << sum_lng10;
  1663 + std::cout << std::endl << " Derived sum: " << tot_dbl << std::endl;
1644 1664 throw;
1645 1665 }
1646   - cout << ".";
  1666 + std::cout << ".";
1647 1667  
1648 1668 // Check long table (int access)
1649 1669 tot_int = 0;
... ... @@ -1652,12 +1672,12 @@ void test_bintable_long(void)
1652 1672 tot_int += col_lng10->integer(i,j);
1653 1673 }
1654 1674 if (tot_int != sum_lng10_int) {
1655   - cout << endl << "TEST ERROR: GFitsTableLngCol::integer() - 10";
1656   - cout << endl << " Reference sum: " << sum_lng10_int;
1657   - cout << endl << " Derived sum: " << tot_int << endl;
  1675 + std::cout << std::endl << "TEST ERROR: GFitsTableLongCol::integer() - 10";
  1676 + std::cout << std::endl << " Reference sum: " << sum_lng10_int;
  1677 + std::cout << std::endl << " Derived sum: " << tot_int << std::endl;
1658 1678 throw;
1659 1679 }
1660   - cout << ".";
  1680 + std::cout << ".";
1661 1681  
1662 1682 // Check single precision table (string access)
1663 1683 tot_str.clear();
... ... @@ -1666,19 +1686,19 @@ void test_bintable_long(void)
1666 1686 tot_str += ":"+col_lng10->string(i,j);
1667 1687 }
1668 1688 if (tot_str != sum_lng10_str) {
1669   - cout << endl << "TEST ERROR: GFitsTableLngCol::string() - 10";
1670   - cout << endl << " Reference sum: " << sum_lng10_str;
1671   - cout << endl << " Derived sum: " << tot_str << endl;
  1689 + std::cout << std::endl << "TEST ERROR: GFitsTableLongCol::string() - 10";
  1690 + std::cout << std::endl << " Reference sum: " << sum_lng10_str;
  1691 + std::cout << std::endl << " Derived sum: " << tot_str << std::endl;
1672 1692 throw;
1673 1693 }
1674   - cout << ".";
  1694 + std::cout << ".";
1675 1695 }
1676   - catch (exception &e) {
1677   - cout << endl << "TEST ERROR: Unable to build tables." << endl;
1678   - cout << e.what() << endl;
  1696 + catch (std::exception &e) {
  1697 + std::cout << std::endl << "TEST ERROR: Unable to build tables." << std::endl;
  1698 + std::cout << e.what() << std::endl;
1679 1699 throw;
1680 1700 }
1681   - cout << ". ok." << endl;
  1701 + std::cout << ". ok." << std::endl;
1682 1702  
1683 1703 }
1684 1704  
... ... @@ -1692,7 +1712,7 @@ void test_bintable_string(void)
1692 1712 std::string filename = "test_bintable_string.fits";
1693 1713  
1694 1714 // Dump header
1695   - cout << "Test GFitsTableStrCol: ";
  1715 + std::cout << "Test GFitsTableStringCol: ";
1696 1716  
1697 1717 // Remove FITS file
1698 1718 std::string cmd = "rm -rf "+ filename;
... ... @@ -1729,84 +1749,84 @@ void test_bintable_string(void)
1729 1749 //
1730 1750  
1731 1751 // Set string table
1732   - GFitsTableStrCol col_str = GFitsTableStrCol("STRING", nrows, 20);
  1752 + GFitsTableStringCol col_str = GFitsTableStringCol("STRING", nrows, 20);
1733 1753 for (int i = 0; i < nrows; ++i) {
1734 1754 double val_dbl = 100.0 * cos(0.1*double(i));
1735   - ostringstream s_value;
1736   - s_value << scientific << val_dbl;
  1755 + std::ostringstream s_value;
  1756 + s_value << std::scientific << val_dbl;
1737 1757 col_str(i) = s_value.str();
1738 1758 sum_str += ":" + s_value.str();
1739 1759 sum_str_dbl += val_dbl;
1740 1760 sum_str_int += int(val_dbl);
1741 1761 }
1742   - cout << ".";
  1762 + std::cout << ".";
1743 1763  
1744 1764 // Check string table (operator access)
1745 1765 tot_str.clear();
1746 1766 for (int i = 0; i < nrows; ++i)
1747 1767 tot_str += ":" + col_str(i);
1748 1768 if (tot_str != sum_str) {
1749   - cout << endl << "TEST ERROR: GFitsTableStrCol::operator()";
1750   - cout << endl << " Reference sum: " << sum_str;
1751   - cout << endl << " Derived sum: " << tot_str << endl;
  1769 + std::cout << std::endl << "TEST ERROR: GFitsTableStringCol::operator()";
  1770 + std::cout << std::endl << " Reference sum: " << sum_str;
  1771 + std::cout << std::endl << " Derived sum: " << tot_str << std::endl;
1752 1772 throw;
1753 1773 }
1754   - cout << ".";
  1774 + std::cout << ".";
1755 1775  
1756 1776 // Check string table (real access)
1757 1777 tot_dbl = 0.0;
1758 1778 for (int i = 0; i < nrows; ++i)
1759 1779 tot_dbl += col_str.real(i);
1760 1780 if (!equal(tot_dbl, sum_str_dbl, 1.0e-4)) {
1761   - cout << endl << "TEST ERROR: GFitsTableStrCol::real()";
1762   - cout << endl << " Reference sum: " << sum_str_dbl;
1763   - cout << endl << " Derived sum: " << tot_dbl << endl;
  1781 + std::cout << std::endl << "TEST ERROR: GFitsTableStringCol::real()";
  1782 + std::cout << std::endl << " Reference sum: " << sum_str_dbl;
  1783 + std::cout << std::endl << " Derived sum: " << tot_dbl << std::endl;
1764 1784 throw;
1765 1785 }
1766   - cout << ".";
  1786 + std::cout << ".";
1767 1787  
1768 1788 // Check string table (int access)
1769 1789 tot_int = 0;
1770 1790 for (int i = 0; i < nrows; ++i)
1771 1791 tot_int += col_str.integer(i);
1772 1792 if (tot_int != sum_str_int) {
1773   - cout << endl << "TEST ERROR: GFitsTableStrCol::integer()";
1774   - cout << endl << " Reference sum: " << sum_str_int;
1775   - cout << endl << " Derived sum: " << tot_int << endl;
  1793 + std::cout << std::endl << "TEST ERROR: GFitsTableStringCol::integer()";
  1794 + std::cout << std::endl << " Reference sum: " << sum_str_int;
  1795 + std::cout << std::endl << " Derived sum: " << tot_int << std::endl;
1776 1796 throw;
1777 1797 }
1778   - cout << ".";
  1798 + std::cout << ".";
1779 1799  
1780 1800 // Check string table (string access)
1781 1801 tot_str.clear();
1782 1802 for (int i = 0; i < nrows; ++i)
1783 1803 tot_str += ":"+col_str.string(i);
1784 1804 if (tot_str != sum_str) {
1785   - cout << endl << "TEST ERROR: GFitsTableStrCol::string()";
1786   - cout << endl << " Reference sum: " << sum_str;
1787   - cout << endl << " Derived sum: " << tot_str << endl;
  1805 + std::cout << std::endl << "TEST ERROR: GFitsTableStringCol::string()";
  1806 + std::cout << std::endl << " Reference sum: " << sum_str;
  1807 + std::cout << std::endl << " Derived sum: " << tot_str << std::endl;
1788 1808 throw;
1789 1809 }
1790   - cout << ".";
  1810 + std::cout << ".";
1791 1811  
1792 1812 //
1793 1813 // ===== S T R I N G 1 0 =====
1794 1814 //
1795 1815  
1796 1816 // Set string table
1797   - GFitsTableStrCol col_str10 = GFitsTableStrCol("STRING10", nrows, 20, nvec);
  1817 + GFitsTableStringCol col_str10 = GFitsTableStringCol("STRING10", nrows, 20, nvec);
1798 1818 for (int i = 0; i < nrows; ++i) {
1799 1819 for (int j = 0; j < nvec; ++j) {
1800 1820 double val_dbl = 100.0 * cos(0.1*double(i)) * cos(0.3*double(j));
1801   - ostringstream s_value;
1802   - s_value << scientific << val_dbl;
  1821 + std::ostringstream s_value;
  1822 + s_value << std::scientific << val_dbl;
1803 1823 col_str10(i,j) = s_value.str();
1804 1824 sum_str10 += ":" + s_value.str();
1805 1825 sum_str10_dbl += val_dbl;
1806 1826 sum_str10_int += int(val_dbl);
1807 1827 }
1808 1828 }
1809   - cout << ".";
  1829 + std::cout << ".";
1810 1830  
1811 1831 // Check string table (operator access)
1812 1832 tot_str.clear();
... ... @@ -1815,12 +1835,12 @@ void test_bintable_string(void)
1815 1835 tot_str += ":" + col_str10(i,j);
1816 1836 }
1817 1837 if (tot_str != sum_str10) {
1818   - cout << endl << "TEST ERROR: GFitsTableStrCol::operator() - 10";
1819   - cout << endl << " Reference sum: " << sum_str10;
1820   - cout << endl << " Derived sum: " << tot_str << endl;
  1838 + std::cout << std::endl << "TEST ERROR: GFitsTableStringCol::operator() - 10";
  1839 + std::cout << std::endl << " Reference sum: " << sum_str10;
  1840 + std::cout << std::endl << " Derived sum: " << tot_str << std::endl;
1821 1841 throw;
1822 1842 }
1823   - cout << ".";
  1843 + std::cout << ".";
1824 1844  
1825 1845 // Check string table (real access)
1826 1846 tot_dbl = 0.0;
... ... @@ -1829,12 +1849,12 @@ void test_bintable_string(void)
1829 1849 tot_dbl += col_str10.real(i,j);
1830 1850 }
1831 1851 if (!equal(tot_dbl, sum_str10_dbl, 1.0e-4)) {
1832   - cout << endl << "TEST ERROR: GFitsTableStrCol::real() - 10";
1833   - cout << endl << " Reference sum: " << sum_str10_dbl;
1834   - cout << endl << " Derived sum: " << tot_dbl << endl;
  1852 + std::cout << std::endl << "TEST ERROR: GFitsTableStringCol::real() - 10";
  1853 + std::cout << std::endl << " Reference sum: " << sum_str10_dbl;
  1854 + std::cout << std::endl << " Derived sum: " << tot_dbl << std::endl;
1835 1855 throw;
1836 1856 }
1837   - cout << ".";
  1857 + std::cout << ".";
1838 1858  
1839 1859 // Check string table (int access)
1840 1860 tot_int = 0;
... ... @@ -1843,12 +1863,12 @@ void test_bintable_string(void)
1843 1863 tot_int += col_str10.integer(i,j);
1844 1864 }
1845 1865 if (tot_int != sum_str10_int) {
1846   - cout << endl << "TEST ERROR: GFitsTableStrCol::integer() - 10";
1847   - cout << endl << " Reference sum: " << sum_str10_int;
1848   - cout << endl << " Derived sum: " << tot_int << endl;
  1866 + std::cout << std::endl << "TEST ERROR: GFitsTableStringCol::integer() - 10";
  1867 + std::cout << std::endl << " Reference sum: " << sum_str10_int;
  1868 + std::cout << std::endl << " Derived sum: " << tot_int << std::endl;
1849 1869 throw;
1850 1870 }
1851   - cout << ".";
  1871 + std::cout << ".";
1852 1872  
1853 1873 // Check string table (string access)
1854 1874 tot_str.clear();
... ... @@ -1857,12 +1877,12 @@ void test_bintable_string(void)
1857 1877 tot_str += ":"+col_str10.string(i,j);
1858 1878 }
1859 1879 if (tot_str != sum_str10) {
1860   - cout << endl << "TEST ERROR: GFitsTableStrCol::string() - 10";
1861   - cout << endl << " Reference sum: " << sum_str10;
1862   - cout << endl << " Derived sum: " << tot_str << endl;
  1880 + std::cout << std::endl << "TEST ERROR: GFitsTableStringCol::string() - 10";
  1881 + std::cout << std::endl << " Reference sum: " << sum_str10;
  1882 + std::cout << std::endl << " Derived sum: " << tot_str << std::endl;
1863 1883 throw;
1864 1884 }
1865   - cout << ".";
  1885 + std::cout << ".";
1866 1886  
1867 1887 //
1868 1888 // ===== W R I T E T A B L E =====
... ... @@ -1879,14 +1899,14 @@ void test_bintable_string(void)
1879 1899  
1880 1900 // Save FITS file
1881 1901 fits.save();
1882   - cout << ".";
  1902 + std::cout << ".";
1883 1903 }
1884   - catch (exception &e) {
1885   - cout << endl << "TEST ERROR: Unable to build tables." << endl;
1886   - cout << e.what() << endl;
  1904 + catch (std::exception &e) {
  1905 + std::cout << std::endl << "TEST ERROR: Unable to build tables." << std::endl;
  1906 + std::cout << e.what() << std::endl;
1887 1907 throw;
1888 1908 }
1889   - cout << ".";
  1909 + std::cout << ".";
1890 1910  
1891 1911  
1892 1912 //================================================================
... ... @@ -1916,64 +1936,64 @@ void test_bintable_string(void)
1916 1936 //
1917 1937  
1918 1938 // Get column
1919   - GFitsTableStrCol* col_str =
1920   - (GFitsTableStrCol*)fits.hdu(1)->column("STRING");
  1939 + GFitsTableStringCol* col_str =
  1940 + (GFitsTableStringCol*)fits.hdu(1)->column("STRING");
1921 1941  
1922 1942 // Check string table (operator access)
1923 1943 tot_str.clear();
1924 1944 for (int i = 0; i < nrows; ++i)
1925 1945 tot_str += ":" + (*col_str)(i);
1926 1946 if (tot_str != sum_str) {
1927   - cout << endl << "TEST ERROR: GFitsTableStrCol::operator()";
1928   - cout << endl << " Reference sum: " << sum_str;
1929   - cout << endl << " Derived sum: " << tot_str << endl;
  1947 + std::cout << std::endl << "TEST ERROR: GFitsTableStringCol::operator()";
  1948 + std::cout << std::endl << " Reference sum: " << sum_str;
  1949 + std::cout << std::endl << " Derived sum: " << tot_str << std::endl;
1930 1950 throw;
1931 1951 }
1932   - cout << ".";
  1952 + std::cout << ".";
1933 1953  
1934 1954 // Check string table (real access)
1935 1955 tot_dbl = 0.0;
1936 1956 for (int i = 0; i < nrows; ++i)
1937 1957 tot_dbl += col_str->real(i);
1938 1958 if (!equal(tot_dbl, sum_str_dbl, 1.0e-4)) {
1939   - cout << endl << "TEST ERROR: GFitsTableStrCol::real()";
1940   - cout << endl << " Reference sum: " << sum_str_dbl;
1941   - cout << endl << " Derived sum: " << tot_dbl << endl;
  1959 + std::cout << std::endl << "TEST ERROR: GFitsTableStringCol::real()";
  1960 + std::cout << std::endl << " Reference sum: " << sum_str_dbl;
  1961 + std::cout << std::endl << " Derived sum: " << tot_dbl << std::endl;
1942 1962 throw;
1943 1963 }
1944   - cout << ".";
  1964 + std::cout << ".";
1945 1965  
1946 1966 // Check string table (int access)
1947 1967 tot_int = 0;
1948 1968 for (int i = 0; i < nrows; ++i)
1949 1969 tot_int += col_str->integer(i);
1950 1970 if (tot_int != sum_str_int) {
1951   - cout << endl << "TEST ERROR: GFitsTableStrCol::integer()";
1952   - cout << endl << " Reference sum: " << sum_str_int;
1953   - cout << endl << " Derived sum: " << tot_int << endl;
  1971 + std::cout << std::endl << "TEST ERROR: GFitsTableStringCol::integer()";
  1972 + std::cout << std::endl << " Reference sum: " << sum_str_int;
  1973 + std::cout << std::endl << " Derived sum: " << tot_int << std::endl;
1954 1974 throw;
1955 1975 }
1956   - cout << ".";
  1976 + std::cout << ".";
1957 1977  
1958 1978 // Check string table (string access)
1959 1979 tot_str.clear();
1960 1980 for (int i = 0; i < nrows; ++i)
1961 1981 tot_str += ":"+col_str->string(i);
1962 1982 if (tot_str != sum_str) {
1963   - cout << endl << "TEST ERROR: GFitsTableStrCol::string()";
1964   - cout << endl << " Reference sum: " << sum_str;
1965   - cout << endl << " Derived sum: " << tot_str << endl;
  1983 + std::cout << std::endl << "TEST ERROR: GFitsTableStringCol::string()";
  1984 + std::cout << std::endl << " Reference sum: " << sum_str;
  1985 + std::cout << std::endl << " Derived sum: " << tot_str << std::endl;
1966 1986 throw;
1967 1987 }
1968   - cout << ".";
  1988 + std::cout << ".";
1969 1989  
1970 1990 //
1971 1991 // ===== S T R I N G 1 0 =====
1972 1992 //
1973 1993  
1974 1994 // Get column
1975   - GFitsTableStrCol* col_str10 =
1976   - (GFitsTableStrCol*)fits.hdu(1)->column("STRING10");
  1995 + GFitsTableStringCol* col_str10 =
  1996 + (GFitsTableStringCol*)fits.hdu(1)->column("STRING10");
1977 1997  
1978 1998 // Check string table (operator access)
1979 1999 tot_str.clear();
... ... @@ -1982,12 +2002,12 @@ void test_bintable_string(void)
1982 2002 tot_str += ":" + (*col_str10)(i,j);
1983 2003 }
1984 2004 if (tot_str != sum_str10) {
1985   - cout << endl << "TEST ERROR: GFitsTableStrCol::operator() - 10";
1986   - cout << endl << " Reference sum: " << sum_str10;
1987   - cout << endl << " Derived sum: " << tot_str << endl;
  2005 + std::cout << std::endl << "TEST ERROR: GFitsTableStringCol::operator() - 10";
  2006 + std::cout << std::endl << " Reference sum: " << sum_str10;
  2007 + std::cout << std::endl << " Derived sum: " << tot_str << std::endl;
1988 2008 throw;
1989 2009 }
1990   - cout << ".";
  2010 + std::cout << ".";
1991 2011  
1992 2012 // Check string table (real access)
1993 2013 tot_dbl = 0.0;
... ... @@ -1996,12 +2016,12 @@ void test_bintable_string(void)
1996 2016 tot_dbl += col_str10->real(i,j);
1997 2017 }
1998 2018 if (!equal(tot_dbl, sum_str10_dbl, 1.0e-4)) {
1999   - cout << endl << "TEST ERROR: GFitsTableStrCol::real() - 10";
2000   - cout << endl << " Reference sum: " << sum_str10_dbl;
2001   - cout << endl << " Derived sum: " << tot_dbl << endl;
  2019 + std::cout << std::endl << "TEST ERROR: GFitsTableStringCol::real() - 10";
  2020 + std::cout << std::endl << " Reference sum: " << sum_str10_dbl;
  2021 + std::cout << std::endl << " Derived sum: " << tot_dbl << std::endl;
2002 2022 throw;
2003 2023 }
2004   - cout << ".";
  2024 + std::cout << ".";
2005 2025  
2006 2026 // Check string table (int access)
2007 2027 tot_int = 0;
... ... @@ -2010,12 +2030,12 @@ void test_bintable_string(void)
2010 2030 tot_int += col_str10->integer(i,j);
2011 2031 }
2012 2032 if (tot_int != sum_str10_int) {
2013   - cout << endl << "TEST ERROR: GFitsTableStrCol::integer() - 10";
2014   - cout << endl << " Reference sum: " << sum_str10_int;
2015   - cout << endl << " Derived sum: " << tot_int << endl;
  2033 + std::cout << std::endl << "TEST ERROR: GFitsTableStringCol::integer() - 10";
  2034 + std::cout << std::endl << " Reference sum: " << sum_str10_int;
  2035 + std::cout << std::endl << " Derived sum: " << tot_int << std::endl;
2016 2036 throw;
2017 2037 }
2018   - cout << ".";
  2038 + std::cout << ".";
2019 2039  
2020 2040 // Check string table (string access)
2021 2041 tot_str.clear();
... ... @@ -2024,20 +2044,20 @@ void test_bintable_string(void)
2024 2044 tot_str += ":"+col_str10->string(i,j);
2025 2045 }
2026 2046 if (tot_str != sum_str10) {
2027   - cout << endl << "TEST ERROR: GFitsTableStrCol::string() - 10";
2028   - cout << endl << " Reference sum: " << sum_str10;
2029   - cout << endl << " Derived sum: " << tot_str << endl;
  2047 + std::cout << std::endl << "TEST ERROR: GFitsTableStringCol::string() - 10";
  2048 + std::cout << std::endl << " Reference sum: " << sum_str10;
  2049 + std::cout << std::endl << " Derived sum: " << tot_str << std::endl;
2030 2050 throw;
2031 2051 }
2032   - cout << ".";
  2052 + std::cout << ".";
2033 2053  
2034 2054 }
2035   - catch (exception &e) {
2036   - cout << endl << "TEST ERROR: Unable to read tables." << endl;
2037   - cout << e.what() << endl;
  2055 + catch (std::exception &e) {
  2056 + std::cout << std::endl << "TEST ERROR: Unable to read tables." << std::endl;
  2057 + std::cout << e.what() << std::endl;
2038 2058 throw;
2039 2059 }
2040   - cout << ". ok." << endl;
  2060 + std::cout << ". ok." << std::endl;
2041 2061  
2042 2062 }
2043 2063  
... ... @@ -2051,7 +2071,7 @@ void test_bintable_logical(void)
2051 2071 std::string filename = "test_bintable_logical.fits";
2052 2072  
2053 2073 // Dump header
2054   - cout << "Test GFitsTableLogCol: ";
  2074 + std::cout << "Test GFitsTableBoolCol: ";
2055 2075  
2056 2076 // Remove FITS file
2057 2077 std::string cmd = "rm -rf "+ filename;
... ... @@ -2087,9 +2107,9 @@ void test_bintable_logical(void)
2087 2107 //
2088 2108  
2089 2109 // Set table
2090   - GFitsTableLogCol col = GFitsTableLogCol("LOGICAL", nrows);
  2110 + GFitsTableBoolCol col = GFitsTableBoolCol("LOGICAL", nrows);
2091 2111 for (int i = 0; i < nrows; ++i) {
2092   - char val = (i % 2) ? 1 : 0;
  2112 + bool val = (i % 2) ? true : false;
2093 2113 col(i) = val;
2094 2114 sum += val;
2095 2115 sum_int += int(val);
... ... @@ -2098,62 +2118,62 @@ void test_bintable_logical(void)
2098 2118 else
2099 2119 sum_str += ":F";
2100 2120 }
2101   - cout << ".";
  2121 + std::cout << ".";
2102 2122  
2103 2123 // Check table (operator access)
2104 2124 tot_int = 0;
2105 2125 for (int i = 0; i < nrows; ++i)
2106 2126 tot_int += col(i);
2107 2127 if (tot_int != sum) {
2108   - cout << endl << "TEST ERROR: GFitsTableLogCol::operator()";
2109   - cout << endl << " Reference sum: " << sum;
2110   - cout << endl << " Derived sum: " << tot_int << endl;
  2128 + std::cout << std::endl << "TEST ERROR: GFitsTableBoolCol::operator()";
  2129 + std::cout << std::endl << " Reference sum: " << sum;
  2130 + std::cout << std::endl << " Derived sum: " << tot_int << std::endl;
2111 2131 throw;
2112 2132 }
2113   - cout << ".";
  2133 + std::cout << ".";
2114 2134  
2115 2135 // Check table (real access)
2116 2136 tot_dbl = 0.0;
2117 2137 for (int i = 0; i < nrows; ++i)
2118 2138 tot_dbl += col.real(i);
2119 2139 if (!dequal(tot_dbl, double(sum))) {
2120   - cout << endl << "TEST ERROR: GFitsTableLogCol::real()";
2121   - cout << endl << " Reference sum: " << sum;
2122   - cout << endl << " Derived sum: " << tot_dbl << endl;
  2140 + std::cout << std::endl << "TEST ERROR: GFitsTableBoolCol::real()";
  2141 + std::cout << std::endl << " Reference sum: " << sum;
  2142 + std::cout << std::endl << " Derived sum: " << tot_dbl << std::endl;
2123 2143 throw;
2124 2144 }
2125   - cout << ".";
  2145 + std::cout << ".";
2126 2146  
2127 2147 // Check table (int access)
2128 2148 tot_int = 0;
2129 2149 for (int i = 0; i < nrows; ++i)
2130 2150 tot_int += col.integer(i);
2131 2151 if (tot_int != sum_int) {
2132   - cout << endl << "TEST ERROR: GFitsTableLogCol::integer()";
2133   - cout << endl << " Reference sum: " << sum_int;
2134   - cout << endl << " Derived sum: " << tot_int << endl;
  2152 + std::cout << std::endl << "TEST ERROR: GFitsTableBoolCol::integer()";
  2153 + std::cout << std::endl << " Reference sum: " << sum_int;
  2154 + std::cout << std::endl << " Derived sum: " << tot_int << std::endl;
2135 2155 throw;
2136 2156 }
2137   - cout << ".";
  2157 + std::cout << ".";
2138 2158  
2139 2159 // Check table (string access)
2140 2160 tot_str.clear();
2141 2161 for (int i = 0; i < nrows; ++i)
2142 2162 tot_str += ":"+col.string(i);
2143 2163 if (tot_str != sum_str) {
2144   - cout << endl << "TEST ERROR: GFitsTableLogCol::string()";
2145   - cout << endl << " Reference sum: " << sum_str;
2146   - cout << endl << " Derived sum: " << tot_str << endl;
  2164 + std::cout << std::endl << "TEST ERROR: GFitsTableBoolCol::string()";
  2165 + std::cout << std::endl << " Reference sum: " << sum_str;
  2166 + std::cout << std::endl << " Derived sum: " << tot_str << std::endl;
2147 2167 throw;
2148 2168 }
2149   - cout << ".";
  2169 + std::cout << ".";
2150 2170  
2151 2171 //
2152 2172 // ===== L O G I C A L 1 0 =====
2153 2173 //
2154 2174  
2155 2175 // Set table
2156   - GFitsTableLogCol col10 = GFitsTableLogCol("LOGICAL10", nrows, nvec);
  2176 + GFitsTableBoolCol col10 = GFitsTableBoolCol("LOGICAL10", nrows, nvec);
2157 2177 for (int i = 0; i < nrows; ++i) {
2158 2178 for (int j = 0; j < nvec; ++j) {
2159 2179 char val = (i % 2) * (j % 2);
... ... @@ -2166,7 +2186,7 @@ void test_bintable_logical(void)
2166 2186 sum10_str += ":F";
2167 2187 }
2168 2188 }
2169   - cout << ".";
  2189 + std::cout << ".";
2170 2190  
2171 2191 // Check table (operator access)
2172 2192 tot_int = 0;
... ... @@ -2175,12 +2195,12 @@ void test_bintable_logical(void)
2175 2195 tot_int += col10(i,j);
2176 2196 }
2177 2197 if (tot_int != sum10) {
2178   - cout << endl << "TEST ERROR: GFitsTableLogCol::operator() - 10";
2179   - cout << endl << " Reference sum: " << sum10;
2180   - cout << endl << " Derived sum: " << tot_int << endl;
  2198 + std::cout << std::endl << "TEST ERROR: GFitsTableBoolCol::operator() - 10";
  2199 + std::cout << std::endl << " Reference sum: " << sum10;
  2200 + std::cout << std::endl << " Derived sum: " << tot_int << std::endl;
2181 2201 throw;
2182 2202 }
2183   - cout << ".";
  2203 + std::cout << ".";
2184 2204  
2185 2205 // Check table (real access)
2186 2206 tot_dbl = 0.0;
... ... @@ -2189,12 +2209,12 @@ void test_bintable_logical(void)
2189 2209 tot_dbl += col10.real(i,j);
2190 2210 }
2191 2211 if (!dequal(tot_dbl, sum10)) {
2192   - cout << endl << "TEST ERROR: GFitsTableLogCol::real() - 10";
2193   - cout << endl << " Reference sum: " << sum10;
2194   - cout << endl << " Derived sum: " << tot_dbl << endl;
  2212 + std::cout << std::endl << "TEST ERROR: GFitsTableBoolCol::real() - 10";
  2213 + std::cout << std::endl << " Reference sum: " << sum10;
  2214 + std::cout << std::endl << " Derived sum: " << tot_dbl << std::endl;
2195 2215 throw;
2196 2216 }
2197   - cout << ".";
  2217 + std::cout << ".";
2198 2218  
2199 2219 // Check table (int access)
2200 2220 tot_int = 0;
... ... @@ -2203,12 +2223,12 @@ void test_bintable_logical(void)
2203 2223 tot_int += col10.integer(i,j);
2204 2224 }
2205 2225 if (tot_int != sum10_int) {
2206   - cout << endl << "TEST ERROR: GFitsTableLogCol::integer() - 10";
2207   - cout << endl << " Reference sum: " << sum10_int;
2208   - cout << endl << " Derived sum: " << tot_int << endl;
  2226 + std::cout << std::endl << "TEST ERROR: GFitsTableBoolCol::integer() - 10";
  2227 + std::cout << std::endl << " Reference sum: " << sum10_int;
  2228 + std::cout << std::endl << " Derived sum: " << tot_int << std::endl;
2209 2229 throw;
2210 2230 }
2211   - cout << ".";
  2231 + std::cout << ".";
2212 2232  
2213 2233 // Check table (string access)
2214 2234 tot_str.clear();
... ... @@ -2217,12 +2237,12 @@ void test_bintable_logical(void)
2217 2237 tot_str += ":"+col10.string(i,j);
2218 2238 }
2219 2239 if (tot_str != sum10_str) {
2220   - cout << endl << "TEST ERROR: GFitsTableLogCol::string() - 10";
2221   - cout << endl << " Reference sum: " << sum10_str;
2222   - cout << endl << " Derived sum: " << tot_str << endl;
  2240 + std::cout << std::endl << "TEST ERROR: GFitsTableBoolCol::string() - 10";
  2241 + std::cout << std::endl << " Reference sum: " << sum10_str;
  2242 + std::cout << std::endl << " Derived sum: " << tot_str << std::endl;
2223 2243 throw;
2224 2244 }
2225   - cout << ".";
  2245 + std::cout << ".";
2226 2246  
2227 2247 //
2228 2248 // ===== W R I T E T A B L E =====
... ... @@ -2239,15 +2259,15 @@ void test_bintable_logical(void)
2239 2259  
2240 2260 // Save FITS file
2241 2261 fits.save();
2242   - cout << ".";
  2262 + std::cout << ".";
2243 2263  
2244 2264 }
2245   - catch (exception &e) {
2246   - cout << endl << "TEST ERROR: Unable to build tables." << endl;
2247   - cout << e.what() << endl;
  2265 + catch (std::exception &e) {
  2266 + std::cout << std::endl << "TEST ERROR: Unable to build tables." << std::endl;
  2267 + std::cout << e.what() << std::endl;
2248 2268 throw;
2249 2269 }
2250   - cout << ".";
  2270 + std::cout << ".";
2251 2271  
2252 2272  
2253 2273 //================================================================
... ... @@ -2278,64 +2298,64 @@ void test_bintable_logical(void)
2278 2298 //
2279 2299  
2280 2300 // Get column
2281   - GFitsTableLogCol* col =
2282   - (GFitsTableLogCol*)fits.hdu(1)->column("LOGICAL");
  2301 + GFitsTableBoolCol* col =
  2302 + (GFitsTableBoolCol*)fits.hdu(1)->column("LOGICAL");
2283 2303  
2284 2304 // Check table (operator access)
2285 2305 tot_int = 0;
2286 2306 for (int i = 0; i < nrows; ++i)
2287 2307 tot_int += (*col)(i);
2288 2308 if (tot_int != sum) {
2289   - cout << endl << "TEST ERROR: GFitsTableLogCol::operator()";
2290   - cout << endl << " Reference sum: " << sum;
2291   - cout << endl << " Derived sum: " << tot_int << endl;
  2309 + std::cout << std::endl << "TEST ERROR: GFitsTableBoolCol::operator()";
  2310 + std::cout << std::endl << " Reference sum: " << sum;
  2311 + std::cout << std::endl << " Derived sum: " << tot_int << std::endl;
2292 2312 throw;
2293 2313 }
2294   - cout << ".";
  2314 + std::cout << ".";
2295 2315  
2296 2316 // Check table (real access)
2297 2317 tot_dbl = 0.0;
2298 2318 for (int i = 0; i < nrows; ++i)
2299 2319 tot_dbl += col->real(i);
2300 2320 if (!dequal(tot_dbl, double(sum))) {
2301   - cout << endl << "TEST ERROR: GFitsTableLogCol::real()";
2302   - cout << endl << " Reference sum: " << sum;
2303   - cout << endl << " Derived sum: " << tot_dbl << endl;
  2321 + std::cout << std::endl << "TEST ERROR: GFitsTableBoolCol::real()";
  2322 + std::cout << std::endl << " Reference sum: " << sum;
  2323 + std::cout << std::endl << " Derived sum: " << tot_dbl << std::endl;
2304 2324 throw;
2305 2325 }
2306   - cout << ".";
  2326 + std::cout << ".";
2307 2327  
2308 2328 // Check table (int access)
2309 2329 tot_int = 0;
2310 2330 for (int i = 0; i < nrows; ++i)
2311 2331 tot_int += col->integer(i);
2312 2332 if (tot_int != sum_int) {
2313   - cout << endl << "TEST ERROR: GFitsTableLogCol::integer()";
2314   - cout << endl << " Reference sum: " << sum_int;
2315   - cout << endl << " Derived sum: " << tot_int << endl;
  2333 + std::cout << std::endl << "TEST ERROR: GFitsTableBoolCol::integer()";
  2334 + std::cout << std::endl << " Reference sum: " << sum_int;
  2335 + std::cout << std::endl << " Derived sum: " << tot_int << std::endl;
2316 2336 throw;
2317 2337 }
2318   - cout << ".";
  2338 + std::cout << ".";
2319 2339  
2320 2340 // Check single precision table (string access)
2321 2341 tot_str.clear();
2322 2342 for (int i = 0; i < nrows; ++i)
2323 2343 tot_str += ":"+col->string(i);
2324 2344 if (tot_str != sum_str) {
2325   - cout << endl << "TEST ERROR: GFitsTableLogCol::string()";
2326   - cout << endl << " Reference sum: " << sum_str;
2327   - cout << endl << " Derived sum: " << tot_str << endl;
  2345 + std::cout << std::endl << "TEST ERROR: GFitsTableBoolCol::string()";
  2346 + std::cout << std::endl << " Reference sum: " << sum_str;
  2347 + std::cout << std::endl << " Derived sum: " << tot_str << std::endl;
2328 2348 throw;
2329 2349 }
2330   - cout << ".";
  2350 + std::cout << ".";
2331 2351  
2332 2352 //
2333 2353 // ===== L O G I C A L 1 0 =====
2334 2354 //
2335 2355  
2336 2356 // Get column
2337   - GFitsTableLogCol* col10 =
2338   - (GFitsTableLogCol*)fits.hdu(1)->column("LOGICAL10");
  2357 + GFitsTableBoolCol* col10 =
  2358 + (GFitsTableBoolCol*)fits.hdu(1)->column("LOGICAL10");
2339 2359  
2340 2360 // Check table (operator access)
2341 2361 tot_int = 0;
... ... @@ -2344,12 +2364,12 @@ void test_bintable_logical(void)
2344 2364 tot_int += (*col10)(i,j);
2345 2365 }
2346 2366 if (tot_int != sum10) {
2347   - cout << endl << "TEST ERROR: GFitsTableLogCol::operator() - 10";
2348   - cout << endl << " Reference sum: " << sum10;
2349   - cout << endl << " Derived sum: " << tot_int << endl;
  2367 + std::cout << std::endl << "TEST ERROR: GFitsTableBoolCol::operator() - 10";
  2368 + std::cout << std::endl << " Reference sum: " << sum10;
  2369 + std::cout << std::endl << " Derived sum: " << tot_int << std::endl;
2350 2370 throw;
2351 2371 }
2352   - cout << ".";
  2372 + std::cout << ".";
2353 2373  
2354 2374 // Check table (real access)
2355 2375 tot_dbl = 0.0;
... ... @@ -2358,12 +2378,12 @@ void test_bintable_logical(void)
2358 2378 tot_dbl += col10->real(i,j);
2359 2379 }
2360 2380 if (!dequal(tot_dbl, sum10)) {
2361   - cout << endl << "TEST ERROR: GFitsTableLogCol::real() - 10";
2362   - cout << endl << " Reference sum: " << sum10;
2363   - cout << endl << " Derived sum: " << tot_dbl << endl;
  2381 + std::cout << std::endl << "TEST ERROR: GFitsTableBoolCol::real() - 10";
  2382 + std::cout << std::endl << " Reference sum: " << sum10;
  2383 + std::cout << std::endl << " Derived sum: " << tot_dbl << std::endl;
2364 2384 throw;
2365 2385 }
2366   - cout << ".";
  2386 + std::cout << ".";
2367 2387  
2368 2388 // Check table (int access)
2369 2389 tot_int = 0;
... ... @@ -2372,12 +2392,12 @@ void test_bintable_logical(void)
2372 2392 tot_int += col10->integer(i,j);
2373 2393 }
2374 2394 if (tot_int != sum10_int) {
2375   - cout << endl << "TEST ERROR: GFitsTableLogCol::integer() - 10";
2376   - cout << endl << " Reference sum: " << sum10_int;
2377   - cout << endl << " Derived sum: " << tot_int << endl;
  2395 + std::cout << std::endl << "TEST ERROR: GFitsTableBoolCol::integer() - 10";
  2396 + std::cout << std::endl << " Reference sum: " << sum10_int;
  2397 + std::cout << std::endl << " Derived sum: " << tot_int << std::endl;
2378 2398 throw;
2379 2399 }
2380   - cout << ".";
  2400 + std::cout << ".";
2381 2401  
2382 2402 // Check single precision table (string access)
2383 2403 tot_str.clear();
... ... @@ -2386,19 +2406,19 @@ void test_bintable_logical(void)
2386 2406 tot_str += ":"+col10->string(i,j);
2387 2407 }
2388 2408 if (tot_str != sum10_str) {
2389   - cout << endl << "TEST ERROR: GFitsTableLogCol::string() - 10";
2390   - cout << endl << " Reference sum: " << sum10_str;
2391   - cout << endl << " Derived sum: " << tot_str << endl;
  2409 + std::cout << std::endl << "TEST ERROR: GFitsTableBoolCol::string() - 10";
  2410 + std::cout << std::endl << " Reference sum: " << sum10_str;
  2411 + std::cout << std::endl << " Derived sum: " << tot_str << std::endl;
2392 2412 throw;
2393 2413 }
2394   - cout << ".";
  2414 + std::cout << ".";
2395 2415 }
2396   - catch (exception &e) {
2397   - cout << endl << "TEST ERROR: Unable to build tables." << endl;
2398   - cout << e.what() << endl;
  2416 + catch (std::exception &e) {
  2417 + std::cout << std::endl << "TEST ERROR: Unable to build tables." << std::endl;
  2418 + std::cout << e.what() << std::endl;
2399 2419 throw;
2400 2420 }
2401   - cout << ". ok." << endl;
  2421 + std::cout << ". ok." << std::endl;
2402 2422  
2403 2423 }
2404 2424  
... ...