GammaLib 2.0.0
Loading...
Searching...
No Matches
GFitsTableShortCol.hpp
Go to the documentation of this file.
1/***************************************************************************
2 * GFitsTableShortCol.hpp - FITS table short 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 GFitsTableShortCol.hpp
23 * @brief FITS table short integer column class interface definition
24 * @author Juergen Knoedlseder
25 */
26
27#ifndef GFITSTABLESHORTCOL_HPP
28#define GFITSTABLESHORTCOL_HPP
29
30/* __ Includes ___________________________________________________________ */
31#include <string>
32#include "GFitsTableCol.hpp"
33
34
35/***********************************************************************//**
36 * @class GFitsTableShortCol
37 *
38 * @brief FITS table short integer column
39 *
40 * This class implements a FITS table short integer column.
41 ***************************************************************************/
43
44public:
45 // Constructors and destructors
47 GFitsTableShortCol(const std::string& name, const int& nrows,
48 const int& size = 1);
50 virtual ~GFitsTableShortCol(void);
51
52 // Operators
54 short& operator()(const int& row, const int& inx = 0);
55 const short& operator()(const int& row, const int& inx = 0) const;
56
57 // Implement virtual methods
58 virtual void clear(void);
59 virtual GFitsTableShortCol* 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 short* data(void);
70 short* nulval(void);
71 void nulval(const short* value);
72
73private:
74 // Private methods
75 void init_members(void);
76 void copy_members(const GFitsTableShortCol& column);
77 void free_members(void);
78 void alloc_nulval(const short* 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 short* m_data; //!< Data vector
92 short* m_nulval; //!< NULL value
93};
94
95
96/***********************************************************************//**
97 * @brief Return class name
98 *
99 * @return String containing the class name ("GFitsTableShortCol").
100 ***************************************************************************/
101inline
102std::string GFitsTableShortCol::classname(void) const
103{
104 return ("GFitsTableShortCol");
105}
106
107
108/***********************************************************************//**
109 * @brief Checks if column has been loaded
110 *
111 * @return True if column has been loaded, false otherwise
112 ***************************************************************************/
113inline
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 ***************************************************************************/
125inline
127{
128 return m_data;
129}
130
131
132/***********************************************************************//**
133 * @brief Returns pointer to nul value
134 *
135 * @return Pointer to nul value.
136 ***************************************************************************/
137inline
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 ***************************************************************************/
149inline
150void* GFitsTableShortCol::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 ***************************************************************************/
161inline
163{
164 return m_nulval;
165}
166
167#endif /* GFITSTABLESHORTCOL_HPP */
FITS table column abstract base class definition.
Abstract interface for FITS table column.
const int & nrows(void) const
Returns number of rows in column.
const int & number(void) const
Returns number of elements in column.
const std::string & name(void) const
Returns column name.
FITS table short integer column.
virtual bool is_loaded(void) const
Checks if column has been loaded.
virtual std::string classname(void) const
Return class name.
virtual double real(const int &row, const int &col=0) const
Get double precision value.
virtual void remove(const int &row, const int &nrows)
Remove rows from column.
void copy_members(const GFitsTableShortCol &column)
Copy class members.
virtual void fetch_data(void) const
Fetch column data.
short & operator()(const int &row, const int &inx=0)
Column data access operator.
virtual void alloc_data(void)
Allocates column data.
virtual void release_data(void)
Release column data.
virtual void insert(const int &row, const int &nrows)
Insert rows in column.
short * data(void)
Returns pointer to column data.
virtual void * ptr_data(const int &index=0)
Returns void pointer to column data.
virtual void clear(void)
Clear instance.
GFitsTableShortCol & operator=(const GFitsTableShortCol &column)
Assignment operator.
virtual std::string ascii_format(void) const
Returns format string of ASCII table.
virtual void * ptr_nulval(void)
Returns void pointer to nul value.
virtual int integer(const int &row, const int &col=0) const
Get integer value.
short * m_data
Data vector.
virtual ~GFitsTableShortCol(void)
Destructor.
short * nulval(void)
Returns pointer to nul value.
void free_members(void)
Delete class members.
void alloc_nulval(const short *value)
Allocates null value.
virtual void init_data(void)
Initialise column data.
virtual GFitsTableShortCol * clone(void) const
Clone column.
void init_members(void)
Initialise class members.
short * m_nulval
NULL value.
virtual void resize_data(const int &index, const int &number)
Resize column data.
virtual std::string string(const int &row, const int &col=0) const
Get string value.
GFitsTableShortCol(void)
Constructor.