GammaLib  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GPhotons.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GPhotons.hpp - Photon container class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2012-2015 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 GPhotons.hpp
23  * @brief Photon container class definition
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef GPHOTONS_HPP
28 #define GPHOTONS_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <string>
32 #include "GContainer.hpp"
33 #include "GPhoton.hpp"
34 
35 
36 /***********************************************************************//**
37  * @class GPhotons
38  *
39  * @brief Photon container class
40  *
41  * This class is a container for photons. Photons are implemented by the
42  * GPhoton class which stores the physical attributes of a photon such as the
43  * photon arrival direction, its energy and its arrival time.
44  ***************************************************************************/
45 class GPhotons : public GContainer {
46 
47 public:
48  // Constructors and destructors
49  GPhotons(void);
50  GPhotons(const GPhotons& photons);
51  virtual ~GPhotons(void);
52 
53  // Operators
54  GPhotons& operator=(const GPhotons& photons);
55  GPhoton& operator[](const int& index);
56  const GPhoton& operator[](const int& index) const;
57 
58  // Methods
59  void clear(void);
60  GPhotons* clone(void) const;
61  std::string classname(void) const;
62  int size(void) const;
63  bool is_empty(void) const;
64  void append(const GPhoton& photon);
65  void insert(const int& index, const GPhoton& photon);
66  void remove(const int& index);
67  void reserve(const int& num);
68  void extend(const GPhotons& photons);
69  std::string print(const GChatter& chatter = NORMAL) const;
70 
71 protected:
72  // Protected methods
73  void init_members(void);
74  void copy_members(const GPhotons& photons);
75  void free_members(void);
76 
77  // Protected data members
78  std::vector<GPhoton> m_photons; //!< List of photons
79 };
80 
81 
82 /***********************************************************************//**
83  * @brief Return class name
84  *
85  * @return String containing the class name ("GPhotons").
86  ***************************************************************************/
87 inline
88 std::string GPhotons::classname(void) const
89 {
90  return ("GPhotons");
91 }
92 
93 
94 /***********************************************************************//**
95  * @brief Return number of photons
96  *
97  * @return Number of photons.
98  ***************************************************************************/
99 inline
100 int GPhotons::size(void) const
101 {
102  return (int)m_photons.size();
103 }
104 
105 
106 /***********************************************************************//**
107  * @brief Signal if there are no photons
108  *
109  * @return True if there are no photons.
110  ***************************************************************************/
111 inline
112 bool GPhotons::is_empty(void) const
113 {
114  return m_photons.empty();
115 }
116 
117 #endif /* GPHOTONS_HPP */
GPhotons * clone(void) const
Clone object.
Definition: GPhotons.cpp:205
bool is_empty(void) const
Signal if there are no photons.
Definition: GPhotons.hpp:112
void init_members(void)
Initialise class members.
Definition: GPhotons.cpp:389
void clear(void)
Clear container.
Definition: GPhotons.cpp:187
Photon container class.
Definition: GPhotons.hpp:45
void extend(const GPhotons &photons)
Append photon container.
Definition: GPhotons.cpp:302
std::vector< GPhoton > m_photons
List of photons.
Definition: GPhotons.hpp:78
Class that handles photons.
Definition: GPhoton.hpp:47
void free_members(void)
Delete class members.
Definition: GPhotons.cpp:417
std::string print(const GChatter &chatter=NORMAL) const
Print photon container information.
Definition: GPhotons.cpp:350
GPhotons(void)
Void constructor.
Definition: GPhotons.cpp:56
GPhotons & operator=(const GPhotons &photons)
Assignment operator.
Definition: GPhotons.cpp:109
GChatter
Definition: GTypemaps.hpp:33
std::string classname(void) const
Return class name.
Definition: GPhotons.hpp:88
Photon class definition.
void copy_members(const GPhotons &photons)
Copy class members.
Definition: GPhotons.cpp:404
void insert(const int &index, const GPhoton &photon)
Insert photon into container.
Definition: GPhotons.cpp:241
void reserve(const int &num)
Reserve memory for photons in container.
Definition: GPhotons.cpp:334
GPhoton & operator[](const int &index)
Return reference to photon.
Definition: GPhotons.cpp:139
void append(const GPhoton &photon)
Append photon to container.
Definition: GPhotons.cpp:219
virtual ~GPhotons(void)
Destructor.
Definition: GPhotons.cpp:87
Definition of interface for container classes.
int size(void) const
Return number of photons.
Definition: GPhotons.hpp:100
Interface class for container classes.
Definition: GContainer.hpp:52