GammaLib  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GModelTemporal.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GModelTemporal.hpp - Abstract temporal model base class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2009-2016 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 GModelTemporal.hpp
23  * @brief Abstract temporal model base class interface definition
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef GMODELTEMPORAL_HPP
28 #define GMODELTEMPORAL_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <vector>
32 #include <string>
33 #include "GBase.hpp"
34 #include "GModelPar.hpp"
35 #include "GTime.hpp"
36 #include "GTimes.hpp"
37 #include "GRan.hpp"
38 
39 
40 /***********************************************************************//**
41  * @class GModelTemporal
42  *
43  * @brief Abstract temporal model base class
44  *
45  * This class implements the temporal component of the factorised model.
46  * The temporal component of the factorised model is supposed to describe the
47  * relative variation of the source flux with respect to the mean value
48  * that is given by the spectral component. Normally, this model will have
49  * a mean value of 1.
50  ***************************************************************************/
51 class GModelTemporal : public GBase {
52 
53 public:
54  // Constructors and destructors
55  GModelTemporal(void);
56  GModelTemporal(const GModelTemporal& model);
57  virtual ~GModelTemporal(void);
58 
59  // Operators
60  virtual GModelTemporal& operator=(const GModelTemporal& model);
61  virtual GModelPar& operator[](const int& index);
62  virtual const GModelPar& operator[](const int& index) const;
63  virtual GModelPar& operator[](const std::string& name);
64  virtual const GModelPar& operator[](const std::string& name) const;
65 
66  // Virtual methods
67  virtual void clear(void) = 0;
68  virtual GModelTemporal* clone(void) const = 0;
69  virtual std::string classname(void) const = 0;
70  virtual std::string type(void) const = 0;
71  virtual double eval(const GTime& srcTime,
72  const bool& gradients = false) const = 0;
73  virtual GTimes mc(const double& rate, const GTime& tmin,
74  const GTime& tmax, GRan& ran) const = 0;
75  virtual void read(const GXmlElement& xml) = 0;
76  virtual void write(GXmlElement& xml) const = 0;
77  virtual std::string print(const GChatter& chatter = NORMAL) const = 0;
78 
79  // Methods
80  GModelPar& at(const int& index);
81  const GModelPar& at(const int& index) const;
82  bool has_par(const std::string& name) const;
83  int size(void) const;
84  void autoscale(void);
85 
86 protected:
87  // Protected methods
88  void init_members(void);
89  void copy_members(const GModelTemporal& model);
90  void free_members(void);
91 
92  // Proteced members
93  std::vector<GModelPar*> m_pars; //!< Parameter pointers
94 };
95 
96 
97 /***********************************************************************//**
98  * @brief Returns model parameter
99  *
100  * @param[in] index Parameter index [0,...,size()-1].
101  * @return Model parameter.
102  *
103  * Returns model parameter without @p index range checking.
104  ***************************************************************************/
105 inline
107 {
108  return *(m_pars[index]);
109 }
110 
111 
112 /***********************************************************************//**
113  * @brief Returns model parameter (const version)
114  *
115  * @param[in] index Parameter index [0,...,size()-1].
116  * @return Model parameter.
117  *
118  * Returns model parameter without @p index range checking.
119  ***************************************************************************/
120 inline
121 const GModelPar& GModelTemporal::operator[](const int& index) const
122 {
123  return *(m_pars[index]);
124 }
125 
126 
127 /***********************************************************************//**
128  * @brief Return number of parameters
129  *
130  * @return Number of parameters in temporal model component.
131  *
132  * Returns the number of parameters in the temporal model component.
133  ***************************************************************************/
134 inline
135 int GModelTemporal::size(void) const
136 {
137  return (int)m_pars.size();
138 }
139 
140 #endif /* GMODELTEMPORAL_HPP */
virtual ~GModelTemporal(void)
Destructor.
virtual GTimes mc(const double &rate, const GTime &tmin, const GTime &tmax, GRan &ran) const =0
std::vector< GModelPar * > m_pars
Parameter pointers.
Random number generator class definition.
Abstract temporal model base class.
bool has_par(const std::string &name) const
Checks if parameter name exists.
virtual std::string print(const GChatter &chatter=NORMAL) const =0
Print content of object.
Definition of interface for all GammaLib classes.
XML element node class.
Definition: GXmlElement.hpp:48
virtual void write(GXmlElement &xml) const =0
Random number generator class.
Definition: GRan.hpp:44
Time class.
Definition: GTime.hpp:55
Time container class definition.
void autoscale(void)
Autoscale parameters.
Time container class.
Definition: GTimes.hpp:45
Model parameter class interface definition.
Model parameter class.
Definition: GModelPar.hpp:87
GModelPar & at(const int &index)
Returns model parameter.
Interface class for all GammaLib classes.
Definition: GBase.hpp:52
int size(void) const
Return number of parameters.
GChatter
Definition: GTypemaps.hpp:33
virtual void read(const GXmlElement &xml)=0
virtual double eval(const GTime &srcTime, const bool &gradients=false) const =0
virtual std::string classname(void) const =0
Return class name.
GModelTemporal(void)
Void constructor.
virtual std::string type(void) const =0
virtual GModelPar & operator[](const int &index)
Returns model parameter.
virtual GModelTemporal & operator=(const GModelTemporal &model)
Assignment operator.
void copy_members(const GModelTemporal &model)
Copy class members.
virtual GModelTemporal * clone(void) const =0
Clones object.
void init_members(void)
Initialise class members.
virtual void clear(void)=0
Clear object.
Time class interface definition.
void free_members(void)
Delete class members.