GSkyRegion.hpp
1 |
/***************************************************************************
|
---|---|
2 |
* GSkyRegion.hpp - Abstract virtual sky region base class *
|
3 |
* ----------------------------------------------------------------------- *
|
4 |
* copyright (C) 2009-2013 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 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 |
#include "GXmlElement.hpp" |
35 |
|
36 |
|
37 |
/***********************************************************************//** |
38 |
* @class GSkyRegion
|
39 |
*
|
40 |
* @brief Abstract interface for the sky region class
|
41 |
*
|
42 |
* This class provides an abstract interface for a sky region. The sky region
|
43 |
* is defined by an array of parameters, the meaning of which is specific
|
44 |
* to the derived class where the region type or shape is defined. The
|
45 |
* parameters are GModelPar objects for convenience.
|
46 |
*
|
47 |
* The class holds several properties such as solid angle subtended by the
|
48 |
* region and computed through internal method compute_solid().
|
49 |
*
|
50 |
* To be clarified:
|
51 |
* - Do we want a member relating the region to an observation run ?
|
52 |
* - Constructor and read/write using XML may not be needed if we use DS9 region file format ?
|
53 |
* - Replace GModelPar by double for the parameters (GModelPar is overkill) ?
|
54 |
*
|
55 |
***************************************************************************/
|
56 |
class GSkyRegion : public GBase { |
57 |
|
58 |
public:
|
59 |
// Constructors and destructors
|
60 |
GSkyRegion(void);
|
61 |
GSkyRegion(const GSkyRegion& region);
|
62 |
explicit GSkyRegion(const GXmlElement& xml); |
63 |
virtual ~GSkyRegion(void); |
64 |
|
65 |
// Operators
|
66 |
virtual GSkyRegion& operator=(const GSkyRegion& region); |
67 |
virtual GModelPar* operator[](const int& index); |
68 |
virtual const GModelPar* operator[](const int& index) const; |
69 |
virtual GModelPar* operator[](const std::string& name); |
70 |
virtual const GModelPar* operator[](const std::string& name) const; |
71 |
|
72 |
// Pure virtual methods
|
73 |
virtual void clear(void) = 0; |
74 |
virtual GSkyRegion* clone(void) const = 0; |
75 |
virtual std::string type(void) const = 0; |
76 |
virtual void read(const GXmlElement& xml) = 0; |
77 |
virtual void write(GXmlElement& xml) const = 0; |
78 |
virtual std::string print(const GChatter& chatter = NORMAL) const = 0; |
79 |
|
80 |
// Implemented methods
|
81 |
int size(void) const; |
82 |
bool haspar(const std::string& name) const; |
83 |
std::string ids(void) const; |
84 |
void ids(const std::string& ids); |
85 |
|
86 |
protected:
|
87 |
// Protected methods
|
88 |
void init_members(void); |
89 |
void copy_members(const GSkyRegion& region); |
90 |
void free_members(void); |
91 |
std::string print_attributes(void) const; |
92 |
void compute_solid(void); |
93 |
|
94 |
// Protected members
|
95 |
std::string m_type; //!< Type of the region |
96 |
std::vector<std::string> m_id; //!< Identifier of the observation to which region applies |
97 |
std::vector<GModelPar> m_pars; //!< Pointers to all region parameters
|
98 |
double m_solid; //!< Solid angle subtended by the region |
99 |
}; |
100 |
|
101 |
|
102 |
/***********************************************************************//** |
103 |
* @brief Returns reference to region parameter by index
|
104 |
*
|
105 |
* @param[in] index Parameter index [0,...,size()-1].
|
106 |
* @return Reference to region parameter.
|
107 |
*
|
108 |
* Returns a reference to the region parameter of the specified @p index.
|
109 |
***************************************************************************/
|
110 |
inline
|
111 |
double GSkyRegion::operator[](const int& index) |
112 |
{ |
113 |
// Return reference
|
114 |
return *(m_pars[index]);
|
115 |
} |
116 |
|
117 |
|
118 |
/***********************************************************************//** |
119 |
* @brief Returns reference to region parameter by index (const version)
|
120 |
*
|
121 |
* @param[in] index Parameter index [0,...,size()-1].
|
122 |
* @return Const reference to region parameter.
|
123 |
*
|
124 |
* Returns a const reference to the region parameter of the specified
|
125 |
***************************************************************************/
|
126 |
inline
|
127 |
const double GSkyRegion::operator[](const int& index) const |
128 |
{ |
129 |
// Return reference
|
130 |
return *(m_pars[index]);
|
131 |
} |
132 |
|
133 |
|
134 |
/***********************************************************************//** |
135 |
* @brief Return number of parameters in region
|
136 |
*
|
137 |
* @return Number of parameters in region.
|
138 |
*
|
139 |
* Returns the number of parameters in the region.
|
140 |
***************************************************************************/
|
141 |
inline
|
142 |
int GSkyRegion::size(void) const |
143 |
{ |
144 |
return (m_pars.size());
|
145 |
} |
146 |
|
147 |
#endif /* GSKYREGION_HPP */ |