Commit 412c9ea66882486874b94e203c538b1f591e1559
1 parent
628a34ad
move obs specific code in obs directory and add GGti class
Showing
9 changed files
with
715 additions
and
52 deletions
include/GData.hpp
include/GGti.hpp
0 → 100644
| 1 | +/*************************************************************************** | |
| 2 | + * GGti.hpp - Good time interval class * | |
| 3 | + * ----------------------------------------------------------------------- * | |
| 4 | + * copyright : (C) 2008 by Jurgen Knodlseder * | |
| 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 2 of the License, or * | |
| 10 | + * (at your option) any later version. * | |
| 11 | + * * | |
| 12 | + ***************************************************************************/ | |
| 13 | +/** | |
| 14 | + * @file GGti.hpp | |
| 15 | + * @brief Good time interval class interface definition. | |
| 16 | + * @author J. Knodlseder | |
| 17 | + */ | |
| 18 | + | |
| 19 | +#ifndef GGTI_HPP | |
| 20 | +#define GGTI_HPP | |
| 21 | + | |
| 22 | +/* __ Includes ___________________________________________________________ */ | |
| 23 | + | |
| 24 | +/* __ Namespaces _________________________________________________________ */ | |
| 25 | + | |
| 26 | + | |
| 27 | +/***********************************************************************//** | |
| 28 | + * @class GGti | |
| 29 | + * | |
| 30 | + * @brief Interface for the GTI class. | |
| 31 | + ***************************************************************************/ | |
| 32 | +class GGti { | |
| 33 | + | |
| 34 | + // Friend classes | |
| 35 | + friend class GObservation; | |
| 36 | + | |
| 37 | +public: | |
| 38 | + // Constructors and destructors | |
| 39 | + GGti(); | |
| 40 | + GGti(const GGti& gti); | |
| 41 | + virtual ~GGti(); | |
| 42 | + | |
| 43 | + // Operators | |
| 44 | + virtual GGti& operator= (const GGti& gti); | |
| 45 | + | |
| 46 | + // Methods | |
| 47 | + | |
| 48 | +protected: | |
| 49 | + // Protected methods | |
| 50 | + void init_members(void); | |
| 51 | + void copy_members(const GGti& gti); | |
| 52 | + void free_members(void); | |
| 53 | + GGti* clone(void); | |
| 54 | + | |
| 55 | + // Protected data area | |
| 56 | + int m_num; //!< Number of intervals | |
| 57 | + double m_tstart; //!< Start of observation | |
| 58 | + double m_tstop; //!< Stop of observation | |
| 59 | + double m_ontime; //!< Sum of GTI durations | |
| 60 | + double m_elapse; //!< Time between start of first GTI and stop of last GTI | |
| 61 | + double *m_start; //!< Array of start times | |
| 62 | + double *m_stop; //!< Array of stop times | |
| 63 | + | |
| 64 | +private: | |
| 65 | +}; | |
| 66 | + | |
| 67 | +#endif /* GGTI_HPP */ | ... | ... |
include/GObservation.hpp
| ... | ... | @@ -22,6 +22,7 @@ |
| 22 | 22 | /* __ Includes ___________________________________________________________ */ |
| 23 | 23 | #include "GResponse.hpp" |
| 24 | 24 | #include "GData.hpp" |
| 25 | +#include "GGti.hpp" | |
| 25 | 26 | |
| 26 | 27 | /* __ Namespaces _________________________________________________________ */ |
| 27 | 28 | |
| ... | ... | @@ -53,9 +54,11 @@ protected: |
| 53 | 54 | |
| 54 | 55 | // Protected data area |
| 55 | 56 | std::string m_obsname; //!< Name of observation |
| 56 | - int m_num_response; //!< Number of associated response functions | |
| 57 | - GResponse** m_response; //!< Pointer to instrument response functions | |
| 57 | + double m_tstart; //!< Start time of observation | |
| 58 | + double m_tstop; //!< Stop time of observations | |
| 59 | + GResponse* m_response; //!< Pointer to instrument response functions | |
| 58 | 60 | GData* m_data; //!< Pointer to associated data |
| 61 | + GGti* m_gti; //!< Pointer to associated data | |
| 59 | 62 | |
| 60 | 63 | private: |
| 61 | 64 | }; | ... | ... |
src/Makefile.am
| ... | ... | @@ -20,9 +20,10 @@ files = GException.cpp \ |
| 20 | 20 | lat/GLATPsf.cpp \ |
| 21 | 21 | lat/GLATEdisp.cpp \ |
| 22 | 22 | lat/GLATObservation.cpp \ |
| 23 | - data/GData.cpp \ | |
| 24 | - rsp/GResponse.cpp \ | |
| 25 | 23 | obs/GObservation.cpp \ |
| 24 | + obs/GResponse.cpp \ | |
| 25 | + obs/GData.cpp \ | |
| 26 | + obs/GGti.cpp \ | |
| 26 | 27 | fits/GFitsHeaderCard.cpp \ |
| 27 | 28 | fits/GFitsHeader.cpp \ |
| 28 | 29 | fits/GFitsData.cpp \ | ... | ... |
src/Makefile.in
| ... | ... | @@ -125,9 +125,10 @@ files = GException.cpp \ |
| 125 | 125 | lat/GLATPsf.cpp \ |
| 126 | 126 | lat/GLATEdisp.cpp \ |
| 127 | 127 | lat/GLATObservation.cpp \ |
| 128 | - data/GData.cpp \ | |
| 129 | - rsp/GResponse.cpp \ | |
| 130 | 128 | obs/GObservation.cpp \ |
| 129 | + obs/GResponse.cpp \ | |
| 130 | + obs/GData.cpp \ | |
| 131 | + obs/GGti.cpp \ | |
| 131 | 132 | fits/GFitsHeaderCard.cpp \ |
| 132 | 133 | fits/GFitsHeader.cpp \ |
| 133 | 134 | fits/GFitsData.cpp \ |
| ... | ... | @@ -168,15 +169,15 @@ LTLIBRARIES = $(lib_LTLIBRARIES) |
| 168 | 169 | libgamma_la_LIBADD = |
| 169 | 170 | am__objects_1 = GException.lo GTools.lo GSkyDir.lo GNodeArray.lo \ |
| 170 | 171 | GImage.lo GHealpix.lo GLATResponse.lo GLATResponseTable.lo \ |
| 171 | - GLATAeff.lo GLATPsf.lo GLATEdisp.lo GLATObservation.lo GData.lo \ | |
| 172 | - GResponse.lo GObservation.lo GFitsHeaderCard.lo GFitsHeader.lo \ | |
| 173 | - GFitsData.lo GFitsImage.lo GFitsDblImage.lo GFitsTable.lo \ | |
| 174 | - GFitsAsciiTable.lo GFitsBinTable.lo GFitsTableCol.lo \ | |
| 175 | - GFitsTableLogCol.lo GFitsTableStrCol.lo GFitsTableShtCol.lo \ | |
| 176 | - GFitsTableLngCol.lo GFitsTableFltCol.lo GFitsTableDblCol.lo \ | |
| 177 | - GFitsHDU.lo GFits.lo GFitPar.lo GVector.lo GMatrixBase.lo \ | |
| 178 | - GMatrix.lo GSymMatrix.lo GSparseMatrix.lo GSparseSymbolic.lo \ | |
| 179 | - GSparseNumeric.lo | |
| 172 | + GLATAeff.lo GLATPsf.lo GLATEdisp.lo GLATObservation.lo \ | |
| 173 | + GObservation.lo GResponse.lo GData.lo GGti.lo \ | |
| 174 | + GFitsHeaderCard.lo GFitsHeader.lo GFitsData.lo GFitsImage.lo \ | |
| 175 | + GFitsDblImage.lo GFitsTable.lo GFitsAsciiTable.lo \ | |
| 176 | + GFitsBinTable.lo GFitsTableCol.lo GFitsTableLogCol.lo \ | |
| 177 | + GFitsTableStrCol.lo GFitsTableShtCol.lo GFitsTableLngCol.lo \ | |
| 178 | + GFitsTableFltCol.lo GFitsTableDblCol.lo GFitsHDU.lo GFits.lo \ | |
| 179 | + GFitPar.lo GVector.lo GMatrixBase.lo GMatrix.lo GSymMatrix.lo \ | |
| 180 | + GSparseMatrix.lo GSparseSymbolic.lo GSparseNumeric.lo | |
| 180 | 181 | am_libgamma_la_OBJECTS = $(am__objects_1) |
| 181 | 182 | libgamma_la_OBJECTS = $(am_libgamma_la_OBJECTS) |
| 182 | 183 | |
| ... | ... | @@ -243,9 +244,10 @@ GLATAeff.lo: lat/GLATAeff.cpp |
| 243 | 244 | GLATPsf.lo: lat/GLATPsf.cpp |
| 244 | 245 | GLATEdisp.lo: lat/GLATEdisp.cpp |
| 245 | 246 | GLATObservation.lo: lat/GLATObservation.cpp |
| 246 | -GData.lo: data/GData.cpp | |
| 247 | -GResponse.lo: rsp/GResponse.cpp | |
| 248 | 247 | GObservation.lo: obs/GObservation.cpp |
| 248 | +GResponse.lo: obs/GResponse.cpp | |
| 249 | +GData.lo: obs/GData.cpp | |
| 250 | +GGti.lo: obs/GGti.cpp | |
| 249 | 251 | GFitsHeaderCard.lo: fits/GFitsHeaderCard.cpp |
| 250 | 252 | GFitsHeader.lo: fits/GFitsHeader.cpp |
| 251 | 253 | GFitsData.lo: fits/GFitsData.cpp |
| ... | ... | @@ -343,24 +345,6 @@ GLATObservation.obj: lat/GLATObservation.cpp |
| 343 | 345 | GLATObservation.lo: lat/GLATObservation.cpp |
| 344 | 346 | $(LIBTOOL) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o GLATObservation.lo `test -f 'lat/GLATObservation.cpp' || echo '$(srcdir)/'`lat/GLATObservation.cpp |
| 345 | 347 | |
| 346 | -GData.o: data/GData.cpp | |
| 347 | - $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o GData.o `test -f 'data/GData.cpp' || echo '$(srcdir)/'`data/GData.cpp | |
| 348 | - | |
| 349 | -GData.obj: data/GData.cpp | |
| 350 | - $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o GData.obj `cygpath -w data/GData.cpp` | |
| 351 | - | |
| 352 | -GData.lo: data/GData.cpp | |
| 353 | - $(LIBTOOL) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o GData.lo `test -f 'data/GData.cpp' || echo '$(srcdir)/'`data/GData.cpp | |
| 354 | - | |
| 355 | -GResponse.o: rsp/GResponse.cpp | |
| 356 | - $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o GResponse.o `test -f 'rsp/GResponse.cpp' || echo '$(srcdir)/'`rsp/GResponse.cpp | |
| 357 | - | |
| 358 | -GResponse.obj: rsp/GResponse.cpp | |
| 359 | - $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o GResponse.obj `cygpath -w rsp/GResponse.cpp` | |
| 360 | - | |
| 361 | -GResponse.lo: rsp/GResponse.cpp | |
| 362 | - $(LIBTOOL) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o GResponse.lo `test -f 'rsp/GResponse.cpp' || echo '$(srcdir)/'`rsp/GResponse.cpp | |
| 363 | - | |
| 364 | 348 | GObservation.o: obs/GObservation.cpp |
| 365 | 349 | $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o GObservation.o `test -f 'obs/GObservation.cpp' || echo '$(srcdir)/'`obs/GObservation.cpp |
| 366 | 350 | |
| ... | ... | @@ -370,6 +354,33 @@ GObservation.obj: obs/GObservation.cpp |
| 370 | 354 | GObservation.lo: obs/GObservation.cpp |
| 371 | 355 | $(LIBTOOL) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o GObservation.lo `test -f 'obs/GObservation.cpp' || echo '$(srcdir)/'`obs/GObservation.cpp |
| 372 | 356 | |
| 357 | +GResponse.o: obs/GResponse.cpp | |
| 358 | + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o GResponse.o `test -f 'obs/GResponse.cpp' || echo '$(srcdir)/'`obs/GResponse.cpp | |
| 359 | + | |
| 360 | +GResponse.obj: obs/GResponse.cpp | |
| 361 | + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o GResponse.obj `cygpath -w obs/GResponse.cpp` | |
| 362 | + | |
| 363 | +GResponse.lo: obs/GResponse.cpp | |
| 364 | + $(LIBTOOL) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o GResponse.lo `test -f 'obs/GResponse.cpp' || echo '$(srcdir)/'`obs/GResponse.cpp | |
| 365 | + | |
| 366 | +GData.o: obs/GData.cpp | |
| 367 | + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o GData.o `test -f 'obs/GData.cpp' || echo '$(srcdir)/'`obs/GData.cpp | |
| 368 | + | |
| 369 | +GData.obj: obs/GData.cpp | |
| 370 | + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o GData.obj `cygpath -w obs/GData.cpp` | |
| 371 | + | |
| 372 | +GData.lo: obs/GData.cpp | |
| 373 | + $(LIBTOOL) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o GData.lo `test -f 'obs/GData.cpp' || echo '$(srcdir)/'`obs/GData.cpp | |
| 374 | + | |
| 375 | +GGti.o: obs/GGti.cpp | |
| 376 | + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o GGti.o `test -f 'obs/GGti.cpp' || echo '$(srcdir)/'`obs/GGti.cpp | |
| 377 | + | |
| 378 | +GGti.obj: obs/GGti.cpp | |
| 379 | + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o GGti.obj `cygpath -w obs/GGti.cpp` | |
| 380 | + | |
| 381 | +GGti.lo: obs/GGti.cpp | |
| 382 | + $(LIBTOOL) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o GGti.lo `test -f 'obs/GGti.cpp' || echo '$(srcdir)/'`obs/GGti.cpp | |
| 383 | + | |
| 373 | 384 | GFitsHeaderCard.o: fits/GFitsHeaderCard.cpp |
| 374 | 385 | $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o GFitsHeaderCard.o `test -f 'fits/GFitsHeaderCard.cpp' || echo '$(srcdir)/'`fits/GFitsHeaderCard.cpp |
| 375 | 386 | ... | ... |
src/obs/GData.cpp
0 → 100644
| 1 | +/*************************************************************************** | |
| 2 | + * GData.cpp - Data abstract base class * | |
| 3 | + * ----------------------------------------------------------------------- * | |
| 4 | + * copyright : (C) 2008 by Jurgen Knodlseder * | |
| 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 2 of the License, or * | |
| 10 | + * (at your option) any later version. * | |
| 11 | + * * | |
| 12 | + * ----------------------------------------------------------------------- * | |
| 13 | + ***************************************************************************/ | |
| 14 | +/** | |
| 15 | + * @file GData.cpp | |
| 16 | + * @brief GData abstract base class implementation. | |
| 17 | + * @author J. Knodlseder | |
| 18 | + */ | |
| 19 | + | |
| 20 | +/* __ Includes ___________________________________________________________ */ | |
| 21 | +#include "GException.hpp" | |
| 22 | +#include "GData.hpp" | |
| 23 | + | |
| 24 | +/* __ Namespaces _________________________________________________________ */ | |
| 25 | + | |
| 26 | +/* __ Method name definitions ____________________________________________ */ | |
| 27 | + | |
| 28 | +/* __ Macros _____________________________________________________________ */ | |
| 29 | + | |
| 30 | +/* __ Coding definitions _________________________________________________ */ | |
| 31 | + | |
| 32 | +/* __ Debug definitions __________________________________________________ */ | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | +/*========================================================================== | |
| 37 | + = = | |
| 38 | + = GData constructors/destructors = | |
| 39 | + = = | |
| 40 | + ==========================================================================*/ | |
| 41 | + | |
| 42 | +/***********************************************************************//** | |
| 43 | + * @brief Constructor | |
| 44 | + ***************************************************************************/ | |
| 45 | +GData::GData() | |
| 46 | +{ | |
| 47 | + // Initialise class members for clean destruction | |
| 48 | + init_members(); | |
| 49 | + | |
| 50 | + // Return | |
| 51 | + return; | |
| 52 | +} | |
| 53 | + | |
| 54 | + | |
| 55 | +/***********************************************************************//** | |
| 56 | + * @brief Copy constructor | |
| 57 | + * | |
| 58 | + * @param data GData instance which should be used for construction | |
| 59 | + ***************************************************************************/ | |
| 60 | +GData::GData(const GData& data) | |
| 61 | +{ | |
| 62 | + // Initialise class members for clean destruction | |
| 63 | + init_members(); | |
| 64 | + | |
| 65 | + // Copy members | |
| 66 | + copy_members(data); | |
| 67 | + | |
| 68 | + // Return | |
| 69 | + return; | |
| 70 | +} | |
| 71 | + | |
| 72 | + | |
| 73 | +/***********************************************************************//** | |
| 74 | + * @brief Destructor | |
| 75 | + ***************************************************************************/ | |
| 76 | +GData::~GData() | |
| 77 | +{ | |
| 78 | + // Free members | |
| 79 | + free_members(); | |
| 80 | + | |
| 81 | + // Return | |
| 82 | + return; | |
| 83 | +} | |
| 84 | + | |
| 85 | + | |
| 86 | +/*========================================================================== | |
| 87 | + = = | |
| 88 | + = GData operators = | |
| 89 | + = = | |
| 90 | + ==========================================================================*/ | |
| 91 | + | |
| 92 | +/***********************************************************************//** | |
| 93 | + * @brief Assignment operator | |
| 94 | + * | |
| 95 | + * @param[in] data GData instance to be assigned | |
| 96 | + ***************************************************************************/ | |
| 97 | +GData& GData::operator= (const GData& data) | |
| 98 | +{ | |
| 99 | + // Execute only if object is not identical | |
| 100 | + if (this != &data) { | |
| 101 | + | |
| 102 | + // Free members | |
| 103 | + free_members(); | |
| 104 | + | |
| 105 | + // Initialise private members for clean destruction | |
| 106 | + init_members(); | |
| 107 | + | |
| 108 | + // Copy members | |
| 109 | + copy_members(data); | |
| 110 | + | |
| 111 | + } // endif: object was not identical | |
| 112 | + | |
| 113 | + // Return this object | |
| 114 | + return *this; | |
| 115 | +} | |
| 116 | + | |
| 117 | + | |
| 118 | +/*========================================================================== | |
| 119 | + = = | |
| 120 | + = GData public methods = | |
| 121 | + = = | |
| 122 | + ==========================================================================*/ | |
| 123 | + | |
| 124 | + | |
| 125 | +/*========================================================================== | |
| 126 | + = = | |
| 127 | + = GData private methods = | |
| 128 | + = = | |
| 129 | + ==========================================================================*/ | |
| 130 | + | |
| 131 | +/***********************************************************************//** | |
| 132 | + * @brief Initialise class members | |
| 133 | + ***************************************************************************/ | |
| 134 | +void GData::init_members(void) | |
| 135 | +{ | |
| 136 | + // Initialise members | |
| 137 | + | |
| 138 | + // Return | |
| 139 | + return; | |
| 140 | +} | |
| 141 | + | |
| 142 | + | |
| 143 | +/***********************************************************************//** | |
| 144 | + * @brief Copy class members | |
| 145 | + * | |
| 146 | + * @param[in] data GData instance from which members should be copied | |
| 147 | + ***************************************************************************/ | |
| 148 | +void GData::copy_members(const GData& data) | |
| 149 | +{ | |
| 150 | + // Copy attributes | |
| 151 | + | |
| 152 | + // Return | |
| 153 | + return; | |
| 154 | +} | |
| 155 | + | |
| 156 | + | |
| 157 | +/***********************************************************************//** | |
| 158 | + * @brief Delete class members | |
| 159 | + ***************************************************************************/ | |
| 160 | +void GData::free_members(void) | |
| 161 | +{ | |
| 162 | + // Free memory | |
| 163 | + | |
| 164 | + // Mark memory as free | |
| 165 | + | |
| 166 | + // Return | |
| 167 | + return; | |
| 168 | +} | |
| 169 | + | |
| 170 | + | |
| 171 | +/*========================================================================== | |
| 172 | + = = | |
| 173 | + = GData friends = | |
| 174 | + = = | |
| 175 | + ==========================================================================*/ | |
| 176 | + | |
| 177 | + | |
| 178 | +/*========================================================================== | |
| 179 | + = = | |
| 180 | + = Other functions used by GData = | |
| 181 | + = = | |
| 182 | + ==========================================================================*/ | ... | ... |
src/obs/GGti.cpp
0 → 100644
| 1 | +/*************************************************************************** | |
| 2 | + * GGti.cpp - Good time interval class * | |
| 3 | + * ----------------------------------------------------------------------- * | |
| 4 | + * copyright : (C) 2008 by Jurgen Knodlseder * | |
| 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 2 of the License, or * | |
| 10 | + * (at your option) any later version. * | |
| 11 | + * * | |
| 12 | + * ----------------------------------------------------------------------- * | |
| 13 | + ***************************************************************************/ | |
| 14 | +/** | |
| 15 | + * @file GGti.cpp | |
| 16 | + * @brief Good time interval class implementation. | |
| 17 | + * @author J. Knodlseder | |
| 18 | + */ | |
| 19 | + | |
| 20 | +/* __ Includes ___________________________________________________________ */ | |
| 21 | +#include <iostream> | |
| 22 | +#include "GException.hpp" | |
| 23 | +#include "GGti.hpp" | |
| 24 | + | |
| 25 | +/* __ Namespaces _________________________________________________________ */ | |
| 26 | + | |
| 27 | +/* __ Method name definitions ____________________________________________ */ | |
| 28 | +#define G_COPY_MEMBERS "GGti::copy_members(const GGti&)" | |
| 29 | + | |
| 30 | +/* __ Macros _____________________________________________________________ */ | |
| 31 | + | |
| 32 | +/* __ Coding definitions _________________________________________________ */ | |
| 33 | + | |
| 34 | +/* __ Debug definitions __________________________________________________ */ | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | +/*========================================================================== | |
| 39 | + = = | |
| 40 | + = GGti constructors/destructors = | |
| 41 | + = = | |
| 42 | + ==========================================================================*/ | |
| 43 | + | |
| 44 | +/***********************************************************************//** | |
| 45 | + * @brief Constructor | |
| 46 | + ***************************************************************************/ | |
| 47 | +GGti::GGti() | |
| 48 | +{ | |
| 49 | + // Initialise class members for clean destruction | |
| 50 | + init_members(); | |
| 51 | + | |
| 52 | + // Return | |
| 53 | + return; | |
| 54 | +} | |
| 55 | + | |
| 56 | + | |
| 57 | +/***********************************************************************//** | |
| 58 | + * @brief Copy constructor | |
| 59 | + * | |
| 60 | + * @param[in] gti Good time interval from which the instance should be built. | |
| 61 | + ***************************************************************************/ | |
| 62 | +GGti::GGti(const GGti& gti) | |
| 63 | +{ | |
| 64 | + // Initialise class members for clean destruction | |
| 65 | + init_members(); | |
| 66 | + | |
| 67 | + // Copy members | |
| 68 | + copy_members(gti); | |
| 69 | + | |
| 70 | + // Return | |
| 71 | + return; | |
| 72 | +} | |
| 73 | + | |
| 74 | + | |
| 75 | +/***********************************************************************//** | |
| 76 | + * @brief Destructor | |
| 77 | + ***************************************************************************/ | |
| 78 | +GGti::~GGti() | |
| 79 | +{ | |
| 80 | + // Free members | |
| 81 | + free_members(); | |
| 82 | + | |
| 83 | + // Return | |
| 84 | + return; | |
| 85 | +} | |
| 86 | + | |
| 87 | + | |
| 88 | +/*========================================================================== | |
| 89 | + = = | |
| 90 | + = GGti operators = | |
| 91 | + = = | |
| 92 | + ==========================================================================*/ | |
| 93 | + | |
| 94 | +/***********************************************************************//** | |
| 95 | + * @brief Assignment operator | |
| 96 | + * | |
| 97 | + * @param[in] gti Good time interval which should be assigned. | |
| 98 | + ***************************************************************************/ | |
| 99 | +GGti& GGti::operator= (const GGti& gti) | |
| 100 | +{ | |
| 101 | + // Execute only if object is not identical | |
| 102 | + if (this != >i) { | |
| 103 | + | |
| 104 | + // Free members | |
| 105 | + free_members(); | |
| 106 | + | |
| 107 | + // Initialise private members for clean destruction | |
| 108 | + init_members(); | |
| 109 | + | |
| 110 | + // Copy members | |
| 111 | + copy_members(gti); | |
| 112 | + | |
| 113 | + } // endif: object was not identical | |
| 114 | + | |
| 115 | + // Return this object | |
| 116 | + return *this; | |
| 117 | +} | |
| 118 | + | |
| 119 | + | |
| 120 | +/*========================================================================== | |
| 121 | + = = | |
| 122 | + = GGti public methods = | |
| 123 | + = = | |
| 124 | + ==========================================================================*/ | |
| 125 | + | |
| 126 | + | |
| 127 | +/*========================================================================== | |
| 128 | + = = | |
| 129 | + = GGti private methods = | |
| 130 | + = = | |
| 131 | + ==========================================================================*/ | |
| 132 | + | |
| 133 | +/***********************************************************************//** | |
| 134 | + * @brief Initialise class members | |
| 135 | + ***************************************************************************/ | |
| 136 | +void GGti::init_members(void) | |
| 137 | +{ | |
| 138 | + // Initialise members | |
| 139 | + m_num = 0; | |
| 140 | + m_tstart = 0.0; | |
| 141 | + m_tstop = 0.0; | |
| 142 | + m_ontime = 0.0; | |
| 143 | + m_elapse = 0.0; | |
| 144 | + m_start = NULL; | |
| 145 | + m_stop = NULL; | |
| 146 | + | |
| 147 | + // Return | |
| 148 | + return; | |
| 149 | +} | |
| 150 | + | |
| 151 | + | |
| 152 | +/***********************************************************************//** | |
| 153 | + * @brief Copy class members | |
| 154 | + * | |
| 155 | + * @param[in] gti GGti members which should be copied. | |
| 156 | + ***************************************************************************/ | |
| 157 | +void GGti::copy_members(const GGti& gti) | |
| 158 | +{ | |
| 159 | + // Copy attributes | |
| 160 | + m_num = gti.m_num; | |
| 161 | + m_tstart = gti.m_tstart; | |
| 162 | + m_tstop = gti.m_tstop; | |
| 163 | + m_ontime = gti.m_ontime; | |
| 164 | + m_elapse = gti.m_elapse; | |
| 165 | + | |
| 166 | + // Copy start/stop times | |
| 167 | + if (m_num > 0) { | |
| 168 | + m_start = new double[m_num]; | |
| 169 | + m_stop = new double[m_num]; | |
| 170 | + if (m_start == NULL || m_stop == NULL) | |
| 171 | + throw GException::mem_alloc(G_COPY_MEMBERS, m_num); | |
| 172 | + for (int i = 0; i < m_num; ++i) { | |
| 173 | + m_start[i] = gti.m_start[i]; | |
| 174 | + m_stop[i] = gti.m_stop[i]; | |
| 175 | + } | |
| 176 | + } | |
| 177 | + | |
| 178 | + // Return | |
| 179 | + return; | |
| 180 | +} | |
| 181 | + | |
| 182 | + | |
| 183 | +/***********************************************************************//** | |
| 184 | + * @brief Delete class members | |
| 185 | + ***************************************************************************/ | |
| 186 | +void GGti::free_members(void) | |
| 187 | +{ | |
| 188 | + // Free memory | |
| 189 | + if (m_start != NULL) delete [] m_start; | |
| 190 | + if (m_stop != NULL) delete [] m_stop; | |
| 191 | + | |
| 192 | + // Signal free pointers | |
| 193 | + m_start = NULL; | |
| 194 | + m_stop = NULL; | |
| 195 | + | |
| 196 | + // Return | |
| 197 | + return; | |
| 198 | +} | |
| 199 | + | |
| 200 | + | |
| 201 | +/*========================================================================== | |
| 202 | + = = | |
| 203 | + = GGti friends = | |
| 204 | + = = | |
| 205 | + ==========================================================================*/ | |
| 206 | + | |
| 207 | + | |
| 208 | +/*========================================================================== | |
| 209 | + = = | |
| 210 | + = Other functions used by GGti = | |
| 211 | + = = | |
| 212 | + ==========================================================================*/ | ... | ... |
src/obs/GObservation.cpp
| ... | ... | @@ -136,9 +136,11 @@ void GObservation::init_members(void) |
| 136 | 136 | { |
| 137 | 137 | // Initialise members |
| 138 | 138 | m_obsname.clear(); |
| 139 | - m_num_response = 0; | |
| 140 | - m_response = NULL; | |
| 141 | - m_data = NULL; | |
| 139 | + m_tstart = 0.0; | |
| 140 | + m_tstop = 0.0; | |
| 141 | + m_response = NULL; | |
| 142 | + m_data = NULL; | |
| 143 | + m_gti = NULL; | |
| 142 | 144 | |
| 143 | 145 | // Return |
| 144 | 146 | return; |
| ... | ... | @@ -153,15 +155,14 @@ void GObservation::init_members(void) |
| 153 | 155 | void GObservation::copy_members(const GObservation& obs) |
| 154 | 156 | { |
| 155 | 157 | // Copy attributes |
| 156 | - m_obsname = obs.m_obsname; | |
| 157 | - m_num_response = obs.m_num_response; | |
| 158 | + m_obsname = obs.m_obsname; | |
| 159 | + m_tstart = obs.m_tstart; | |
| 160 | + m_tstop = obs.m_tstop; | |
| 158 | 161 | |
| 159 | - // Copy other members | |
| 160 | - if (m_num_response > 0) { | |
| 161 | - m_response = new GResponse*[m_num_response]; | |
| 162 | - for (int i = 0; i < m_num_response; ++i) | |
| 163 | - m_response[i] = obs.m_response[i]->clone(); | |
| 164 | - } | |
| 162 | + // Clone members | |
| 163 | + m_response = obs.m_response->clone(); | |
| 164 | + m_data = obs.m_data->clone(); | |
| 165 | + m_gti = obs.m_gti->clone(); | |
| 165 | 166 | |
| 166 | 167 | // Return |
| 167 | 168 | return; |
| ... | ... | @@ -174,15 +175,14 @@ void GObservation::copy_members(const GObservation& obs) |
| 174 | 175 | void GObservation::free_members(void) |
| 175 | 176 | { |
| 176 | 177 | // Free memory |
| 177 | - if (m_response != NULL) { | |
| 178 | - for (int i = 0; i < m_num_response; ++i) { | |
| 179 | - if (m_response[i] != NULL) delete [] m_response[i]; | |
| 180 | - } | |
| 181 | - delete [] m_response; | |
| 182 | - } | |
| 178 | + if (m_response != NULL) delete m_response; | |
| 179 | + if (m_data != NULL) delete m_data; | |
| 180 | + if (m_gti != NULL) delete m_gti; | |
| 183 | 181 | |
| 184 | 182 | // Signal free pointers |
| 185 | 183 | m_response = NULL; |
| 184 | + m_data = NULL; | |
| 185 | + m_gti = NULL; | |
| 186 | 186 | |
| 187 | 187 | // Return |
| 188 | 188 | return; | ... | ... |
src/obs/GResponse.cpp
0 → 100644
| 1 | +/*************************************************************************** | |
| 2 | + * GResponse.cpp - Response abstract base class * | |
| 3 | + * ----------------------------------------------------------------------- * | |
| 4 | + * copyright : (C) 2008 by Jurgen Knodlseder * | |
| 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 2 of the License, or * | |
| 10 | + * (at your option) any later version. * | |
| 11 | + * * | |
| 12 | + * ----------------------------------------------------------------------- * | |
| 13 | + ***************************************************************************/ | |
| 14 | + | |
| 15 | +/* __ Includes ___________________________________________________________ */ | |
| 16 | +#include "GException.hpp" | |
| 17 | +#include "GResponse.hpp" | |
| 18 | +#include <iostream> // cout, cerr | |
| 19 | + | |
| 20 | +/* __ Namespaces _________________________________________________________ */ | |
| 21 | + | |
| 22 | +/* __ Method name definitions ____________________________________________ */ | |
| 23 | + | |
| 24 | +/* __ Macros _____________________________________________________________ */ | |
| 25 | + | |
| 26 | +/* __ Coding definitions _________________________________________________ */ | |
| 27 | + | |
| 28 | +/* __ Debug definitions __________________________________________________ */ | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | +/*========================================================================== | |
| 33 | + = = | |
| 34 | + = GResponse constructors/destructors = | |
| 35 | + = = | |
| 36 | + ==========================================================================*/ | |
| 37 | + | |
| 38 | +/***********************************************************************//** | |
| 39 | + * @brief Constructor | |
| 40 | + ***************************************************************************/ | |
| 41 | +GResponse::GResponse() | |
| 42 | +{ | |
| 43 | + // Initialise class members for clean destruction | |
| 44 | + init_members(); | |
| 45 | + | |
| 46 | + // Return | |
| 47 | + return; | |
| 48 | +} | |
| 49 | + | |
| 50 | + | |
| 51 | +/***********************************************************************//** | |
| 52 | + * @brief Copy constructor | |
| 53 | + * | |
| 54 | + * @param[in] rsp Response from which the instance should be built. | |
| 55 | + ***************************************************************************/ | |
| 56 | +GResponse::GResponse(const GResponse& rsp) | |
| 57 | +{ | |
| 58 | + // Initialise class members for clean destruction | |
| 59 | + init_members(); | |
| 60 | + | |
| 61 | + // Copy members | |
| 62 | + copy_members(rsp); | |
| 63 | + | |
| 64 | + // Return | |
| 65 | + return; | |
| 66 | +} | |
| 67 | + | |
| 68 | + | |
| 69 | +/***********************************************************************//** | |
| 70 | + * @brief Destructor | |
| 71 | + ***************************************************************************/ | |
| 72 | +GResponse::~GResponse() | |
| 73 | +{ | |
| 74 | + // Free members | |
| 75 | + free_members(); | |
| 76 | + | |
| 77 | + // Return | |
| 78 | + return; | |
| 79 | +} | |
| 80 | + | |
| 81 | + | |
| 82 | +/*========================================================================== | |
| 83 | + = = | |
| 84 | + = GResponse operators = | |
| 85 | + = = | |
| 86 | + ==========================================================================*/ | |
| 87 | + | |
| 88 | +/***********************************************************************//** | |
| 89 | + * @brief Assignment operator | |
| 90 | + * | |
| 91 | + * @param[in] rsp Response which should be assigned. | |
| 92 | + ***************************************************************************/ | |
| 93 | +GResponse& GResponse::operator= (const GResponse& rsp) | |
| 94 | +{ | |
| 95 | + // Execute only if object is not identical | |
| 96 | + if (this != &rsp) { | |
| 97 | + | |
| 98 | + // Free members | |
| 99 | + free_members(); | |
| 100 | + | |
| 101 | + // Initialise private members for clean destruction | |
| 102 | + init_members(); | |
| 103 | + | |
| 104 | + // Copy members | |
| 105 | + copy_members(rsp); | |
| 106 | + | |
| 107 | + } // endif: object was not identical | |
| 108 | + | |
| 109 | + // Return this object | |
| 110 | + return *this; | |
| 111 | +} | |
| 112 | + | |
| 113 | + | |
| 114 | +/*========================================================================== | |
| 115 | + = = | |
| 116 | + = GResponse public methods = | |
| 117 | + = = | |
| 118 | + ==========================================================================*/ | |
| 119 | + | |
| 120 | + | |
| 121 | +/*========================================================================== | |
| 122 | + = = | |
| 123 | + = GResponse private methods = | |
| 124 | + = = | |
| 125 | + ==========================================================================*/ | |
| 126 | + | |
| 127 | +/***********************************************************************//** | |
| 128 | + * @brief Initialise class members | |
| 129 | + ***************************************************************************/ | |
| 130 | +void GResponse::init_members(void) | |
| 131 | +{ | |
| 132 | + // Initialise members | |
| 133 | + m_caldb.clear(); | |
| 134 | + m_rspname.clear(); | |
| 135 | + | |
| 136 | + // Return | |
| 137 | + return; | |
| 138 | +} | |
| 139 | + | |
| 140 | + | |
| 141 | +/***********************************************************************//** | |
| 142 | + * @brief Copy class members | |
| 143 | + * | |
| 144 | + * @param[in] rsp Response members which should be copied. | |
| 145 | + ***************************************************************************/ | |
| 146 | +void GResponse::copy_members(const GResponse& rsp) | |
| 147 | +{ | |
| 148 | + // Copy attributes | |
| 149 | + m_caldb = rsp.m_caldb; | |
| 150 | + m_rspname = rsp.m_rspname; | |
| 151 | + | |
| 152 | + // Copy other membres | |
| 153 | + | |
| 154 | + // Return | |
| 155 | + return; | |
| 156 | +} | |
| 157 | + | |
| 158 | + | |
| 159 | +/***********************************************************************//** | |
| 160 | + * @brief Delete class members | |
| 161 | + ***************************************************************************/ | |
| 162 | +void GResponse::free_members(void) | |
| 163 | +{ | |
| 164 | + // Free memory | |
| 165 | + | |
| 166 | + // Signal free pointers | |
| 167 | + | |
| 168 | + // Return | |
| 169 | + return; | |
| 170 | +} | |
| 171 | + | |
| 172 | + | |
| 173 | +/*========================================================================== | |
| 174 | + = = | |
| 175 | + = GResponse friends = | |
| 176 | + = = | |
| 177 | + ==========================================================================*/ | |
| 178 | + | |
| 179 | + | |
| 180 | +/*========================================================================== | |
| 181 | + = = | |
| 182 | + = Other functions used by GResponse = | |
| 183 | + = = | |
| 184 | + ==========================================================================*/ | ... | ... |