diff --git a/NEWS b/NEWS index 42fa1fb..f7238c9 100644 --- a/NEWS +++ b/NEWS @@ -24,6 +24,14 @@ The following methods have been renamed: - GCTAResponseTable::tables(), was formerly GCTAResponseTable::size() - GCTAResponseTable::axis_bins(), was formerly GCTAResponseTable::axis() +The following methods now take a GFilename argument instead of std::string: +- GEbounds(const GFilename&) +- GEbounds::load() +- GEbounds::save() +- GGti(const GFilename&) +- GGti::load() +- GGti::save() + The return value has been changed for the following methods: - GFits::filename() returns now GFilename instead of std::string - GCTAObservation::eventtype() returns now std::string instead of const std::string& diff --git a/include/GEbounds.hpp b/include/GEbounds.hpp index cf0df39..e27cb4c 100644 --- a/include/GEbounds.hpp +++ b/include/GEbounds.hpp @@ -1,7 +1,7 @@ /*************************************************************************** * GEbounds.hpp - Energy boundaries class * * ----------------------------------------------------------------------- * - * copyright (C) 2009-2015 by Juergen Knoedlseder * + * copyright (C) 2009-2016 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -36,6 +36,7 @@ class GXmlElement; class GFits; class GFitsTable; +class GFilename; /***********************************************************************//** @@ -55,7 +56,7 @@ class GEbounds : public GContainer { public: // Constructors and destructors GEbounds(void); - explicit GEbounds(const std::string& filename); + explicit GEbounds(const GFilename& filename); explicit GEbounds(const GXmlElement& xml); GEbounds(const GEbounds& ebds); GEbounds(const GEnergy& emin, const GEnergy& emax); @@ -81,8 +82,8 @@ public: void extend(const GEbounds& ebds); void set_lin(const int& num, const GEnergy& emin, const GEnergy& emax); void set_log(const int& num, const GEnergy& emin, const GEnergy& emax); - void load(const std::string& filename); - void save(const std::string& filename, + void load(const GFilename& filename); + void save(const GFilename& filename, const bool& clobber = false, const std::string& unit = "keV") const; void read(const GFitsTable& table); diff --git a/include/GGti.hpp b/include/GGti.hpp index b3c0598..68b03ae 100644 --- a/include/GGti.hpp +++ b/include/GGti.hpp @@ -32,6 +32,7 @@ #include "GContainer.hpp" #include "GTime.hpp" #include "GTimeReference.hpp" +#include "GFilename.hpp" /* __ Forward declarations _______________________________________________ */ class GXmlElement; @@ -58,7 +59,7 @@ class GGti : public GContainer { public: // Constructors and destructors GGti(void); - explicit GGti(const std::string& filename); + explicit GGti(const GFilename& filename); GGti(const GGti& gti); GGti(const GTime& tstart, const GTime& tstop); explicit GGti(const GXmlElement& xml); @@ -82,8 +83,8 @@ public: void remove(const int& index); void reserve(const int& num); void extend(const GGti& gti); - void load(const std::string& filename); - void save(const std::string& filename, + void load(const GFilename& filename); + void save(const GFilename& filename, const bool& clobber = false) const; void read(const GFitsTable& table); void write(GFits& fits, @@ -118,7 +119,7 @@ protected: GTime *m_start; //!< Array of start times GTime *m_stop; //!< Array of stop times GTimeReference m_reference; //!< Time reference - std::string m_xml_filename; //!< XML filename + GFilename m_xml_filename; //!< XML filename }; diff --git a/pyext/GEbounds.i b/pyext/GEbounds.i index 0625a84..5ec88d7 100644 --- a/pyext/GEbounds.i +++ b/pyext/GEbounds.i @@ -1,7 +1,7 @@ /*************************************************************************** * GEbounds.i - Energy boundaries class * * ----------------------------------------------------------------------- * - * copyright (C) 2010-2015 by Juergen Knoedlseder * + * copyright (C) 2010-2016 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -39,7 +39,7 @@ class GEbounds : public GContainer { public: // Constructors and destructors GEbounds(void); - explicit GEbounds(const std::string& filename); + explicit GEbounds(const GFilename& filename); explicit GEbounds(const GXmlElement& xml); GEbounds(const GEbounds& ebds); GEbounds(const GEnergy& emin, const GEnergy& emax); @@ -62,8 +62,8 @@ public: void extend(const GEbounds& ebds); void set_lin(const int& num, const GEnergy& emin, const GEnergy& emax); void set_log(const int& num, const GEnergy& emin, const GEnergy& emax); - void load(const std::string& filename); - void save(const std::string& filename, + void load(const GFilename& filename); + void save(const GFilename& filename, const bool& clobber = false, const std::string& unit = "keV") const; void read(const GFitsTable& table); diff --git a/pyext/GGti.i b/pyext/GGti.i index 370b0d3..9f2f3bd 100644 --- a/pyext/GGti.i +++ b/pyext/GGti.i @@ -40,7 +40,7 @@ class GGti : public GBase { public: // Constructors and destructors GGti(void); - explicit GGti(const std::string& filename); + explicit GGti(const GFilename& filename); GGti(const GGti& gti); GGti(const GTime& tstart, const GTime& tstop); explicit GGti(const GXmlElement& xml); @@ -61,8 +61,8 @@ public: void remove(const int& index); void reserve(const int& num); void extend(const GGti& gti); - void load(const std::string& filename); - void save(const std::string& filename, + void load(const GFilename& filename); + void save(const GFilename& filename, const bool& clobber = false) const; void read(const GFitsTable& table); void write(GFits& fits, diff --git a/src/obs/GEbounds.cpp b/src/obs/GEbounds.cpp index 4b6fa93..6b80638 100644 --- a/src/obs/GEbounds.cpp +++ b/src/obs/GEbounds.cpp @@ -83,7 +83,7 @@ GEbounds::GEbounds(void) * * Constructs energy boundaries from a FITS file. ***************************************************************************/ -GEbounds::GEbounds(const std::string& filename) +GEbounds::GEbounds(const GFilename& filename) { // Initialise members init_members(); @@ -576,19 +576,16 @@ void GEbounds::set_log(const int& num, const GEnergy& emin, const GEnergy& emax) * If no extension name is provided, the energy boundaries are loaded from * the "EBOUNDS" extension. ***************************************************************************/ -void GEbounds::load(const std::string& filename) +void GEbounds::load(const GFilename& filename) { - // Create file name - GFilename fname(filename); - // Allocate FITS file GFits file; // Open FITS file - file.open(fname.filename()); + file.open(filename.filename()); // Get energy boundary table - const GFitsTable& table = *file.table(fname.extname("EBOUNDS")); + const GFitsTable& table = *file.table(filename.extname("EBOUNDS")); // Read energy boundaries from table read(table); @@ -613,21 +610,18 @@ void GEbounds::load(const std::string& filename) * If no extension name is provided, the energy boundaries are saved into * an "EBOUNDS" extension. ***************************************************************************/ -void GEbounds::save(const std::string& filename, +void GEbounds::save(const GFilename& filename, const bool& clobber, const std::string& unit) const { - // Create file name - GFilename fname(filename); - // Allocate FITS file GFits file; // Write energy boundaries to FITS file - write(file, fname.extname("EBOUNDS"), unit); + write(file, filename.extname("EBOUNDS"), unit); // Save to file - file.saveto(fname.filename(), clobber); + file.saveto(filename.filename(), clobber); // Return return; diff --git a/src/obs/GGti.cpp b/src/obs/GGti.cpp index c15f4f2..82af803 100644 --- a/src/obs/GGti.cpp +++ b/src/obs/GGti.cpp @@ -62,6 +62,8 @@ /***********************************************************************//** * @brief Void constructor + * + * Constructs empty Good Time Intervals. ***************************************************************************/ GGti::GGti(void) { @@ -80,7 +82,7 @@ GGti::GGti(void) * * Constructs Good Time Intervals from a FITS file. ***************************************************************************/ -GGti::GGti(const std::string& filename) +GGti::GGti(const GFilename& filename) { // Initialise members init_members(); @@ -97,6 +99,8 @@ GGti::GGti(const std::string& filename) * @brief Copy constructor * * @param[in] gti Good Time Intervals. + * + * Constructs Good Time Intervals by coping other Good Time Intervals. ***************************************************************************/ GGti::GGti(const GGti& gti) { @@ -578,19 +582,16 @@ void GGti::extend(const GGti& gti) * If no extension name is provided in the @p filename, the Good Time * Intervals are loaded from the "GTI" extension. ***************************************************************************/ -void GGti::load(const std::string& filename) +void GGti::load(const GFilename& filename) { - // Create file name - GFilename fname(filename); - // Allocate FITS file GFits file; // Open FITS file - file.open(fname.filename()); + file.open(filename.filename()); // Get GTI table - const GFitsTable& table = *file.table(fname.extname("GTI")); + const GFitsTable& table = *file.table(filename.extname("GTI")); // Read GTI from table read(table); @@ -619,16 +620,13 @@ void GGti::load(const std::string& filename) * An existing file will only be modified if the @p clobber flag is set to * true. ***************************************************************************/ -void GGti::save(const std::string& filename, const bool& clobber) const +void GGti::save(const GFilename& filename, const bool& clobber) const { - // Create file name - GFilename fname(filename); - // Open or create FITS file - GFits fits(fname.filename(), true); + GFits fits(filename.filename(), true); // Write GTI to FITS object - write(fits, fname.extname("GTI")); + write(fits, filename.extname("GTI")); // Save to file fits.save(clobber); @@ -835,7 +833,7 @@ void GGti::write(GXmlElement& xml) const if (!m_xml_filename.empty()) { // Write "file" attribute - par->attribute("file", m_xml_filename); + par->attribute("file", m_xml_filename.fullname()); // Write GTI file save(m_xml_filename, true); @@ -1064,7 +1062,7 @@ std::string GGti::print(const GChatter& chatter) const // Optionally append XML filename if (!m_xml_filename.empty()) { result.append("\n"+gammalib::parformat("File name")); - result.append(m_xml_filename); + result.append(m_xml_filename.fullname()); } } // endif: chatter was not silent