GammaLib  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GSource.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GSource.hpp - Source class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2012-2014 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 GSource.hpp
23  * @brief Source class definition
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef GSOURCE_HPP
28 #define GSOURCE_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <string>
32 #include "GBase.hpp"
33 #include "GModelSpatial.hpp"
34 #include "GEnergy.hpp"
35 #include "GTime.hpp"
36 
37 
38 /***********************************************************************//**
39  * @class GSource
40  *
41  * @brief Class that handles gamma-ray sources
42  *
43  * The GSource class stores the physical attributes of a gamma-ray source,
44  * which is the distribution of photon arrival directions in form of a
45  * spatial source model, the photon energy, and the photon arrival time.
46  * The class is very similar to the GPhoton class, yet instead of a given
47  * photon arrival direction it contains a spatial model pointer. Note that
48  * the class does not allocate or deallocate the spatial model pointer,
49  * it just is a carrier of a pointer which is handled outside the class.
50  *
51  * Each source also has a name so that it can be identified.
52  ***************************************************************************/
53 class GSource : public GBase {
54 
55 public:
56  // Constructors and destructors
57  GSource(void);
58  GSource(const std::string& name, GModelSpatial* model,
59  const GEnergy& energy, const GTime& time);
60  GSource(const GSource& src);
61  virtual ~GSource(void);
62 
63  // Operators
64  GSource& operator=(const GSource& src);
65 
66  // Methods
67  void clear(void);
68  GSource* clone(void) const;
69  std::string classname(void) const;
70  const std::string& name(void) const;
71  const GModelSpatial* model(void) const;
72  const GEnergy& energy(void) const;
73  const GTime& time(void) const;
74  void name(const std::string& name);
75  void model(GModelSpatial* model);
76  void energy(const GEnergy& energy);
77  void time(const GTime& time);
78  std::string print(const GChatter& chatter = NORMAL) const;
79 
80 protected:
81  // Protected methods
82  void init_members(void);
83  void copy_members(const GSource& src);
84  void free_members(void);
85 
86  // Protected data members
87  std::string m_name; //!< Source name
88  GModelSpatial* m_model; //!< Spatial model
89  GEnergy m_energy; //!< Photon energy
90  GTime m_time; //!< Photon arrival time
91 };
92 
93 
94 /***********************************************************************//**
95  * @brief Return class name
96  *
97  * @return String containing the class name ("GSource").
98  ***************************************************************************/
99 inline
100 std::string GSource::classname(void) const
101 {
102  return ("GSource");
103 }
104 
105 
106 /***********************************************************************//**
107  * @brief Return model name
108  *
109  * @return Model name.
110  *
111  * Returns the model name.
112  ***************************************************************************/
113 inline
114 const std::string& GSource::name(void) const
115 {
116  return m_name;
117 }
118 
119 
120 /***********************************************************************//**
121  * @brief Return spatial model component
122  *
123  * @return Pointer to spatial model component.
124  *
125  * Returns spatial model component.
126  ***************************************************************************/
127 inline
128 const GModelSpatial* GSource::model(void) const
129 {
130  return m_model;
131 }
132 
133 
134 /***********************************************************************//**
135  * @brief Return photon energy
136  *
137  * @return Photon energy.
138  *
139  * Returns photon energy.
140  ***************************************************************************/
141 inline
142 const GEnergy& GSource::energy(void) const
143 {
144  return m_energy;
145 }
146 
147 
148 /***********************************************************************//**
149  * @brief Return photon arrival time
150  *
151  * @return Photon arrival time.
152  *
153  * Returns the photon arrival time.
154  ***************************************************************************/
155 inline
156 const GTime& GSource::time(void) const
157 {
158  return m_time;
159 }
160 
161 
162 /***********************************************************************//**
163  * @brief Set model name
164  *
165  * @param[in] name Model name.
166  *
167  * Sets the model name.
168  ***************************************************************************/
169 inline
170 void GSource::name(const std::string& name)
171 {
172  m_name = name;
173  return;
174 }
175 
176 
177 /***********************************************************************//**
178  * @brief Set spatial model component
179  *
180  * @param[in] model Spatial model component.
181  *
182  * Sets the spatial model component.
183  ***************************************************************************/
184 inline
186 {
187  m_model = model;
188  return;
189 }
190 
191 
192 /***********************************************************************//**
193  * @brief Set photon energy
194  *
195  * @param[in] energy Photon energy.
196  *
197  * Sets the photon energy.
198  ***************************************************************************/
199 inline
200 void GSource::energy(const GEnergy& energy)
201 {
202  m_energy = energy;
203  return;
204 }
205 
206 
207 /***********************************************************************//**
208  * @brief Set photon arrival time
209  *
210  * @param[in] time Photon arrival time.
211  *
212  * Sets the photon arrival time.
213  ***************************************************************************/
214 inline
215 void GSource::time(const GTime& time)
216 {
217  m_time = time;
218  return;
219 }
220 
221 #endif /* GSOURCE_HPP */
GSource * clone(void) const
Clone object.
Definition: GSource.cpp:182
std::string m_name
Source name.
Definition: GSource.hpp:87
Energy value class definition.
std::string classname(void) const
Return class name.
Definition: GSource.hpp:100
Definition of interface for all GammaLib classes.
Abstract spatial model base class interface definition.
Time class.
Definition: GTime.hpp:55
void free_members(void)
Delete class members.
Definition: GSource.cpp:266
const std::string & name(void) const
Return model name.
Definition: GSource.hpp:114
virtual ~GSource(void)
Destructor.
Definition: GSource.cpp:112
Interface class for all GammaLib classes.
Definition: GBase.hpp:52
const GTime & time(void) const
Return photon arrival time.
Definition: GSource.hpp:156
GChatter
Definition: GTypemaps.hpp:33
GSource & operator=(const GSource &src)
Assignment operator.
Definition: GSource.cpp:134
const GModelSpatial * model(void) const
Return spatial model component.
Definition: GSource.hpp:128
const GEnergy & energy(void) const
Return photon energy.
Definition: GSource.hpp:142
GSource(void)
Void constructor.
Definition: GSource.cpp:54
GTime m_time
Photon arrival time.
Definition: GSource.hpp:90
void copy_members(const GSource &src)
Copy class members.
Definition: GSource.cpp:250
void init_members(void)
Initialise class members.
Definition: GSource.cpp:232
void clear(void)
Clear instance.
Definition: GSource.cpp:164
Abstract spatial model base class.
GModelSpatial * m_model
Spatial model.
Definition: GSource.hpp:88
Class that handles gamma-ray sources.
Definition: GSource.hpp:53
std::string print(const GChatter &chatter=NORMAL) const
Print source.
Definition: GSource.cpp:195
Time class interface definition.
GEnergy m_energy
Photon energy.
Definition: GSource.hpp:89
Class that handles energies in a unit independent way.
Definition: GEnergy.hpp:48