Commit 51e199a2bcb7dd46696bf73a7bea68dfef16cc80
1 parent
610c9292
Add more instrument module template files
Showing
12 changed files
with
1628 additions
and
3 deletions
inst/lat/src/GLATEventList.cpp
| ... | ... | @@ -73,7 +73,7 @@ GLATEventList::GLATEventList(void) : GEventList() |
| 73 | 73 | /***********************************************************************//** |
| 74 | 74 | * @brief File name constructor |
| 75 | 75 | * |
| 76 | - * @param[in] filename Counts cube filename. | |
| 76 | + * @param[in] filename Event list filename. | |
| 77 | 77 | * |
| 78 | 78 | * Construct event list object by loading the events from a FITS file. |
| 79 | 79 | ***************************************************************************/ | ... | ... |
src/template/GXXXEventAtom.cpp
0 → 100644
| 1 | +/*************************************************************************** | |
| 2 | + * GXXXEventAtom.cpp - [INSTRUMENT] event atom class * | |
| 3 | + * ----------------------------------------------------------------------- * | |
| 4 | + * copyright (C) [YEAR] by [AUTHOR] * | |
| 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 GXXXEventAtom.cpp | |
| 23 | + * @brief [INSTRUMENT] event atom class implementation | |
| 24 | + * @author [AUTHOR] | |
| 25 | + */ | |
| 26 | + | |
| 27 | +/* __ Includes ___________________________________________________________ */ | |
| 28 | +#ifdef HAVE_CONFIG_H | |
| 29 | +#include <config.h> | |
| 30 | +#endif | |
| 31 | +#include <string> | |
| 32 | +#include "GXXXEventAtom.hpp" | |
| 33 | +//#include "GTools.hpp" | |
| 34 | + | |
| 35 | +/* __ Method name definitions ____________________________________________ */ | |
| 36 | + | |
| 37 | +/* __ Macros _____________________________________________________________ */ | |
| 38 | + | |
| 39 | +/* __ Coding definitions _________________________________________________ */ | |
| 40 | + | |
| 41 | +/* __ Debug definitions __________________________________________________ */ | |
| 42 | + | |
| 43 | + | |
| 44 | +/*========================================================================== | |
| 45 | + = = | |
| 46 | + = Constructors/destructors = | |
| 47 | + = = | |
| 48 | + ==========================================================================*/ | |
| 49 | + | |
| 50 | +/***********************************************************************//** | |
| 51 | + * @brief Void constructor | |
| 52 | + * | |
| 53 | + * Creates an empty [INSTRUMENT] event atom. | |
| 54 | + ***************************************************************************/ | |
| 55 | +GXXXEventAtom::GXXXEventAtom(void) : GEventAtom() | |
| 56 | +{ | |
| 57 | + // Initialise class members for clean destruction | |
| 58 | + init_members(); | |
| 59 | + | |
| 60 | + // Return | |
| 61 | + return; | |
| 62 | +} | |
| 63 | + | |
| 64 | + | |
| 65 | +/***********************************************************************//** | |
| 66 | + * @brief Copy constructor | |
| 67 | + * | |
| 68 | + * @param[in] atom [INSTRUMENT] event atom. | |
| 69 | + ***************************************************************************/ | |
| 70 | +GXXXEventAtom::GXXXEventAtom(const GXXXEventAtom& atom) : GEventAtom(atom) | |
| 71 | +{ | |
| 72 | + // Initialise class members for clean destruction | |
| 73 | + init_members(); | |
| 74 | + | |
| 75 | + // Copy members | |
| 76 | + copy_members(atom); | |
| 77 | + | |
| 78 | + // Return | |
| 79 | + return; | |
| 80 | +} | |
| 81 | + | |
| 82 | + | |
| 83 | +/***********************************************************************//** | |
| 84 | + * @brief Destructor | |
| 85 | + ***************************************************************************/ | |
| 86 | +GXXXEventAtom::~GXXXEventAtom(void) | |
| 87 | +{ | |
| 88 | + // Free members | |
| 89 | + free_members(); | |
| 90 | + | |
| 91 | + // Return | |
| 92 | + return; | |
| 93 | +} | |
| 94 | + | |
| 95 | + | |
| 96 | +/*========================================================================== | |
| 97 | + = = | |
| 98 | + = Operators = | |
| 99 | + = = | |
| 100 | + ==========================================================================*/ | |
| 101 | + | |
| 102 | +/***********************************************************************//** | |
| 103 | + * @brief Assignment operator | |
| 104 | + * | |
| 105 | + * @param[in] atom [INSTRUMENT] event atom. | |
| 106 | + * @return [INSTRUMENT] event atom. | |
| 107 | + ***************************************************************************/ | |
| 108 | +GXXXEventAtom& GXXXEventAtom::operator=(const GXXXEventAtom& atom) | |
| 109 | +{ | |
| 110 | + // Execute only if object is not identical | |
| 111 | + if (this != &atom) { | |
| 112 | + | |
| 113 | + // Copy base class members | |
| 114 | + this->GEventAtom::operator=(atom); | |
| 115 | + | |
| 116 | + // Free members | |
| 117 | + free_members(); | |
| 118 | + | |
| 119 | + // Initialise private members for clean destruction | |
| 120 | + init_members(); | |
| 121 | + | |
| 122 | + // Copy members | |
| 123 | + copy_members(atom); | |
| 124 | + | |
| 125 | + } // endif: object was not identical | |
| 126 | + | |
| 127 | + // Return this object | |
| 128 | + return *this; | |
| 129 | +} | |
| 130 | + | |
| 131 | + | |
| 132 | +/*========================================================================== | |
| 133 | + = = | |
| 134 | + = Public methods = | |
| 135 | + = = | |
| 136 | + ==========================================================================*/ | |
| 137 | + | |
| 138 | +/***********************************************************************//** | |
| 139 | + * @brief Clear event atom | |
| 140 | + * | |
| 141 | + * Clears [INSTRUMENT] event atom by resetting all class members to an | |
| 142 | + * initial state. Any information that was present before will be lost. | |
| 143 | + ***************************************************************************/ | |
| 144 | +void GXXXEventAtom::clear(void) | |
| 145 | +{ | |
| 146 | + // Free class members (base and derived classes, derived class first) | |
| 147 | + free_members(); | |
| 148 | + this->GEventAtom::free_members(); | |
| 149 | + this->GEvent::free_members(); | |
| 150 | + | |
| 151 | + // Initialise members | |
| 152 | + this->GEvent::init_members(); | |
| 153 | + this->GEventAtom::init_members(); | |
| 154 | + init_members(); | |
| 155 | + | |
| 156 | + // Return | |
| 157 | + return; | |
| 158 | +} | |
| 159 | + | |
| 160 | + | |
| 161 | +/***********************************************************************//** | |
| 162 | + * @brief Clone event atom | |
| 163 | + * | |
| 164 | + * @return Pointer to deep copy of [INSTRUMENT] event atom. | |
| 165 | + ***************************************************************************/ | |
| 166 | +GXXXEventAtom* GXXXEventAtom::clone(void) const | |
| 167 | +{ | |
| 168 | + return new GXXXEventAtom(*this); | |
| 169 | +} | |
| 170 | + | |
| 171 | + | |
| 172 | +/***********************************************************************//** | |
| 173 | + * @brief Print event information | |
| 174 | + * | |
| 175 | + * @param[in] chatter Chattiness. | |
| 176 | + * @return String containing event information. | |
| 177 | + ***************************************************************************/ | |
| 178 | +std::string GXXXEventAtom::print(const GChatter& chatter) const | |
| 179 | +{ | |
| 180 | + // Initialise result string | |
| 181 | + std::string result; | |
| 182 | + | |
| 183 | + // Continue only if chatter is not silent | |
| 184 | + if (chatter != SILENT) { | |
| 185 | + | |
| 186 | + // Append event attributes | |
| 187 | + result.append("Dir="+m_dir.print(chatter)); | |
| 188 | + result.append(" Energy="+m_energy.print(chatter)); | |
| 189 | + result.append(" Time="+m_time.print(chatter)); | |
| 190 | + | |
| 191 | + } // endif: chatter was not silent | |
| 192 | + | |
| 193 | + // Return result | |
| 194 | + return result; | |
| 195 | +} | |
| 196 | + | |
| 197 | + | |
| 198 | +/*========================================================================== | |
| 199 | + = = | |
| 200 | + = Private methods = | |
| 201 | + = = | |
| 202 | + ==========================================================================*/ | |
| 203 | + | |
| 204 | +/***********************************************************************//** | |
| 205 | + * @brief Initialise class members | |
| 206 | + ***************************************************************************/ | |
| 207 | +void GXXXEventAtom::init_members(void) | |
| 208 | +{ | |
| 209 | + // Initialise members | |
| 210 | + m_dir.clear(); | |
| 211 | + m_time.clear(); | |
| 212 | + m_energy.clear(); | |
| 213 | + | |
| 214 | + // Return | |
| 215 | + return; | |
| 216 | +} | |
| 217 | + | |
| 218 | + | |
| 219 | +/***********************************************************************//** | |
| 220 | + * @brief Copy class members | |
| 221 | + * | |
| 222 | + * @param[in] atom [INSTRUMENT] event atom. | |
| 223 | + ***************************************************************************/ | |
| 224 | +void GXXXEventAtom::copy_members(const GXXXEventAtom& atom) | |
| 225 | +{ | |
| 226 | + // Copy members | |
| 227 | + m_dir = atom.m_dir; | |
| 228 | + m_time = atom.m_time; | |
| 229 | + m_energy = atom.m_energy; | |
| 230 | + | |
| 231 | + // Return | |
| 232 | + return; | |
| 233 | +} | |
| 234 | + | |
| 235 | + | |
| 236 | +/***********************************************************************//** | |
| 237 | + * @brief Delete class members | |
| 238 | + ***************************************************************************/ | |
| 239 | +void GXXXEventAtom::free_members(void) | |
| 240 | +{ | |
| 241 | + // Return | |
| 242 | + return; | |
| 243 | +} | ... | ... |
src/template/GXXXEventAtom.hpp
0 → 100644
| 1 | +/*************************************************************************** | |
| 2 | + * GXXXEventAtom.hpp - [INSTRUMENT] event atom class * | |
| 3 | + * ----------------------------------------------------------------------- * | |
| 4 | + * copyright (C) [YEAR] by [AUTHOR] * | |
| 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 GXXXEventAtom.hpp | |
| 23 | + * @brief [INSTRUMENT] event atom class definition | |
| 24 | + * @author [AUTHOR] | |
| 25 | + */ | |
| 26 | + | |
| 27 | +#ifndef GXXXEVENTATOM_HPP | |
| 28 | +#define GXXXEVENTATOM_HPP | |
| 29 | + | |
| 30 | +/* __ Includes ___________________________________________________________ */ | |
| 31 | +#include <iostream> | |
| 32 | +#include "GEventAtom.hpp" | |
| 33 | +#include "GEnergy.hpp" | |
| 34 | +#include "GTime.hpp" | |
| 35 | +#include "GXXXInstDir.hpp" | |
| 36 | + | |
| 37 | +/* __ Forward declarations _______________________________________________ */ | |
| 38 | + | |
| 39 | + | |
| 40 | +/***********************************************************************//** | |
| 41 | + * @class GXXXEventAtom | |
| 42 | + * | |
| 43 | + * @brief [INSTRUMENT] event atom class | |
| 44 | + ***************************************************************************/ | |
| 45 | +class GXXXEventAtom : public GEventAtom { | |
| 46 | + | |
| 47 | + // Friend classes | |
| 48 | + //friend class GXXXEventList; | |
| 49 | + | |
| 50 | +public: | |
| 51 | + // Constructors and destructors | |
| 52 | + GXXXEventAtom(void); | |
| 53 | + GXXXEventAtom(const GXXXEventAtom& atom); | |
| 54 | + virtual ~GXXXEventAtom(void); | |
| 55 | + | |
| 56 | + // Operators | |
| 57 | + GXXXEventAtom& operator=(const GXXXEventAtom& atom); | |
| 58 | + | |
| 59 | + // Implemented pure virtual base class methods | |
| 60 | + void clear(void); | |
| 61 | + GXXXEventAtom* clone(void) const; | |
| 62 | + std::string classname(void) const; | |
| 63 | + const GXXXInstDir& dir(void) const; | |
| 64 | + const GEnergy& energy(void) const; | |
| 65 | + const GTime& time(void) const; | |
| 66 | + std::string print(const GChatter& chatter = NORMAL) const; | |
| 67 | + | |
| 68 | +protected: | |
| 69 | + // Protected methods | |
| 70 | + void init_members(void); | |
| 71 | + void copy_members(const GXXXEventAtom& atom); | |
| 72 | + void free_members(void); | |
| 73 | + | |
| 74 | + // Protected members | |
| 75 | + GXXXInstDir m_dir; //!< Event direction | |
| 76 | + GEnergy m_energy; //!< Event energy | |
| 77 | + GTime m_time; //!< Event time | |
| 78 | +}; | |
| 79 | + | |
| 80 | + | |
| 81 | +/***********************************************************************//** | |
| 82 | + * @brief Return class name | |
| 83 | + * | |
| 84 | + * @return String containing the class name ("GXXXEventAtom"). | |
| 85 | + ***************************************************************************/ | |
| 86 | +inline | |
| 87 | +std::string GXXXEventAtom::classname(void) const | |
| 88 | +{ | |
| 89 | + return ("GXXXEventAtom"); | |
| 90 | +} | |
| 91 | + | |
| 92 | + | |
| 93 | +/***********************************************************************//** | |
| 94 | + * @brief Return event instrument direction | |
| 95 | + * | |
| 96 | + * @return Event instrument direction. | |
| 97 | + * | |
| 98 | + * Returns the direction of the event. | |
| 99 | + * | |
| 100 | + * @todo Specify what actually an event direction is. You instrument may | |
| 101 | + * not be an imaging instrument. | |
| 102 | + ***************************************************************************/ | |
| 103 | +inline | |
| 104 | +const GXXXInstDir& GXXXEventAtom::dir(void) const | |
| 105 | +{ | |
| 106 | + return m_dir; | |
| 107 | +} | |
| 108 | + | |
| 109 | + | |
| 110 | +/***********************************************************************//** | |
| 111 | + * @brief Return event energy | |
| 112 | + * | |
| 113 | + * @return Event energy. | |
| 114 | + * | |
| 115 | + * Returns the reconstructed energy of the photon on the sky. | |
| 116 | + ***************************************************************************/ | |
| 117 | +inline | |
| 118 | +const GEnergy& GXXXEventAtom::energy(void) const | |
| 119 | +{ | |
| 120 | + return m_energy; | |
| 121 | +} | |
| 122 | + | |
| 123 | + | |
| 124 | +/***********************************************************************//** | |
| 125 | + * @brief Return event time | |
| 126 | + * | |
| 127 | + * @return Event time. | |
| 128 | + * | |
| 129 | + * Returns the event triggering time. | |
| 130 | + ***************************************************************************/ | |
| 131 | +inline | |
| 132 | +const GTime& GXXXEventAtom::time(void) const | |
| 133 | +{ | |
| 134 | + return m_time; | |
| 135 | +} | |
| 136 | + | |
| 137 | +#endif /* GXXXEVENTATOM_HPP */ | ... | ... |
src/template/GXXXEventAtom.i
0 → 100644
| 1 | +/*************************************************************************** | |
| 2 | + * GXXXEventAtom.i - [INSTRUMENT] event atom class * | |
| 3 | + * ----------------------------------------------------------------------- * | |
| 4 | + * copyright (C) [YEAR] by [AUTHOR] * | |
| 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 GXXXEventAtom.i | |
| 23 | + * @brief [INSTRUMENT] event atom class definition | |
| 24 | + * @author [AUTHOR] | |
| 25 | + */ | |
| 26 | +%{ | |
| 27 | +/* Put headers and other declarations here that are needed for compilation */ | |
| 28 | +#include "GXXXEventAtom.hpp" | |
| 29 | +%} | |
| 30 | + | |
| 31 | + | |
| 32 | +/***********************************************************************//** | |
| 33 | + * @class GXXXEventAtom | |
| 34 | + * | |
| 35 | + * @brief [INSTRUMENT] event atom class | |
| 36 | + ***************************************************************************/ | |
| 37 | +class GXXXEventAtom : public GEventAtom { | |
| 38 | + | |
| 39 | +public: | |
| 40 | + // Constructors and destructors | |
| 41 | + GXXXEventAtom(void); | |
| 42 | + GXXXEventAtom(const GXXXEventAtom& atom); | |
| 43 | + virtual ~GXXXEventAtom(void); | |
| 44 | + | |
| 45 | + // Implemented pure virtual base class methods | |
| 46 | + void clear(void); | |
| 47 | + GXXXEventAtom* clone(void) const; | |
| 48 | + std::string classname(void) const; | |
| 49 | + const GXXXInstDir& dir(void) const; | |
| 50 | + const GEnergy& energy(void) const; | |
| 51 | + const GTime& time(void) const; | |
| 52 | +}; | |
| 53 | + | |
| 54 | + | |
| 55 | +/***********************************************************************//** | |
| 56 | + * @brief GXXXEventAtom class extension | |
| 57 | + ***************************************************************************/ | |
| 58 | +%extend GXXXEventAtom { | |
| 59 | + GXXXEventAtom copy() { | |
| 60 | + return (*self); | |
| 61 | + } | |
| 62 | +}; | ... | ... |
src/template/GXXXEventList.cpp
0 → 100644
| 1 | +/*************************************************************************** | |
| 2 | + * GXXXEventList.cpp - [INSTRUMENT] event list class * | |
| 3 | + * ----------------------------------------------------------------------- * | |
| 4 | + * copyright (C) [YEAR] by [AUTHOR] * | |
| 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 GXXXEventList.hpp | |
| 23 | + * @brief [INSTRUMENT] event list class implementation | |
| 24 | + * @author [AUTHOR] | |
| 25 | + */ | |
| 26 | + | |
| 27 | +/* __ Includes ___________________________________________________________ */ | |
| 28 | +#ifdef HAVE_CONFIG_H | |
| 29 | +#include <config.h> | |
| 30 | +#endif | |
| 31 | +#include "GFits.hpp" | |
| 32 | +#include "GException.hpp" | |
| 33 | +#include "GXXXEventList.hpp" | |
| 34 | + | |
| 35 | +/* __ Method name definitions ____________________________________________ */ | |
| 36 | +#define G_OPERATOR "GXXXEventList::operator[](int&)" | |
| 37 | +#define G_ROI "GXXXEventList::roi(GRoi&)" | |
| 38 | + | |
| 39 | +/* __ Macros _____________________________________________________________ */ | |
| 40 | + | |
| 41 | +/* __ Coding definitions _________________________________________________ */ | |
| 42 | + | |
| 43 | +/* __ Debug definitions __________________________________________________ */ | |
| 44 | + | |
| 45 | + | |
| 46 | +/*========================================================================== | |
| 47 | + = = | |
| 48 | + = Constructors/destructors = | |
| 49 | + = = | |
| 50 | + ==========================================================================*/ | |
| 51 | + | |
| 52 | +/***********************************************************************//** | |
| 53 | + * @brief Void constructor | |
| 54 | + * | |
| 55 | + * Creates an empty [INSTRUMENT] event list. | |
| 56 | + ***************************************************************************/ | |
| 57 | +GXXXEventList::GXXXEventList(void) : GEventList() | |
| 58 | +{ | |
| 59 | + // Initialise class members for clean destruction | |
| 60 | + init_members(); | |
| 61 | + | |
| 62 | + // Return | |
| 63 | + return; | |
| 64 | +} | |
| 65 | + | |
| 66 | + | |
| 67 | +/***********************************************************************//** | |
| 68 | + * @brief File name constructor | |
| 69 | + * | |
| 70 | + * @param[in] filename [INSTRUMENT] event list filename. | |
| 71 | + * | |
| 72 | + * Construct [INSTRUMENT] event list object by loading the events from a | |
| 73 | + * FITS file. | |
| 74 | + ***************************************************************************/ | |
| 75 | +GXXXEventList::GXXXEventList(const GFilename& filename) : GEventList() | |
| 76 | +{ | |
| 77 | + // Initialise members | |
| 78 | + init_members(); | |
| 79 | + | |
| 80 | + // Load event list | |
| 81 | + load(filename); | |
| 82 | + | |
| 83 | + // Return | |
| 84 | + return; | |
| 85 | +} | |
| 86 | + | |
| 87 | + | |
| 88 | +/***********************************************************************//** | |
| 89 | + * @brief Copy constructor | |
| 90 | + * | |
| 91 | + * @param[in] list [INSTRUMENT] event list. | |
| 92 | + ***************************************************************************/ | |
| 93 | +GXXXEventList::GXXXEventList(const GXXXEventList& list) : GEventList(list) | |
| 94 | +{ | |
| 95 | + // Initialise members | |
| 96 | + init_members(); | |
| 97 | + | |
| 98 | + // Copy members | |
| 99 | + copy_members(list); | |
| 100 | + | |
| 101 | + // Return | |
| 102 | + return; | |
| 103 | +} | |
| 104 | + | |
| 105 | + | |
| 106 | +/***********************************************************************//** | |
| 107 | + * @brief Destructor | |
| 108 | + ***************************************************************************/ | |
| 109 | +GXXXEventList::~GXXXEventList(void) | |
| 110 | +{ | |
| 111 | + // Free members | |
| 112 | + free_members(); | |
| 113 | + | |
| 114 | + // Return | |
| 115 | + return; | |
| 116 | +} | |
| 117 | + | |
| 118 | + | |
| 119 | +/*========================================================================== | |
| 120 | + = = | |
| 121 | + = Operators = | |
| 122 | + = = | |
| 123 | + ==========================================================================*/ | |
| 124 | + | |
| 125 | +/***********************************************************************//** | |
| 126 | + * @brief Assignment operator | |
| 127 | + * | |
| 128 | + * @param[in] list [INSTRUMENT] event list. | |
| 129 | + * @return [INSTRUMENT] event list. | |
| 130 | + ***************************************************************************/ | |
| 131 | +GXXXEventList& GXXXEventList::operator=(const GXXXEventList& list) | |
| 132 | +{ | |
| 133 | + // Execute only if object is not identical | |
| 134 | + if (this != &list) { | |
| 135 | + | |
| 136 | + // Copy base class members | |
| 137 | + this->GEventList::operator=(list); | |
| 138 | + | |
| 139 | + // Free members | |
| 140 | + free_members(); | |
| 141 | + | |
| 142 | + // Initialise members | |
| 143 | + init_members(); | |
| 144 | + | |
| 145 | + // Copy members | |
| 146 | + copy_members(list); | |
| 147 | + | |
| 148 | + } // endif: object was not identical | |
| 149 | + | |
| 150 | + // Return this object | |
| 151 | + return *this; | |
| 152 | +} | |
| 153 | + | |
| 154 | + | |
| 155 | +/***********************************************************************//** | |
| 156 | + * @brief [INSTRUMENT] event atom access operator | |
| 157 | + * | |
| 158 | + * @param[in] index Event index [0,...,size()-1]. | |
| 159 | + * @return Pointer to [INSTRUMENT] event atom. | |
| 160 | + * | |
| 161 | + * @exception GException::out_of_range | |
| 162 | + * Event index outside valid range. | |
| 163 | + * | |
| 164 | + * Returns pointer to a [INSTRUMENT] event atom. | |
| 165 | + ***************************************************************************/ | |
| 166 | +GXXXEventAtom* GXXXEventList::operator[](const int& index) | |
| 167 | +{ | |
| 168 | + // Optionally check if the index is valid | |
| 169 | + #if defined(G_RANGE_CHECK) | |
| 170 | + if (index < 0 || index >= size()) { | |
| 171 | + throw GException::out_of_range(G_OPERATOR, "Event index", index, size()); | |
| 172 | + } | |
| 173 | + #endif | |
| 174 | + | |
| 175 | + // Return pointer | |
| 176 | + return (&(m_events[index])); | |
| 177 | +} | |
| 178 | + | |
| 179 | + | |
| 180 | +/***********************************************************************//** | |
| 181 | + * @brief [INSTRUMENT] event atom access operator | |
| 182 | + * | |
| 183 | + * @param[in] index Event index [0,...,size()-1]. | |
| 184 | + * @return Pointer to [INSTRUMENT] event atom. | |
| 185 | + * | |
| 186 | + * @exception GException::out_of_range | |
| 187 | + * Event index outside valid range. | |
| 188 | + * | |
| 189 | + * Returns pointer to a [INSTRUMENT] event atom. | |
| 190 | + ***************************************************************************/ | |
| 191 | +const GXXXEventAtom* GXXXEventList::operator[](const int& index) const | |
| 192 | +{ | |
| 193 | + // Optionally check if the index is valid | |
| 194 | + #if defined(G_RANGE_CHECK) | |
| 195 | + if (index < 0 || index >= size()) { | |
| 196 | + throw GException::out_of_range(G_OPERATOR, "Event index", index, size()); | |
| 197 | + } | |
| 198 | + #endif | |
| 199 | + | |
| 200 | + // Return pointer | |
| 201 | + return (&(m_events[index])); | |
| 202 | +} | |
| 203 | + | |
| 204 | + | |
| 205 | +/*========================================================================== | |
| 206 | + = = | |
| 207 | + = Public methods = | |
| 208 | + = = | |
| 209 | + ==========================================================================*/ | |
| 210 | + | |
| 211 | +/***********************************************************************//** | |
| 212 | + * @brief Clear [INSTRUMENT] event list | |
| 213 | + * | |
| 214 | + * Clears [INSTRUMENT] event list by resetting all class members to an | |
| 215 | + * initial state. Any information that was present before will be lost. | |
| 216 | + ***************************************************************************/ | |
| 217 | +void GXXXEventList::clear(void) | |
| 218 | +{ | |
| 219 | + // Free class members (base and derived classes, derived class first) | |
| 220 | + free_members(); | |
| 221 | + this->GEventList::free_members(); | |
| 222 | + this->GEvents::free_members(); | |
| 223 | + | |
| 224 | + // Initialise members | |
| 225 | + this->GEvents::init_members(); | |
| 226 | + this->GEventList::init_members(); | |
| 227 | + init_members(); | |
| 228 | + | |
| 229 | + // Return | |
| 230 | + return; | |
| 231 | +} | |
| 232 | + | |
| 233 | + | |
| 234 | +/***********************************************************************//** | |
| 235 | + * @brief Clone event list | |
| 236 | + * | |
| 237 | + * @return Pointer to deep copy of [INSTRUMENT] event list. | |
| 238 | + ***************************************************************************/ | |
| 239 | +GXXXEventList* GXXXEventList::clone(void) const | |
| 240 | +{ | |
| 241 | + return new GXXXEventList(*this); | |
| 242 | +} | |
| 243 | + | |
| 244 | + | |
| 245 | +/***********************************************************************//** | |
| 246 | + * @brief Load [INSTRUMENT] events from FITS file | |
| 247 | + * | |
| 248 | + * @param[in] filename [INSTRUMENT] event list FITS file name. | |
| 249 | + * | |
| 250 | + * Loads [INSTRUMENT] events from a FITS file into the event list. | |
| 251 | + ***************************************************************************/ | |
| 252 | +void GXXXEventList::load(const GFilename& filename) | |
| 253 | +{ | |
| 254 | + // Open FITS file | |
| 255 | + GFits fits(filename); | |
| 256 | + | |
| 257 | + // Read event list from FITS file | |
| 258 | + read(fits); | |
| 259 | + | |
| 260 | + // Close FITS file | |
| 261 | + fits.close(); | |
| 262 | + | |
| 263 | + // Return | |
| 264 | + return; | |
| 265 | +} | |
| 266 | + | |
| 267 | + | |
| 268 | +/***********************************************************************//** | |
| 269 | + * @brief Save [INSTRUMENT] events | |
| 270 | + * | |
| 271 | + * @param[in] filename [INSTRUMENT] event list FITS file name. | |
| 272 | + * @param[in] clobber Overwrite existing FITS file? | |
| 273 | + * | |
| 274 | + * Save [INSTRUMENT] events from a FITS file into the event list. | |
| 275 | + ***************************************************************************/ | |
| 276 | +void GXXXEventList::save(const GFilename& filename, | |
| 277 | + const bool& clobber) const | |
| 278 | +{ | |
| 279 | + // Open FITS file | |
| 280 | + GFits fits; | |
| 281 | + | |
| 282 | + // Write events | |
| 283 | + write(fits); | |
| 284 | + | |
| 285 | + // Save events | |
| 286 | + fits.saveto(filename, clobber); | |
| 287 | + | |
| 288 | + // Close FITS file | |
| 289 | + fits.close(); | |
| 290 | + | |
| 291 | + // Return | |
| 292 | + return; | |
| 293 | +} | |
| 294 | + | |
| 295 | + | |
| 296 | +/***********************************************************************//** | |
| 297 | + * @brief Read [INSTRUMENT] events from FITS file. | |
| 298 | + * | |
| 299 | + * @param[in] file FITS file. | |
| 300 | + * | |
| 301 | + * Read the [INSTRUMENT] event list from a FITS file object. | |
| 302 | + * | |
| 303 | + * @todo Implement method. | |
| 304 | + ***************************************************************************/ | |
| 305 | +void GXXXEventList::read(const GFits& file) | |
| 306 | +{ | |
| 307 | + // Clear object | |
| 308 | + clear(); | |
| 309 | + | |
| 310 | + // TODO: You need to implement an interface to the FITS file that stores | |
| 311 | + // your events. Make sure that you read all relevant information. | |
| 312 | + | |
| 313 | + // Return | |
| 314 | + return; | |
| 315 | +} | |
| 316 | + | |
| 317 | + | |
| 318 | +/***********************************************************************//** | |
| 319 | + * @brief Write [INSTRUMENT] event list into FITS file. | |
| 320 | + * | |
| 321 | + * @param[in] file FITS file. | |
| 322 | + * | |
| 323 | + * Write the L[INSTRUMENT]AT event list into FITS file. | |
| 324 | + * | |
| 325 | + * @todo Implement method. | |
| 326 | + ***************************************************************************/ | |
| 327 | +void GXXXEventList::write(GFits& file) const | |
| 328 | +{ | |
| 329 | + // TODO: You need to implement an interface to the FITS file that so | |
| 330 | + // that you can save your events. | |
| 331 | + | |
| 332 | + // Return | |
| 333 | + return; | |
| 334 | +} | |
| 335 | + | |
| 336 | + | |
| 337 | +/***********************************************************************//** | |
| 338 | + * @brief Set region of interest | |
| 339 | + * | |
| 340 | + * @param[in] roi Region of interest. | |
| 341 | + * | |
| 342 | + * @exception GException::invalid_argument | |
| 343 | + * Specified RoI is not a [INSTRUMENT] RoI. | |
| 344 | + * | |
| 345 | + * Sets the region of interest for the observation. | |
| 346 | + ***************************************************************************/ | |
| 347 | +void GXXXEventList::roi(const GRoi& roi) | |
| 348 | +{ | |
| 349 | + // Get pointer on [INSTRUMENT] region of interest | |
| 350 | + const GXXXRoi* xxxroi = dynamic_cast<const GXXXRoi*>(&roi); | |
| 351 | + if (xxxroi == NULL) { | |
| 352 | + std::string cls = std::string(typeid(&roi).name()); | |
| 353 | + std::string msg = "Region of interest of type \""+cls+"\" is " | |
| 354 | + "not a [INSTRUMENT] RoI. Please specify a " | |
| 355 | + "[INSTRUMENT] RoI as argument."; | |
| 356 | + throw GException::invalid_argument(G_ROI, msg); | |
| 357 | + } | |
| 358 | + | |
| 359 | + // Set RoI | |
| 360 | + m_roi = *xxxroi; | |
| 361 | + | |
| 362 | + // Return | |
| 363 | + return; | |
| 364 | +} | |
| 365 | + | |
| 366 | + | |
| 367 | +/***********************************************************************//** | |
| 368 | + * @brief Append event to event list | |
| 369 | + * | |
| 370 | + * @param[in] event Event. | |
| 371 | + * | |
| 372 | + * Appends an event to the end of the event list. | |
| 373 | + ***************************************************************************/ | |
| 374 | +void GXXXEventList::append(const GXXXEventAtom& event) | |
| 375 | +{ | |
| 376 | + // Append event | |
| 377 | + m_events.push_back(event); | |
| 378 | + | |
| 379 | + // Return | |
| 380 | + return; | |
| 381 | +} | |
| 382 | + | |
| 383 | + | |
| 384 | +/***********************************************************************//** | |
| 385 | + * @brief Remove events from event list | |
| 386 | + * | |
| 387 | + * @param[in] index Index from which on events should be removed. | |
| 388 | + * @param[in] number Number of event to remove (default: 1). | |
| 389 | + * | |
| 390 | + * Removes events from the event list. This method does nothing if @p index | |
| 391 | + * points beyond the event list. The method does also gently accept | |
| 392 | + * @p number arguments where @p index + @p number reach beyond the event | |
| 393 | + * list. In that case, all events from event @p index on will be removed. | |
| 394 | + ***************************************************************************/ | |
| 395 | +void GXXXEventList::remove(const int& index, const int& number) | |
| 396 | +{ | |
| 397 | + // Continue only if index is valid | |
| 398 | + if (index < size()) { | |
| 399 | + | |
| 400 | + // Determine number of elements to remove | |
| 401 | + int n_remove = (index + number > size()) ? size() - index : number; | |
| 402 | + | |
| 403 | + // Remove events | |
| 404 | + m_events.erase(m_events.begin() + index, | |
| 405 | + m_events.begin() + index + n_remove); | |
| 406 | + | |
| 407 | + } // endif: index was valid | |
| 408 | + | |
| 409 | + // Return | |
| 410 | + return; | |
| 411 | +} | |
| 412 | + | |
| 413 | + | |
| 414 | +/***********************************************************************//** | |
| 415 | + * @brief Print [INSTRUMENT] event list information | |
| 416 | + * | |
| 417 | + * @param[in] chatter Chattiness. | |
| 418 | + * @return String containing [INSTRUMENT] event list information. | |
| 419 | + ***************************************************************************/ | |
| 420 | +std::string GXXXEventList::print(const GChatter& chatter) const | |
| 421 | +{ | |
| 422 | + // Initialise result string | |
| 423 | + std::string result; | |
| 424 | + | |
| 425 | + // Continue only if chatter is not silent | |
| 426 | + if (chatter != SILENT) { | |
| 427 | + | |
| 428 | + // Append header | |
| 429 | + result.append("=== GXXXEventList ==="); | |
| 430 | + | |
| 431 | + // Append information | |
| 432 | + result.append("\n"+gammalib::parformat("Number of events") + | |
| 433 | + gammalib::str(number())); | |
| 434 | + | |
| 435 | + // Append additional information | |
| 436 | + // TODO: Add code to append any additional information that might | |
| 437 | + // be relevant. | |
| 438 | + | |
| 439 | + } // endif: chatter was not silent | |
| 440 | + | |
| 441 | + // Return result | |
| 442 | + return result; | |
| 443 | +} | |
| 444 | + | |
| 445 | + | |
| 446 | +/*========================================================================== | |
| 447 | + = = | |
| 448 | + = Private methods = | |
| 449 | + = = | |
| 450 | + ==========================================================================*/ | |
| 451 | + | |
| 452 | +/***********************************************************************//** | |
| 453 | + * @brief Initialise class members | |
| 454 | + ***************************************************************************/ | |
| 455 | +void GXXXEventList::init_members(void) | |
| 456 | +{ | |
| 457 | + // Initialise members | |
| 458 | + m_roi.clear(); | |
| 459 | + m_events.clear(); | |
| 460 | + | |
| 461 | + // Return | |
| 462 | + return; | |
| 463 | +} | |
| 464 | + | |
| 465 | + | |
| 466 | +/***********************************************************************//** | |
| 467 | + * @brief Copy class members | |
| 468 | + * | |
| 469 | + * @param[in] list [INSTRUMENT] event list. | |
| 470 | + ***************************************************************************/ | |
| 471 | +void GXXXEventList::copy_members(const GXXXEventList& list) | |
| 472 | +{ | |
| 473 | + // Copy members | |
| 474 | + m_roi = list.m_roi; | |
| 475 | + m_events = list.m_events; | |
| 476 | + | |
| 477 | + // Return | |
| 478 | + return; | |
| 479 | +} | |
| 480 | + | |
| 481 | + | |
| 482 | +/***********************************************************************//** | |
| 483 | + * @brief Delete class members | |
| 484 | + ***************************************************************************/ | |
| 485 | +void GXXXEventList::free_members(void) | |
| 486 | +{ | |
| 487 | + // Return | |
| 488 | + return; | |
| 489 | +} | ... | ... |
src/template/GXXXEventList.hpp
0 → 100644
| 1 | +/*************************************************************************** | |
| 2 | + * GXXXEventList.hpp - [INSTRUMENT] event list class * | |
| 3 | + * ----------------------------------------------------------------------- * | |
| 4 | + * copyright (C) [YEAR] by [AUTHOR] * | |
| 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 GXXXEventList.hpp | |
| 23 | + * @brief [INSTRUMENT] event list class definition | |
| 24 | + * @author [AUTHOR] | |
| 25 | + */ | |
| 26 | + | |
| 27 | +#ifndef GXXXEVENTLIST_HPP | |
| 28 | +#define GXXXEVENTLIST_HPP | |
| 29 | + | |
| 30 | +/* __ Includes ___________________________________________________________ */ | |
| 31 | +#include <string> | |
| 32 | +#include <vector> | |
| 33 | +#include "GEventList.hpp" | |
| 34 | +#include "GXXXEventAtom.hpp" | |
| 35 | +#include "GXXXRoi.hpp" | |
| 36 | + | |
| 37 | +/* __ Forward declarations _______________________________________________ */ | |
| 38 | +class GRoi; | |
| 39 | +class GFits; | |
| 40 | +class GFilename; | |
| 41 | + | |
| 42 | +/* __ Constants __________________________________________________________ */ | |
| 43 | + | |
| 44 | + | |
| 45 | +/***********************************************************************//** | |
| 46 | + * @class GXXXEventList | |
| 47 | + * | |
| 48 | + * @brief [INSTRUMENT] event list class | |
| 49 | + ***************************************************************************/ | |
| 50 | +class GXXXEventList : public GEventList { | |
| 51 | + | |
| 52 | +public: | |
| 53 | + // Constructors and destructors | |
| 54 | + GXXXEventList(void); | |
| 55 | + explicit GXXXEventList(const GFilename& filename); | |
| 56 | + GXXXEventList(const GXXXEventList& list); | |
| 57 | + virtual ~GXXXEventList(void); | |
| 58 | + | |
| 59 | + // Operators | |
| 60 | + virtual GXXXEventList& operator=(const GXXXEventList& list); | |
| 61 | + virtual GXXXEventAtom* operator[](const int& index); | |
| 62 | + virtual const GXXXEventAtom* operator[](const int& index) const; | |
| 63 | + | |
| 64 | + // Implemented pure virtual base class methods | |
| 65 | + virtual void clear(void); | |
| 66 | + virtual GXXXEventList* clone(void) const; | |
| 67 | + virtual std::string classname(void) const; | |
| 68 | + virtual int size(void) const; | |
| 69 | + virtual void load(const GFilename& filename); | |
| 70 | + virtual void save(const GFilename& filename, | |
| 71 | + const bool& clobber = false) const; | |
| 72 | + virtual void read(const GFits& file); | |
| 73 | + virtual void write(GFits& file) const; | |
| 74 | + virtual int number(void) const; | |
| 75 | + virtual void roi(const GRoi& roi); | |
| 76 | + virtual const GXXXRoi& roi(void) const; | |
| 77 | + virtual std::string print(const GChatter& chatter = NORMAL) const; | |
| 78 | + | |
| 79 | + // Other methods | |
| 80 | + void append(const GXXXEventAtom& event); | |
| 81 | + void reserve(const int& number); | |
| 82 | + void remove(const int& index, const int& number = 1); | |
| 83 | + | |
| 84 | +protected: | |
| 85 | + // Protected methods | |
| 86 | + void init_members(void); | |
| 87 | + void copy_members(const GXXXEventList& list); | |
| 88 | + void free_members(void); | |
| 89 | + virtual void set_energies(void); | |
| 90 | + virtual void set_times(void); | |
| 91 | + | |
| 92 | + // Protected members | |
| 93 | + GXXXRoi m_roi; //!< Region of interest | |
| 94 | + std::vector<GXXXEventAtom> m_events; //!< Events | |
| 95 | +}; | |
| 96 | + | |
| 97 | + | |
| 98 | +/***********************************************************************//** | |
| 99 | + * @brief Return class name | |
| 100 | + * | |
| 101 | + * @return String containing the class name ("GXXXEventList"). | |
| 102 | + ***************************************************************************/ | |
| 103 | +inline | |
| 104 | +std::string GXXXEventList::classname(void) const | |
| 105 | +{ | |
| 106 | + return ("GXXXEventList"); | |
| 107 | +} | |
| 108 | + | |
| 109 | + | |
| 110 | +/***********************************************************************//** | |
| 111 | + * @brief Return number of events in list | |
| 112 | + * | |
| 113 | + * @return Number of events in list. | |
| 114 | + ***************************************************************************/ | |
| 115 | +inline | |
| 116 | +int GXXXEventList::size(void) const | |
| 117 | +{ | |
| 118 | + return (int)m_events.size(); | |
| 119 | +} | |
| 120 | + | |
| 121 | + | |
| 122 | +/***********************************************************************//** | |
| 123 | + * @brief Return number of events in list | |
| 124 | + * | |
| 125 | + * @return Number of events in list. | |
| 126 | + ***************************************************************************/ | |
| 127 | +inline | |
| 128 | +int GXXXEventList::number(void) const | |
| 129 | +{ | |
| 130 | + return (int)m_events.size(); | |
| 131 | +} | |
| 132 | + | |
| 133 | + | |
| 134 | +/***********************************************************************//** | |
| 135 | + * @brief Return Region of Interest | |
| 136 | + * | |
| 137 | + * @return Region of Interest. | |
| 138 | + ***************************************************************************/ | |
| 139 | +inline | |
| 140 | +const GXXXRoi& GXXXEventList::roi(void) const | |
| 141 | +{ | |
| 142 | + return m_roi; | |
| 143 | +} | |
| 144 | + | |
| 145 | + | |
| 146 | +/***********************************************************************//** | |
| 147 | + * @brief Reserves space for events | |
| 148 | + * | |
| 149 | + * @param[in] number Number of events. | |
| 150 | + * | |
| 151 | + * Reserves space for a @p number events in the event list. | |
| 152 | + ***************************************************************************/ | |
| 153 | +inline | |
| 154 | +void GXXXEventList::reserve(const int& number) | |
| 155 | +{ | |
| 156 | + m_events.reserve(number); | |
| 157 | + return; | |
| 158 | +} | |
| 159 | + | |
| 160 | + | |
| 161 | +/***********************************************************************//** | |
| 162 | + * @brief Set energies | |
| 163 | + * | |
| 164 | + * Sets energies. | |
| 165 | + ***************************************************************************/ | |
| 166 | +inline | |
| 167 | +void GXXXEventList::set_energies(void) | |
| 168 | +{ | |
| 169 | + return; | |
| 170 | +} | |
| 171 | + | |
| 172 | + | |
| 173 | +/***********************************************************************//** | |
| 174 | + * @brief Set times | |
| 175 | + * | |
| 176 | + * Sets times. | |
| 177 | + ***************************************************************************/ | |
| 178 | +inline | |
| 179 | +void GXXXEventList::set_times(void) | |
| 180 | +{ | |
| 181 | + return; | |
| 182 | +} | |
| 183 | + | |
| 184 | +#endif /* GLATEVENTLIST_HPP */ | ... | ... |
src/template/GXXXEventList.i
0 → 100644
| 1 | +/*************************************************************************** | |
| 2 | + * GXXXEventList.i - [INSTRUMENT] event list class * | |
| 3 | + * ----------------------------------------------------------------------- * | |
| 4 | + * copyright (C) [YEAR] by [AUTHOR] * | |
| 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 GXXXEventList.i | |
| 23 | + * @brief [INSTRUMENT] event list class definition | |
| 24 | + * @author [AUTHOR] | |
| 25 | + */ | |
| 26 | +%{ | |
| 27 | +/* Put headers and other declarations here that are needed for compilation */ | |
| 28 | +#include "GXXXEventList.hpp" | |
| 29 | +#include "GTools.hpp" | |
| 30 | +%} | |
| 31 | + | |
| 32 | + | |
| 33 | +/***********************************************************************//** | |
| 34 | + * @class GXXXEventList | |
| 35 | + * | |
| 36 | + * @brief [INSTRUMENT] event list class | |
| 37 | + ***************************************************************************/ | |
| 38 | +class GXXXEventList : public GEventList { | |
| 39 | + | |
| 40 | +public: | |
| 41 | + // Constructors and destructors | |
| 42 | + GXXXEventList(void); | |
| 43 | + explicit GXXXEventList(const GFilename& filename); | |
| 44 | + GXXXEventList(const GXXXEventList& list); | |
| 45 | + virtual ~GXXXEventList(void); | |
| 46 | + | |
| 47 | + // Implemented pure virtual base class methods | |
| 48 | + virtual void clear(void); | |
| 49 | + virtual GXXXEventList* clone(void) const; | |
| 50 | + virtual std::string classname(void) const; | |
| 51 | + virtual int size(void) const; | |
| 52 | + virtual void load(const GFilename& filename); | |
| 53 | + virtual void save(const GFilename& filename, | |
| 54 | + const bool& clobber = false) const; | |
| 55 | + virtual void read(const GFits& file); | |
| 56 | + virtual void write(GFits& file) const; | |
| 57 | + virtual int number(void) const; | |
| 58 | + virtual void roi(const GRoi& roi); | |
| 59 | + virtual const GXXXRoi& roi(void) const; | |
| 60 | + | |
| 61 | + // Other methods | |
| 62 | + void append(const GXXXEventAtom& event); | |
| 63 | + void reserve(const int& number); | |
| 64 | + void remove(const int& index, const int& number = 1); | |
| 65 | +}; | |
| 66 | + | |
| 67 | + | |
| 68 | +/***********************************************************************//** | |
| 69 | + * @brief GXXXEventList class extension | |
| 70 | + ***************************************************************************/ | |
| 71 | +%extend GXXXEventList { | |
| 72 | + GXXXEventAtom* __getitem__(const int& index) { | |
| 73 | + // Counting from start, e.g. [2] | |
| 74 | + if (index >= 0 && index < self->size()) { | |
| 75 | + return (*self)[index]; | |
| 76 | + } | |
| 77 | + // Counting from end, e.g. [-1] | |
| 78 | + else if (index < 0 && self->size()+index >= 0) { | |
| 79 | + return (*self)[self->size()+index]; | |
| 80 | + } | |
| 81 | + else { | |
| 82 | + throw GException::out_of_range("__getitem__(int)", "Event index", | |
| 83 | + index, self->size()); | |
| 84 | + } | |
| 85 | + } | |
| 86 | + GXXXEventList* __getitem__(PyObject *param) { | |
| 87 | + if (PySlice_Check(param)) { | |
| 88 | + Py_ssize_t start = 0; | |
| 89 | + Py_ssize_t stop = 0; | |
| 90 | + Py_ssize_t step = 0; | |
| 91 | + Py_ssize_t len = self->size(); | |
| 92 | + if (PythonSlice_GetIndices(param, len, &start, &stop, &step) == 0) { | |
| 93 | + GXXXEventList* list = new GXXXEventList; | |
| 94 | + if (step > 0) { | |
| 95 | + for (int i = (int)start; i < (int)stop; i += (int)step) { | |
| 96 | + list->append(*(*self)[i]); | |
| 97 | + } | |
| 98 | + } | |
| 99 | + else { | |
| 100 | + for (int i = (int)start; i > (int)stop; i += (int)step) { | |
| 101 | + list->append(*(*self)[i]); | |
| 102 | + } | |
| 103 | + } | |
| 104 | + return list; | |
| 105 | + } | |
| 106 | + else { | |
| 107 | + throw GException::invalid_argument("__getitem__(PyObject)", | |
| 108 | + "Invalid slice indices"); | |
| 109 | + } | |
| 110 | + } | |
| 111 | + else { | |
| 112 | + throw GException::invalid_argument("__getitem__(PyObject)",""); | |
| 113 | + } | |
| 114 | + } | |
| 115 | + void __setitem__(const int& index, const GXXXEventAtom& event) { | |
| 116 | + // Counting from start, e.g. [2] | |
| 117 | + if (index >= 0 && index < self->size()) { | |
| 118 | + *(*self)[index] = event; | |
| 119 | + } | |
| 120 | + // Counting from end, e.g. [-1] | |
| 121 | + else if (index < 0 && self->size()+index >= 0) { | |
| 122 | + *(*self)[self->size()+index] = event; | |
| 123 | + } | |
| 124 | + else { | |
| 125 | + throw GException::out_of_range("__setitem__(int)", "Event index", | |
| 126 | + index, self->size()); | |
| 127 | + } | |
| 128 | + } | |
| 129 | + GXXXEventList copy() { | |
| 130 | + return (*self); | |
| 131 | + } | |
| 132 | +}; | ... | ... |
src/template/GXXXInstDir.cpp
0 → 100644
| 1 | +/*************************************************************************** | |
| 2 | + * GXXXInstDir.cpp - [INSTRUMENT] instrument direction class * | |
| 3 | + * ----------------------------------------------------------------------- * | |
| 4 | + * copyright (C) [YEAR] by [AUTHOR] * | |
| 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 GXXXInstDir.cpp | |
| 23 | + * @brief [INSTRUMENT] instrument direction class implementation | |
| 24 | + * @author [AUTHOR] | |
| 25 | + */ | |
| 26 | + | |
| 27 | +/* __ Includes ___________________________________________________________ */ | |
| 28 | +#ifdef HAVE_CONFIG_H | |
| 29 | +#include <config.h> | |
| 30 | +#endif | |
| 31 | +#include "GXXXInstDir.hpp" | |
| 32 | + | |
| 33 | +/* __ Method name definitions ____________________________________________ */ | |
| 34 | + | |
| 35 | +/* __ Macros _____________________________________________________________ */ | |
| 36 | + | |
| 37 | +/* __ Coding definitions _________________________________________________ */ | |
| 38 | + | |
| 39 | +/* __ Debug definitions __________________________________________________ */ | |
| 40 | + | |
| 41 | +/* __ Prototypes _________________________________________________________ */ | |
| 42 | + | |
| 43 | +/*========================================================================== | |
| 44 | + = = | |
| 45 | + = Constructors/destructors = | |
| 46 | + = = | |
| 47 | + ==========================================================================*/ | |
| 48 | + | |
| 49 | +/***********************************************************************//** | |
| 50 | + * @brief Void constructor | |
| 51 | + * | |
| 52 | + * Creates an empty [INSTRUMENT] instrument direction. | |
| 53 | + ***************************************************************************/ | |
| 54 | +GXXXInstDir::GXXXInstDir(void) : GInstDir() | |
| 55 | +{ | |
| 56 | + // Initialise class members | |
| 57 | + init_members(); | |
| 58 | + | |
| 59 | + // Return | |
| 60 | + return; | |
| 61 | +} | |
| 62 | + | |
| 63 | + | |
| 64 | +/***********************************************************************//** | |
| 65 | + * @brief Copy constructor | |
| 66 | + * | |
| 67 | + * @param[in] dir [INSTRUMENT] instrument direction. | |
| 68 | + ***************************************************************************/ | |
| 69 | +GXXXInstDir::GXXXInstDir(const GXXXInstDir& dir) : GInstDir(dir) | |
| 70 | +{ | |
| 71 | + // Initialise class members | |
| 72 | + init_members(); | |
| 73 | + | |
| 74 | + // Copy members | |
| 75 | + copy_members(dir); | |
| 76 | + | |
| 77 | + // Return | |
| 78 | + return; | |
| 79 | +} | |
| 80 | + | |
| 81 | + | |
| 82 | +/***********************************************************************//** | |
| 83 | + * @brief Destructor | |
| 84 | + ***************************************************************************/ | |
| 85 | +GXXXInstDir::~GXXXInstDir(void) | |
| 86 | +{ | |
| 87 | + // Free members | |
| 88 | + free_members(); | |
| 89 | + | |
| 90 | + // Return | |
| 91 | + return; | |
| 92 | +} | |
| 93 | + | |
| 94 | + | |
| 95 | +/*========================================================================== | |
| 96 | + = = | |
| 97 | + = Operators = | |
| 98 | + = = | |
| 99 | + ==========================================================================*/ | |
| 100 | + | |
| 101 | +/***********************************************************************//** | |
| 102 | + * @brief Assignment operator | |
| 103 | + * | |
| 104 | + * @param[in] dir [INSTRUMENT] instrument direction. | |
| 105 | + * @return [INSTRUMENT] instrument direction. | |
| 106 | + ***************************************************************************/ | |
| 107 | +GXXXInstDir& GXXXInstDir::operator=(const GXXXInstDir& dir) | |
| 108 | +{ | |
| 109 | + // Execute only if object is not identical | |
| 110 | + if (this != &dir) { | |
| 111 | + | |
| 112 | + // Copy base class members | |
| 113 | + this->GInstDir::operator=(dir); | |
| 114 | + | |
| 115 | + // Free members | |
| 116 | + free_members(); | |
| 117 | + | |
| 118 | + // Initialise private members | |
| 119 | + init_members(); | |
| 120 | + | |
| 121 | + // Copy members | |
| 122 | + copy_members(dir); | |
| 123 | + | |
| 124 | + } // endif: object was not identical | |
| 125 | + | |
| 126 | + // Return this object | |
| 127 | + return *this; | |
| 128 | +} | |
| 129 | + | |
| 130 | + | |
| 131 | +/*========================================================================== | |
| 132 | + = = | |
| 133 | + = Public methods = | |
| 134 | + = = | |
| 135 | + ==========================================================================*/ | |
| 136 | + | |
| 137 | +/***********************************************************************//** | |
| 138 | + * @brief Clear [INSTRUMENT] instrument direction | |
| 139 | + * | |
| 140 | + * Clears [INSTRUMENT] instrument direction by resetting all class members to | |
| 141 | + * an initial state. Any information that was present before will be lost. | |
| 142 | + ***************************************************************************/ | |
| 143 | +void GXXXInstDir::clear(void) | |
| 144 | +{ | |
| 145 | + // Free members | |
| 146 | + free_members(); | |
| 147 | + this->GInstDir::free_members(); | |
| 148 | + | |
| 149 | + // Initialise private members | |
| 150 | + this->GInstDir::init_members(); | |
| 151 | + init_members(); | |
| 152 | + | |
| 153 | + // Return | |
| 154 | + return; | |
| 155 | +} | |
| 156 | + | |
| 157 | + | |
| 158 | +/***********************************************************************//** | |
| 159 | + * @brief Clone [INSTRUMENT] instrument direction | |
| 160 | + * | |
| 161 | + * @return Pointer to deep copy of [INSTRUMENT] instrument direction. | |
| 162 | + ***************************************************************************/ | |
| 163 | +GXXXInstDir* GXXXInstDir::clone(void) const | |
| 164 | +{ | |
| 165 | + return new GXXXInstDir(*this); | |
| 166 | +} | |
| 167 | + | |
| 168 | + | |
| 169 | +/***********************************************************************//** | |
| 170 | + * @brief Print [INSTRUMENT] instrument direction information | |
| 171 | + * | |
| 172 | + * @param[in] chatter Chattiness. | |
| 173 | + * @return String containing [INSTRUMENT] instrument direction information. | |
| 174 | + ***************************************************************************/ | |
| 175 | +std::string GXXXInstDir::print(const GChatter& chatter) const | |
| 176 | +{ | |
| 177 | + // Initialise result string | |
| 178 | + std::string result; | |
| 179 | + | |
| 180 | + // Continue only if chatter is not silent | |
| 181 | + if (chatter != SILENT) { | |
| 182 | + | |
| 183 | + // Append instrument direction | |
| 184 | + // TODO: Add code to append any information that might be relevant. | |
| 185 | + // Keep the information short, and don't print a header, since you | |
| 186 | + // may have many events | |
| 187 | + | |
| 188 | + } // endif: chatter was not silent | |
| 189 | + | |
| 190 | + // Return result | |
| 191 | + return result; | |
| 192 | +} | |
| 193 | + | |
| 194 | + | |
| 195 | +/*========================================================================== | |
| 196 | + = = | |
| 197 | + = Private methods = | |
| 198 | + = = | |
| 199 | + ==========================================================================*/ | |
| 200 | + | |
| 201 | +/***********************************************************************//** | |
| 202 | + * @brief Initialise class members | |
| 203 | + ***************************************************************************/ | |
| 204 | +void GXXXInstDir::init_members(void) | |
| 205 | +{ | |
| 206 | + // Return | |
| 207 | + return; | |
| 208 | +} | |
| 209 | + | |
| 210 | + | |
| 211 | +/***********************************************************************//** | |
| 212 | + * @brief Copy class members | |
| 213 | + * | |
| 214 | + * @param[in] dir [INSTRUMENT] instrument direction. | |
| 215 | + ***************************************************************************/ | |
| 216 | +void GXXXInstDir::copy_members(const GXXXInstDir& dir) | |
| 217 | +{ | |
| 218 | + // Return | |
| 219 | + return; | |
| 220 | +} | |
| 221 | + | |
| 222 | + | |
| 223 | +/***********************************************************************//** | |
| 224 | + * @brief Delete class members | |
| 225 | + ***************************************************************************/ | |
| 226 | +void GXXXInstDir::free_members(void) | |
| 227 | +{ | |
| 228 | + // Return | |
| 229 | + return; | |
| 230 | +} | ... | ... |
src/template/GXXXInstDir.hpp
0 → 100644
| 1 | +/*************************************************************************** | |
| 2 | + * GXXXInstDir.hpp - [INSTRUMENT] instrument direction class * | |
| 3 | + * ----------------------------------------------------------------------- * | |
| 4 | + * copyright (C) [YEAR] by [AUTHOR] * | |
| 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 GXXXInstDir.hpp | |
| 23 | + * @brief [INSTRUMENT] instrument direction class definition | |
| 24 | + * @author [AUTHOR] | |
| 25 | + */ | |
| 26 | + | |
| 27 | +#ifndef GXXXINSTDIR_HPP | |
| 28 | +#define GXXXINSTDIR_HPP | |
| 29 | + | |
| 30 | +/* __ Includes ___________________________________________________________ */ | |
| 31 | +#include <string> | |
| 32 | +#include "GInstDir.hpp" | |
| 33 | + | |
| 34 | + | |
| 35 | +/***********************************************************************//** | |
| 36 | + * @class GXXXInstDir | |
| 37 | + * | |
| 38 | + * @brief [INSTRUMENT] instrument direction class | |
| 39 | + * | |
| 40 | + * The [INSTRUMENT] instrument direction defines the spatial information | |
| 41 | + * associated to an event. | |
| 42 | + ***************************************************************************/ | |
| 43 | +class GXXXInstDir : public GInstDir { | |
| 44 | + | |
| 45 | +public: | |
| 46 | + // Constructors and destructors | |
| 47 | + GXXXInstDir(void); | |
| 48 | + GXXXInstDir(const GXXXInstDir& dir); | |
| 49 | + virtual ~GXXXInstDir(void); | |
| 50 | + | |
| 51 | + // Operators | |
| 52 | + GXXXInstDir& operator=(const GXXXInstDir& dir); | |
| 53 | + | |
| 54 | + // Implemented pure virtual base class methods | |
| 55 | + virtual void clear(void); | |
| 56 | + virtual GXXXInstDir* clone(void) const; | |
| 57 | + virtual std::string classname(void) const; | |
| 58 | + virtual std::string print(const GChatter& chatter = NORMAL) const; | |
| 59 | + | |
| 60 | + // Other methods | |
| 61 | + // TODO: Add any further methods that are needed | |
| 62 | + | |
| 63 | +protected: | |
| 64 | + // Protected methods | |
| 65 | + void init_members(void); | |
| 66 | + void copy_members(const GXXXInstDir& dir); | |
| 67 | + void free_members(void); | |
| 68 | +}; | |
| 69 | + | |
| 70 | + | |
| 71 | +/***********************************************************************//** | |
| 72 | + * @brief Return class name | |
| 73 | + * | |
| 74 | + * @return String containing the class name ("GXXXInstDir"). | |
| 75 | + ***************************************************************************/ | |
| 76 | +inline | |
| 77 | +std::string GXXXInstDir::classname(void) const | |
| 78 | +{ | |
| 79 | + return ("GXXXInstDir"); | |
| 80 | +} | |
| 81 | + | |
| 82 | +#endif /* GXXXINSTDIR_HPP */ | ... | ... |
src/template/GXXXInstDir.i
0 → 100644
| 1 | +/*************************************************************************** | |
| 2 | + * GXXXInstDir.i - [INSTRUMENT] instrument direction class * | |
| 3 | + * ----------------------------------------------------------------------- * | |
| 4 | + * copyright (C) [YEAR] by [AUTHOR] * | |
| 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 GXXXInstDir.i | |
| 23 | + * @brief [INSTRUMENT] instrument direction class definition | |
| 24 | + * @author [AUTHOR] | |
| 25 | + */ | |
| 26 | +%{ | |
| 27 | +/* Put headers and other declarations here that are needed for compilation */ | |
| 28 | +#include "GXXXInstDir.hpp" | |
| 29 | +%} | |
| 30 | + | |
| 31 | + | |
| 32 | +/***********************************************************************//** | |
| 33 | + * @class GXXXInstDir | |
| 34 | + * | |
| 35 | + * @brief [INSTRUMENT] instrument direction class | |
| 36 | + ***************************************************************************/ | |
| 37 | +class GXXXInstDir : public GInstDir { | |
| 38 | + | |
| 39 | +public: | |
| 40 | + // Constructors and destructors | |
| 41 | + GXXXInstDir(void); | |
| 42 | + GXXXInstDir(const GXXXInstDir& dir); | |
| 43 | + virtual ~GXXXInstDir(void); | |
| 44 | + | |
| 45 | + // Implemented pure virtual base class methods | |
| 46 | + virtual void clear(void); | |
| 47 | + virtual GXXXInstDir* clone(void) const; | |
| 48 | + virtual std::string classname(void) const; | |
| 49 | + | |
| 50 | + // Other methods | |
| 51 | + // TODO: Copy methods from GXXXInstDir.hpp file | |
| 52 | +}; | |
| 53 | + | |
| 54 | + | |
| 55 | +/***********************************************************************//** | |
| 56 | + * @brief GXXXInstDir class extension | |
| 57 | + ***************************************************************************/ | |
| 58 | +%extend GXXXInstDir { | |
| 59 | + GXXXInstDir copy() { | |
| 60 | + return (*self); | |
| 61 | + } | |
| 62 | +}; | ... | ... |
src/template/GXXXObservation.hpp
| ... | ... | @@ -88,8 +88,9 @@ protected: |
| 88 | 88 | double m_ontime; //!< Ontime (sec) |
| 89 | 89 | double m_livetime; //!< Livetime (sec) |
| 90 | 90 | double m_deadc; //!< Deadtime correction |
| 91 | - // TODO: Add any data members that are necessary. Note that the events | |
| 92 | - // are stored in the GObservation base class | |
| 91 | + // TODO: Add any data members that are necessary. Note that the event | |
| 92 | + // list or cubes (type GEvents) are stored in the GObservation base | |
| 93 | + // class | |
| 93 | 94 | }; |
| 94 | 95 | |
| 95 | 96 | ... | ... |
src/template/Makefile.am
| ... | ... | @@ -27,6 +27,9 @@ INCLUDES = -I$(top_srcdir)/include \ |
| 27 | 27 | # Define sources for this directory |
| 28 | 28 | sources = GXXXObservation.cpp \ |
| 29 | 29 | GXXXResponse.cpp \ |
| 30 | + GXXXEventList.cpp \ | |
| 31 | + GXXXEventAtom.cpp \ | |
| 32 | + GXXXInstDir.cpp \ | |
| 30 | 33 | GXXXRoi.cpp |
| 31 | 34 | |
| 32 | 35 | # Build libtool library | ... | ... |