GammaLib  2.1.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GSkyRegion.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GSkyRegion.hpp - Abstract virtual sky region base class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2013-2017 by Pierrick Martin *
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 GSkyRegion.hpp
23  * @brief Abstract sky region base class interface definition
24  * @author Pierrick Martin
25  */
26 
27 #ifndef GSKYREGION_HPP
28 #define GSKYREGION_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <vector>
32 #include <string>
33 #include "GBase.hpp"
34 
35 /* __ Forward declarations _______________________________________________ */
36 class GSkyPixel;
37 class GSkyDir;
38 
39 
40 /***********************************************************************//**
41  * @class GSkyRegion
42  *
43  * @brief Abstract interface for the sky region class
44  *
45  * This class provides an abstract interface for a sky region. The sky region
46  * is defined by an array of parameters names and values specific to the
47  * derived class where the region type or shape is implemented.
48  *
49  * Accessible information elements are:
50  * - Type of the region (circle, rectangle,...)
51  * - Solid angle subtended by the region
52  *
53  * The object can be initialised from a string in the DS9 region file format,
54  * and return its description as a string in the DS9 region file format. The
55  * input/ouput to/from files is handled in the container class GSkyRegions.
56  ***************************************************************************/
57 class GSkyRegion : public GBase {
58 
59 public:
60  // Constructors and destructors
61  GSkyRegion(void);
62  GSkyRegion(const GSkyRegion& region);
63  virtual ~GSkyRegion(void);
64 
65  // Operators
66  virtual GSkyRegion& operator=(const GSkyRegion& region);
67 
68  // Pure virtual methods
69  virtual void clear(void) = 0;
70  virtual GSkyRegion* clone(void) const = 0;
71  virtual std::string classname(void) const = 0;
72  virtual void read(const std::string& regstring) = 0;
73  virtual std::string write(void) const = 0;
74  virtual bool contains(const GSkyDir& dir) const = 0;
75  virtual bool overlaps(const GSkyRegion& reg) const = 0;
76  virtual bool contains(const GSkyRegion& reg) const = 0;
77  virtual std::string print(const GChatter& chatter = NORMAL) const = 0;
78 
79  // Implemented methods
80  const std::string& type(void) const;
81  const std::string& name(void) const;
82  const double& solidangle(void) const;
83  void type(const std::string& type);
84  void name(const std::string& name);
85  void solidangle(const double& solidangle);
86 
87 protected:
88  // Protected methods
89  void init_members(void);
90  void copy_members(const GSkyRegion& region);
91  void free_members(void);
92 
93  // Protected members
94  std::string m_type; //!< Type of the region (circle, rectangle,...)
95  std::string m_name; //!< Name of the region
96  double m_solid; //!< Solid angle subtended by the region (sr)
97 };
98 
99 
100 /***********************************************************************//**
101  * @brief Return region name
102  *
103  * @return Region name
104  *
105  * Returns the region name.
106  ***************************************************************************/
107 inline
108 const std::string& GSkyRegion::name(void) const
109 {
110  return (m_name);
111 }
112 
113 
114 /***********************************************************************//**
115  * @brief Set region name
116  *
117  * @param[in] name Region name.
118  *
119  * Sets the region name.
120  ***************************************************************************/
121 inline
122 void GSkyRegion::name(const std::string& name)
123 {
124  m_name = name;
125  return;
126 }
127 
128 
129 /***********************************************************************//**
130  * @brief Return region type
131  *
132  * @return Region type
133  *
134  * Returns the region type.
135  ***************************************************************************/
136 inline
137 const std::string& GSkyRegion::type(void) const
138 {
139  return (m_type);
140 }
141 
142 
143 /***********************************************************************//**
144  * @brief Set region type
145  *
146  * @param[in] type Region type.
147  *
148  * Sets the region type.
149  ***************************************************************************/
150 inline
151 void GSkyRegion::type(const std::string& type)
152 {
153  m_type = type;
154  return;
155 }
156 
157 
158 /***********************************************************************//**
159  * @brief Return solid angle of region
160  *
161  * @return Solid angle of region.
162  *
163  * Returns the solid angle subtended by the region (in steradians).
164  ***************************************************************************/
165 inline
166 const double& GSkyRegion::solidangle(void) const
167 {
168  return (m_solid);
169 }
170 
171 
172 /***********************************************************************//**
173  * @brief Set solid angle of region
174  *
175  * @param[in] solidangle Solid angle of region (in steradians).
176  *
177  * Sets the solid angle subtended by the region (in steradians).
178  ***************************************************************************/
179 inline
180 void GSkyRegion::solidangle(const double& solidangle)
181 {
183  return;
184 }
185 
186 #endif /* GSKYREGION_HPP */
virtual GSkyRegion * clone(void) const =0
Clones object.
double m_solid
Solid angle subtended by the region (sr)
Definition: GSkyRegion.hpp:96
void copy_members(const GSkyRegion &region)
Copy class members.
Definition: GSkyRegion.cpp:153
virtual ~GSkyRegion(void)
Destructor.
Definition: GSkyRegion.cpp:84
void free_members(void)
Delete class members.
Definition: GSkyRegion.cpp:168
void init_members(void)
Initialise class members.
Definition: GSkyRegion.cpp:136
const double & solidangle(void) const
Return solid angle of region.
Definition: GSkyRegion.hpp:166
const std::string & type(void) const
Return region type.
Definition: GSkyRegion.hpp:137
virtual std::string write(void) const =0
Definition of interface for all GammaLib classes.
std::string m_type
Type of the region (circle, rectangle,...)
Definition: GSkyRegion.hpp:94
Sky map pixel class.
Definition: GSkyPixel.hpp:74
const std::string & name(void) const
Return region name.
Definition: GSkyRegion.hpp:108
virtual std::string print(const GChatter &chatter=NORMAL) const =0
Print content of object.
Abstract interface for the sky region class.
Definition: GSkyRegion.hpp:57
virtual bool contains(const GSkyDir &dir) const =0
std::string m_name
Name of the region.
Definition: GSkyRegion.hpp:95
Interface class for all GammaLib classes.
Definition: GBase.hpp:52
virtual GSkyRegion & operator=(const GSkyRegion &region)
Assignment operator.
Definition: GSkyRegion.cpp:106
virtual void read(const std::string &regstring)=0
virtual std::string classname(void) const =0
Return class name.
GChatter
Definition: GTypemaps.hpp:33
virtual bool overlaps(const GSkyRegion &reg) const =0
virtual void clear(void)=0
Clear object.
GSkyRegion(void)
Void constructor.
Definition: GSkyRegion.cpp:53
Sky direction class.
Definition: GSkyDir.hpp:62