GammaLib  2.1.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GFitsTableByteCol.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GFitsTableByteCol.hpp - FITS table Byte column class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2008-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 GFitsTableByteCol.hpp
23  * @brief FITS table Byte column class interface definition
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef GFITSTABLEBYTECOL_HPP
28 #define GFITSTABLEBYTECOL_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <string>
32 #include "GFitsTableCol.hpp"
33 
34 
35 /***********************************************************************//**
36  * @class GFitsTableByteCol
37  *
38  * @brief FITS table Byte column
39  *
40  * This class implements a FITS table Byte column.
41  ***************************************************************************/
43 
44 public:
45  // Constructors and destructors
46  GFitsTableByteCol(void);
47  GFitsTableByteCol(const std::string& name, const int& nrows,
48  const int& size = 1);
49  GFitsTableByteCol(const GFitsTableByteCol& column);
50  virtual ~GFitsTableByteCol(void);
51 
52  // Operators
54  unsigned char& operator()(const int& row, const int& inx = 0);
55  const unsigned char& operator()(const int& row, const int& inx = 0) const;
56 
57  // Implement virtual methods
58  virtual void clear(void);
59  virtual GFitsTableByteCol* 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  unsigned char* data(void);
70  unsigned char* nulval(void);
71  void nulval(const unsigned char* value);
72 
73 private:
74  // Private methods
75  void init_members(void);
76  void copy_members(const GFitsTableByteCol& column);
77  void free_members(void);
78  void alloc_nulval(const unsigned char* 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  unsigned char* m_data; //!< Data vector
92  unsigned char* m_nulval; //!< NULL value
93 };
94 
95 
96 /***********************************************************************//**
97  * @brief Return class name
98  *
99  * @return String containing the class name ("GFitsTableByteCol").
100  ***************************************************************************/
101 inline
102 std::string GFitsTableByteCol::classname(void) const
103 {
104  return ("GFitsTableByteCol");
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
126 unsigned char* GFitsTableByteCol::data(void)
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
138 unsigned char* GFitsTableByteCol::nulval(void)
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* GFitsTableByteCol::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 /* GFITSTABLEBYTECOL_HPP */
virtual GFitsTableByteCol * clone(void) const
Clone column.
void free_members(void)
Delete class members.
virtual void init_data(void)
Initialise column data.
virtual void clear(void)
Clear instance.
const std::string & name(void) const
Returns column name.
virtual void insert(const int &row, const int &nrows)
Insert rows in column.
FITS table Byte column.
virtual int integer(const int &row, const int &col=0) const
Get integer value.
unsigned char * m_nulval
NULL value.
FITS table column abstract base class definition.
unsigned char * m_data
Data vector.
virtual void * ptr_nulval(void)
Returns void pointer to nul value.
virtual void release_data(void)
Release column data.
const int & number(void) const
Returns number of elements in column.
void alloc_nulval(const unsigned char *value)
Allocates null value.
virtual ~GFitsTableByteCol(void)
Destructor.
Abstract interface for FITS table column.
unsigned char & operator()(const int &row, const int &inx=0)
Column data access operator.
void init_members(void)
Initialise class members.
unsigned char * data(void)
Returns pointer to column data.
virtual void alloc_data(void)
Allocates column data.
virtual void resize_data(const int &index, const int &number)
Resize column data.
GFitsTableByteCol & operator=(const GFitsTableByteCol &column)
Assignment operator.
virtual double real(const int &row, const int &col=0) const
Get double precision value.
virtual std::string ascii_format(void) const
Returns format string of ASCII table.
virtual void * ptr_data(const int &index=0)
Returns void pointer to column data.
GFitsTableByteCol(void)
Constructor.
virtual bool is_loaded(void) const
Checks if column has been loaded.
unsigned char * nulval(void)
Returns pointer to nul value.
void copy_members(const GFitsTableByteCol &column)
Copy class members.
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.
virtual void fetch_data(void) const
Fetch column data.
virtual std::string classname(void) const
Return class name.