GammaLib  2.1.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GModelSpectralTablePars.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GModelSpectralTablePars.hpp - Spectral table model par container 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 GModelSpectralTablePars.hpp
23  * @brief Spectral table model parameter container class definition
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef GMODELSPECTRALTABLEPARS_HPP
28 #define GMODELSPECTRALTABLEPARS_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <vector>
32 #include <string>
33 #include "GContainer.hpp"
35 
36 /* __ Forward declarations _______________________________________________ */
37 
38 
39 /***********************************************************************//**
40  * @class GModelSpectralTablePars
41  *
42  * @brief Spectral table model parameter container class
43  ***************************************************************************/
45 
46 public:
47  // Constructors and destructors
50  virtual ~GModelSpectralTablePars(void);
51 
52  // Operators
54  GModelSpectralTablePar* operator[](const int& index);
55  const GModelSpectralTablePar* operator[](const int& index) const;
56  GModelSpectralTablePar* operator[](const std::string& name);
57  const GModelSpectralTablePar* operator[](const std::string& name) const;
58 
59  // Implemented pure virtual base class methods
60  void clear(void);
61  GModelSpectralTablePars* clone(void) const;
62  std::string classname(void) const;
63  GModelSpectralTablePar* at(const int& index);
64  const GModelSpectralTablePar* at(const int& index) const;
65  int size(void) const;
66  bool is_empty(void) const;
67  GModelSpectralTablePar* set(const int& index,
68  const GModelSpectralTablePar& par);
69  GModelSpectralTablePar* set(const std::string& name,
70  const GModelSpectralTablePar& par);
72  GModelSpectralTablePar* insert(const int& index,
73  const GModelSpectralTablePar& par);
74  GModelSpectralTablePar* insert(const std::string& name,
75  const GModelSpectralTablePar& par);
76  void remove(const int& index);
77  void remove(const std::string& name);
78  void reserve(const int& num);
79  void extend(const GModelSpectralTablePars& pars);
80  bool contains(const std::string& name) const;
81  std::string print(const GChatter& chatter = NORMAL) const;
82 
83 protected:
84  // Protected methods
85  void init_members(void);
86  void copy_members(const GModelSpectralTablePars& model);
87  void free_members(void);
88  int get_index(const std::string& name) const;
89 
90  // Proteced members
91  std::vector<GModelSpectralTablePar*> m_pars; //!< List of parameters
92 };
93 
94 
95 /***********************************************************************//**
96  * @brief Return class name
97  *
98  * @return String containing the class name ("GModelSpectralTablePars").
99  ***************************************************************************/
100 inline
101 std::string GModelSpectralTablePars::classname(void) const
102 {
103  return ("GModelSpectralTablePars");
104 }
105 
106 
107 /***********************************************************************//**
108  * @brief Return pointer to table model parameter
109  *
110  * @param[in] index Table model parameter index [0,...,size()-1].
111  *
112  * Returns a pointer to the table model parameter with the specified
113  * @p index.
114  ***************************************************************************/
115 inline
117 {
118  return (m_pars[index]);
119 }
120 
121 
122 /***********************************************************************//**
123  * @brief Return pointer to table model parameter (const version)
124  *
125  * @param[in] index Table model parameter index [0,...,size()-1].
126  *
127  * Returns a const pointer to the table model parameter with the specified
128  * @p index.
129  ***************************************************************************/
130 inline
132 {
133  return (m_pars[index]);
134 }
135 
136 
137 /***********************************************************************//**
138  * @brief Return pointer to table model parameter
139  *
140  * @param[in] name Table model parameter name.
141  *
142  * Returns a pointer to the table model parameter with the specified @p name.
143  ***************************************************************************/
144 inline
146 {
147  return const_cast<GModelSpectralTablePar*>(static_cast<const GModelSpectralTablePars&>(*this)[name]);
148 }
149 
150 
151 /***********************************************************************//**
152  * @brief Return number of table model parameters in container
153  *
154  * @return Number of table model parameters in container.
155  *
156  * Returns the number of table model parameters in the model container.
157  ***************************************************************************/
158 inline
160 {
161  return (int)m_pars.size();
162 }
163 
164 
165 /***********************************************************************//**
166  * @brief Signals if there are no table model parameters in container
167  *
168  * @return True if container is empty, false otherwise.
169  *
170  * Signals if the table model parameters container does not contain any table
171  * model parameter.
172  ***************************************************************************/
173 inline
175 {
176  return (m_pars.empty());
177 }
178 
179 
180 /***********************************************************************//**
181  * @brief Reserves space for table model parameters in container
182  *
183  * @param[in] num Number of table model parameters
184  *
185  * Reserves space for @p num table model parameters in the container.
186  ***************************************************************************/
187 inline
189 {
190  m_pars.reserve(num);
191  return;
192 }
193 
194 #endif /* GMODELSPECTRALTABLEPARS_HPP */
int get_index(const std::string &name) const
Return parameter index by name.
GModelSpectralTablePar * append(const GModelSpectralTablePar &par)
Append table model parameter to container.
std::vector< GModelSpectralTablePar * > m_pars
List of parameters.
void init_members(void)
Initialise class members.
void extend(const GModelSpectralTablePars &pars)
Append table model parameter container.
Spectral table model parameter container class.
GModelSpectralTablePar * at(const int &index)
Return pointer to table model parameter.
GModelSpectralTablePar * set(const int &index, const GModelSpectralTablePar &par)
Set table model parameter in container.
Spectral table model parameter class definition.
GChatter
Definition: GTypemaps.hpp:33
int size(void) const
Return number of table model parameters in container.
GModelSpectralTablePar * operator[](const int &index)
Return pointer to table model parameter.
void copy_members(const GModelSpectralTablePars &model)
Copy class members.
virtual ~GModelSpectralTablePars(void)
Destructor.
std::string classname(void) const
Return class name.
void clear(void)
Clear table model parameters.
bool contains(const std::string &name) const
Signals if table model parameter exists.
void free_members(void)
Delete class members.
GModelSpectralTablePars & operator=(const GModelSpectralTablePars &pars)
Assignment operator.
bool is_empty(void) const
Signals if there are no table model parameters in container.
Definition of interface for container classes.
void reserve(const int &num)
Reserves space for table model parameters in container.
GModelSpectralTablePar * insert(const int &index, const GModelSpectralTablePar &par)
Insert table model parameter into container.
GModelSpectralTablePars * clone(void) const
Clone table model parameters.
GModelSpectralTablePars(void)
Void constructor.
Spectral table model parameter class.
Interface class for container classes.
Definition: GContainer.hpp:52
std::string print(const GChatter &chatter=NORMAL) const
Print table model parameters.