GammaLib  2.1.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GFitsImageUShort.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GFitsImageUShort.hpp - Unsigned short FITS image 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 GFitsImageUShort.hpp
23  * @brief Unsigned short FITS image class definition
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef GFITSIMAGEUSHORT_HPP
28 #define GFITSIMAGEUSHORT_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include "GFitsImage.hpp"
32 
33 
34 /***********************************************************************//**
35  * @class GFitsImageUShort
36  *
37  * @brief Unsigned short FITS image class
38  ***************************************************************************/
39 class GFitsImageUShort : public GFitsImage {
40 
41 public:
42  // Constructors and destructors
43  GFitsImageUShort(void);
44  GFitsImageUShort(const int& nx, const unsigned short* pixels = NULL);
45  GFitsImageUShort(const int& nx, const int& ny, const unsigned short* pixels = NULL);
46  GFitsImageUShort(const int& nx, const int& ny, const int& nz, const unsigned short* pixels = NULL);
47  GFitsImageUShort(const int& nx, const int& ny, const int& nz, const int& nt, const unsigned short* pixels = NULL);
48  GFitsImageUShort(const std::vector<int>& naxes, const unsigned short* pixels = NULL);
49  GFitsImageUShort(const GFitsImage& image);
50  GFitsImageUShort(const GFitsImageUShort& image);
51  virtual ~GFitsImageUShort(void);
52 
53  // Operators
55  unsigned short& operator()(const int& ix);
56  unsigned short& operator()(const int& ix, const int& iy);
57  unsigned short& operator()(const int& ix, const int& iy, const int& iz);
58  unsigned short& operator()(const int& ix, const int& iy, const int& iz, const int& it);
59  const unsigned short& operator()(const int& ix) const;
60  const unsigned short& operator()(const int& ix, const int& iy) const;
61  const unsigned short& operator()(const int& ix, const int& iy, const int& iz) const;
62  const unsigned short& operator()(const int& ix, const int& iy, const int& iz, const int& it) const;
63 
64  // Methods
65  void clear(void);
66  GFitsImageUShort* clone(void) const;
67  std::string classname(void) const;
68  unsigned short& at(const int& ix);
69  unsigned short& at(const int& ix, const int& iy);
70  unsigned short& at(const int& ix, const int& iy, const int& iz);
71  unsigned short& at(const int& ix, const int& iy, const int& iz, const int& it);
72  const unsigned short& at(const int& ix) const;
73  const unsigned short& at(const int& ix, const int& iy) const;
74  const unsigned short& at(const int& ix, const int& iy, const int& iz) const;
75  const unsigned short& at(const int& ix, const int& iy, const int& iz, const int& it) const;
76  double pixel(const int& ix) const;
77  double pixel(const int& ix, const int& iy) const;
78  double pixel(const int& ix, const int& iy, const int& iz) const;
79  double pixel(const int& ix, const int& iy, const int& iz, const int& it) const;
80  void* pixels(void);
81  int type(void) const;
82 
83 private:
84  // Private methods
85  void init_members(void);
86  void copy_members(const GFitsImageUShort& image);
87  void free_members(void);
88  void alloc_data(void);
89  void init_data(void);
90  void release_data(void);
91  void construct_data(const unsigned short* pixels);
92  void load_data(void) const;
93  void alloc_nulval(const void* value);
94  void* ptr_data(void) { return m_pixels; }
95  void* ptr_nulval(void) { return m_nulval; }
96 
97  // Private data area
98  unsigned short* m_pixels; //!< Pixels
99  unsigned short* m_nulval; //!< NULL value
100 };
101 
102 
103 /***********************************************************************//**
104  * @brief Return class name
105  *
106  * @return String containing the class name ("GFitsImageUShort").
107  ***************************************************************************/
108 inline
109 std::string GFitsImageUShort::classname(void) const
110 {
111  return ("GFitsImageUShort");
112 }
113 
114 #endif /* GFITSIMAGEUSHORT_HPP */
void init_data(void)
Initialise data.
Abstract FITS image base class.
Definition: GFitsImage.hpp:43
void release_data(void)
Release data.
void * ptr_nulval(void)
unsigned short & at(const int &ix)
Image pixel access operator.
double pixel(const int &ix) const
Return value of image pixel.
void construct_data(const unsigned short *pixels)
Construct data from array.
void alloc_nulval(const void *value)
Allocates nul value.
GFitsImageUShort * clone(void) const
Clone FITS image.
void * ptr_data(void)
void clear(void)
Clear instance.
Abstract FITS image base class definition.
unsigned short * m_nulval
NULL value.
void alloc_data(void)
Allocate data.
unsigned short * m_pixels
Pixels.
void copy_members(const GFitsImageUShort &image)
Copy class members.
unsigned short & operator()(const int &ix)
Image pixel access operator.
void init_members(void)
Initialise class members.
int type(void) const
Return image type.
void free_members(void)
Delete class members.
void load_data(void) const
Load data.
Unsigned short FITS image class.
GFitsImageUShort(void)
Void constructor.
int naxes(const int &axis) const
Return dimension of an image axis.
Definition: GFitsImage.cpp:344
GFitsImageUShort & operator=(const GFitsImageUShort &image)
Assignment operator.
virtual ~GFitsImageUShort(void)
Destructor.
void * pixels(void)
Return pointer to image pixel.
std::string classname(void) const
Return class name.