GammaLib  2.1.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GFitsTableLongCol.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GFitsTableLongCol.hpp - FITS table long column class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2010-2017 by Juergen Knoedlseder *
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 3 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License *
18  * along with this program. If not, see <http://www.gnu.org/licenses/>. *
19  * *
20  ***************************************************************************/
21 /**
22  * @file GFitsTableLongCol.hpp
23  * @brief FITS table long integer column class interface definition
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef GFITSTABLELONGCOL_HPP
28 #define GFITSTABLELONGCOL_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <string>
32 #include "GFitsTableCol.hpp"
33 
34 
35 /***********************************************************************//**
36  * @class GFitsTableLongCol
37  *
38  * @brief FITS table long integer column
39  *
40  * This class implements a FITS table long integer column.
41  ***************************************************************************/
43 
44 public:
45  // Constructors and destructors
46  GFitsTableLongCol(void);
47  GFitsTableLongCol(const std::string& name, const int& nrows,
48  const int& size = 1);
49  GFitsTableLongCol(const GFitsTableLongCol& column);
50  virtual ~GFitsTableLongCol(void);
51 
52  // Operators
54  long& operator()(const int& row, const int& inx = 0);
55  const long& operator()(const int& row, const int& inx = 0) const;
56 
57  // Implement virtual methods
58  virtual void clear(void);
59  virtual GFitsTableLongCol* clone(void) const;
60  virtual std::string classname(void) const;
61  virtual std::string string(const int& row, const int& col = 0) const;
62  virtual double real(const int& row, const int& col = 0) const;
63  virtual int integer(const int& row, const int& col = 0) const;
64  virtual void insert(const int& row, const int& nrows);
65  virtual void remove(const int& row, const int& nrows);
66  virtual bool is_loaded(void) const;
67 
68  // Other methods
69  long* data(void);
70  long* nulval(void);
71  void nulval(const long* value);
72 
73 private:
74  // Private methods
75  void init_members(void);
76  void copy_members(const GFitsTableLongCol& column);
77  void free_members(void);
78  void alloc_nulval(const long* value);
79 
80  // Implemented virtual base class methods
81  virtual void alloc_data(void);
82  virtual void init_data(void);
83  virtual void fetch_data(void) const;
84  virtual void resize_data(const int& index, const int& number);
85  virtual void release_data(void);
86  virtual void* ptr_data(const int& index = 0);
87  virtual void* ptr_nulval(void);
88  virtual std::string ascii_format(void) const;
89 
90  // Private data area
91  long* m_data; //!< Data vector
92  long* m_nulval; //!< NULL value
93 };
94 
95 
96 /***********************************************************************//**
97  * @brief Return class name
98  *
99  * @return String containing the class name ("GFitsTableLongCol").
100  ***************************************************************************/
101 inline
102 std::string GFitsTableLongCol::classname(void) const
103 {
104  return ("GFitsTableLongCol");
105 }
106 
107 
108 /***********************************************************************//**
109  * @brief Checks if column has been loaded
110  *
111  * @return True if column has been loaded, false otherwise
112  ***************************************************************************/
113 inline
115 {
116  return (m_data != NULL);
117 }
118 
119 
120 /***********************************************************************//**
121  * @brief Returns pointer to column data
122  *
123  * @return Pointer to column data.
124  ***************************************************************************/
125 inline
127 {
128  return m_data;
129 }
130 
131 
132 /***********************************************************************//**
133  * @brief Returns pointer to nul value
134  *
135  * @return Pointer to nul value.
136  ***************************************************************************/
137 inline
139 {
140  return m_nulval;
141 }
142 
143 
144 /***********************************************************************//**
145  * @brief Returns void pointer to column data
146  *
147  * @return Void pointer to column data.
148  ***************************************************************************/
149 inline
150 void* GFitsTableLongCol::ptr_data(const int& index)
151 {
152  return (m_data+index);
153 }
154 
155 
156 /***********************************************************************//**
157  * @brief Returns void pointer to nul value
158  *
159  * @return Void pointer to nul value.
160  ***************************************************************************/
161 inline
163 {
164  return m_nulval;
165 }
166 
167 #endif /* GFITSTABLELONGCOL_HPP */
virtual int integer(const int &row, const int &col=0) const
Get integer value.
virtual void * ptr_nulval(void)
Returns void pointer to nul value.
virtual std::string ascii_format(void) const
Returns format string of ASCII table.
long * m_nulval
NULL value.
const std::string & name(void) const
Returns column name.
virtual void clear(void)
Clear instance.
long * m_data
Data vector.
virtual GFitsTableLongCol * clone(void) const
Clone column.
virtual void insert(const int &row, const int &nrows)
Insert rows in column.
FITS table column abstract base class definition.
virtual void resize_data(const int &index, const int &number)
Resize column data.
long * data(void)
Returns pointer to column data.
virtual void release_data(void)
Release column data.
virtual void alloc_data(void)
Allocates column data.
virtual void init_data(void)
Initialise column data.
virtual ~GFitsTableLongCol(void)
Destructor.
GFitsTableLongCol & operator=(const GFitsTableLongCol &column)
Assignment operator.
const int & number(void) const
Returns number of elements in column.
void init_members(void)
Initialise class members.
Abstract interface for FITS table column.
long * nulval(void)
Returns pointer to nul value.
virtual bool is_loaded(void) const
Checks if column has been loaded.
virtual void fetch_data(void) const
Fetch column data.
FITS table long integer column.
void free_members(void)
Delete class members.
virtual double real(const int &row, const int &col=0) const
Get double precision value.
void alloc_nulval(const long *value)
Allocates null value.
virtual std::string classname(void) const
Return class name.
GFitsTableLongCol(void)
Constructor.
virtual std::string string(const int &row, const int &col=0) const
Get string value.
const int & nrows(void) const
Returns number of rows in column.
long & operator()(const int &row, const int &inx=0)
Column data access operator.
void copy_members(const GFitsTableLongCol &column)
Copy class members.
virtual void * ptr_data(const int &index=0)
Returns void pointer to column data.