GammaLib  2.1.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GModelSpectralTablePar.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GModelSpectralTablePar.hpp - Spectral table model parameter class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2019-2020 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 GModelSpectralTablePar.hpp
23  * @brief Spectral table model parameter class definition
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef GMODELSPECTRALTABLEPAR_HPP
28 #define GMODELSPECTRALTABLEPAR_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <string>
32 #include "GBase.hpp"
33 #include "GModelPar.hpp"
34 #include "GNodeArray.hpp"
35 
36 /* __ Forward declarations _______________________________________________ */
37 
38 
39 /***********************************************************************//**
40  * @class GModelSpectralTablePar
41  *
42  * @brief Spectral table model parameter class
43  ***************************************************************************/
44 class GModelSpectralTablePar : public GBase {
45 
46 public:
47  // Constructors and destructors
50  const std::vector<double>& values);
52  virtual ~GModelSpectralTablePar(void);
53 
54  // Operators
56 
57  // Methods
58  void clear(void);
59  GModelSpectralTablePar* clone(void) const;
60  std::string classname(void) const;
61  int size(void) const;
62  bool is_empty(void) const;
63  GModelPar& par(void);
64  const GModelPar& par(void) const;
65  const GNodeArray& values(void) const;
66  const int& method(void) const;
67  void method(const int& method);
68  std::string print(const GChatter& chatter = NORMAL) const;
69 
70 protected:
71  // Protected methods
72  void init_members(void);
73  void copy_members(const GModelSpectralTablePar& par);
74  void free_members(void);
75 
76  // Protected members
77  GModelPar m_par; //!< Model parameter
78  GNodeArray m_values; //!< Parameter values
79  int m_method; //!< Interpolation method (0: linear, 1: logarithmic)
80 };
81 
82 
83 /***********************************************************************//**
84  * @brief Return class name
85  *
86  * @return String containing the class name ("GModelSpectralTablePar").
87  ***************************************************************************/
88 inline
89 std::string GModelSpectralTablePar::classname(void) const
90 {
91  return ("GModelSpectralTablePar");
92 }
93 
94 
95 /***********************************************************************//**
96  * @brief Return number of table model parameter values
97  *
98  * @return Number of table model parameter values.
99  *
100  * Returns the number of table model parameter values.
101  ***************************************************************************/
102 inline
104 {
105  return (m_values.size());
106 }
107 
108 
109 /***********************************************************************//**
110  * @brief Signals if there are no table model parameter values
111  *
112  * @return True if there are no table model parameter values, false otherwise.
113  *
114  * Signals if there are no table model parameter values.
115  ***************************************************************************/
116 inline
118 {
119  return (m_values.is_empty());
120 }
121 
122 
123 /***********************************************************************//**
124  * @brief Return reference to table model parameter
125  *
126  * @return Reference to table model parameter.
127  ***************************************************************************/
128 inline
130 {
131  return m_par;
132 }
133 
134 
135 /***********************************************************************//**
136  * @brief Return reference to table model parameter (const version)
137  *
138  * @return Reference to table model parameter.
139  ***************************************************************************/
140 inline
142 {
143  return m_par;
144 }
145 
146 
147 /***********************************************************************//**
148  * @brief Return reference to table model parameter values as node array
149  *
150  * @return Reference to table model parameter values as node array.
151  ***************************************************************************/
152 inline
154 {
155  return m_values;
156 }
157 
158 
159 /***********************************************************************//**
160  * @brief Return reference to table model parameter interpolation method
161  *
162  * @return Interpolation method (0: linear, 1: logarithmic).
163  ***************************************************************************/
164 inline
165 const int& GModelSpectralTablePar::method(void) const
166 {
167  return m_method;
168 }
169 
170 
171 /***********************************************************************//**
172  * @brief Set table model parameter interpolation method
173  *
174  * @param[in] method Interpolation method (0: linear, 1: logarithmic).
175  ***************************************************************************/
176 inline
177 void GModelSpectralTablePar::method(const int& method)
178 {
179  m_method = method;
180  return;
181 }
182 
183 #endif /* GMODELSPECTRALTABLEPAR_HPP */
int size(void) const
Return number of nodes in node array.
Definition: GNodeArray.hpp:192
std::string classname(void) const
Return class name.
Node array class.
Definition: GNodeArray.hpp:60
int m_method
Interpolation method (0: linear, 1: logarithmic)
GModelPar m_par
Model parameter.
std::string print(const GChatter &chatter=NORMAL) const
Print table model parameter.
GNodeArray m_values
Parameter values.
Definition of interface for all GammaLib classes.
const int & method(void) const
Return reference to table model parameter interpolation method.
GModelSpectralTablePar(void)
Void constructor.
int size(void) const
Return number of table model parameter values.
bool is_empty(void) const
Signals if there are no nodes in node array.
Definition: GNodeArray.hpp:206
Model parameter class interface definition.
Model parameter class.
Definition: GModelPar.hpp:87
Node array class interface definition.
bool is_empty(void) const
Signals if there are no table model parameter values.
Interface class for all GammaLib classes.
Definition: GBase.hpp:52
virtual ~GModelSpectralTablePar(void)
Destructor.
GChatter
Definition: GTypemaps.hpp:33
void free_members(void)
Delete class members.
void init_members(void)
Initialise class members.
void copy_members(const GModelSpectralTablePar &par)
Copy class members.
void clear(void)
Clear table model parameter.
GModelSpectralTablePar * clone(void) const
Clone table model parameter.
const GNodeArray & values(void) const
Return reference to table model parameter values as node array.
GModelPar & par(void)
Return reference to table model parameter.
Spectral table model parameter class.
GModelSpectralTablePar & operator=(const GModelSpectralTablePar &par)
Assignment operator.