diff --git a/NEWS b/NEWS index ef46b7e..afff79b 100644 --- a/NEWS +++ b/NEWS @@ -30,14 +30,20 @@ The following methods have been renamed: - GFilename::is_empty(), was GFilename::empty() - GFilename::url(), was GFilename::filename() -The following classes now use for filenames a GFilename argument instead +The following classes now use GFilename for filenames arguments instead of std::string: +- GApplicationPars +- GArf +- GCsv - GEbounds -- GGti - GEnergies -- GEvents - GEventCube, GCOMEventCube, GCTAEventCube, GLATEventCube, GMWLSpectrum - GEventList, GCTAEventList, GLATEventList +- GEvents +- GGti +- GLog +- GModelSpatialDiffuseCube +- GSkyMap The return value has been changed for the following methods: - GFits::filename() returns now GFilename instead of std::string diff --git a/include/GApplicationPars.hpp b/include/GApplicationPars.hpp index 51673fd..a1c7d3d 100644 --- a/include/GApplicationPars.hpp +++ b/include/GApplicationPars.hpp @@ -1,7 +1,7 @@ /*************************************************************************** * GApplicationPars.hpp - Application parameters * * ----------------------------------------------------------------------- * - * 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 * @@ -33,6 +33,9 @@ #include "GContainer.hpp" #include "GApplicationPar.hpp" +/* __ Forward declarations _______________________________________________ */ +class GFilename; + /***********************************************************************//** * @class GApplicationPars @@ -49,8 +52,8 @@ class GApplicationPars : public GContainer { public: // Constructors and destructors GApplicationPars(void); - explicit GApplicationPars(const std::string& filename); - GApplicationPars(const std::string& filename, + explicit GApplicationPars(const GFilename& filename); + GApplicationPars(const GFilename& filename, const std::vector& args); GApplicationPars(const GApplicationPars& pars); virtual ~GApplicationPars(void); @@ -80,10 +83,10 @@ public: void reserve(const int& num); void extend(const GApplicationPars& pars); bool contains(const std::string& name) const; - void load(const std::string& filename); - void load(const std::string& filename, + void load(const GFilename& filename); + void load(const GFilename& filename, const std::vector& args); - void save(const std::string& filename); + void save(const GFilename& filename); std::string print(const GChatter& chatter = NORMAL) const; protected: diff --git a/include/GArf.hpp b/include/GArf.hpp index 6809e15..00f1952 100644 --- a/include/GArf.hpp +++ b/include/GArf.hpp @@ -1,7 +1,7 @@ /*************************************************************************** * GArf.hpp - XSPEC Auxiliary Response File class * * ----------------------------------------------------------------------- * - * copyright (C) 2013-2015 by Juergen Knoedlseder * + * copyright (C) 2013-2016 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -29,10 +29,14 @@ /* __ Includes ___________________________________________________________ */ #include +#include #include "GBase.hpp" #include "GEbounds.hpp" -#include "GFits.hpp" -#include "GFitsTable.hpp" +#include "GFilename.hpp" + +/* __ Forward declarations _______________________________________________ */ +class GFits; +class GFitsTable; /***********************************************************************//** @@ -45,7 +49,7 @@ class GArf : public GBase { public: // Constructors and destructors GArf(void); - explicit GArf(const std::string& filename); + explicit GArf(const GFilename& filename); explicit GArf(const GEbounds& ebds); GArf(const GArf& arf); virtual ~GArf(void); @@ -56,20 +60,20 @@ public: const double& operator[](const int& index) const; // Methods - void clear(void); - GArf* clone(void) const; - std::string classname(void) const; - int size(void) const; - double& at(const int& index); - const double& at(const int& index) const; - const GEbounds& ebounds(void) const; - void load(const std::string& filename); - void save(const std::string& filename, - const bool& clobber = false) const; - void read(const GFitsTable& table); - void write(GFits& fits) const; - const std::string& filename(void) const; - std::string print(const GChatter& chatter = NORMAL) const; + void clear(void); + GArf* clone(void) const; + std::string classname(void) const; + int size(void) const; + double& at(const int& index); + const double& at(const int& index) const; + const GEbounds& ebounds(void) const; + void load(const GFilename& filename); + void save(const GFilename& filename, + const bool& clobber = false) const; + void read(const GFitsTable& table); + void write(GFits& fits) const; + const GFilename& filename(void) const; + std::string print(const GChatter& chatter = NORMAL) const; protected: // Protected methods @@ -78,7 +82,7 @@ protected: void free_members(void); // Protected members - mutable std::string m_filename; //!< Filename of origin + mutable GFilename m_filename; //!< Filename of origin GEbounds m_ebounds; //!< Energy boundaries std::vector m_specresp; //!< Spectral response }; @@ -163,7 +167,7 @@ const GEbounds& GArf::ebounds(void) const * no load() or save() method has been called before. ***************************************************************************/ inline -const std::string& GArf::filename(void) const +const GFilename& GArf::filename(void) const { return (m_filename); } diff --git a/include/GCsv.hpp b/include/GCsv.hpp index 74160b1..f45e6b7 100644 --- a/include/GCsv.hpp +++ b/include/GCsv.hpp @@ -1,7 +1,7 @@ /*************************************************************************** * GCsv.hpp - Comma-separated values table 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 * @@ -32,6 +32,9 @@ #include #include "GBase.hpp" +/* __ Forward declarations _______________________________________________ */ +class GFilename; + /***********************************************************************//** * @class GCsv @@ -57,7 +60,7 @@ public: // Constructors and destructors GCsv(void); GCsv(const int& nrows, const int& ncols); - GCsv(const std::string& filename, const std::string& sep = " "); + GCsv(const GFilename& filename, const std::string& sep = " "); GCsv(const GCsv& csv); virtual ~GCsv(void); @@ -81,8 +84,8 @@ public: void string(const int& row, const int& col, const std::string& value); void real(const int& row, const int& col, const double& value); void integer(const int& row, const int& col, const int& value); - void load(const std::string& filename, const std::string& sep = " "); - void save(const std::string& filename, const std::string& sep = " ", + void load(const GFilename& filename, const std::string& sep = " "); + void save(const GFilename& filename, const std::string& sep = " ", const bool& clobber = false) const; std::string print(const GChatter& chatter = NORMAL) const; diff --git a/include/GFits.hpp b/include/GFits.hpp index 0fd62fe..56589bf 100644 --- a/include/GFits.hpp +++ b/include/GFits.hpp @@ -65,7 +65,7 @@ class GFits : public GContainer { public: // Constructors and destructors GFits(void); - GFits(const std::string& filename, const bool& create = false); + GFits(const GFilename& filename, const bool& create = false); GFits(const GFits& fits); virtual ~GFits(void); @@ -107,11 +107,11 @@ public: bool contains(const std::string& extname) const; const GFilename& filename(void) const; int extno(const std::string& extname) const; - void open(const std::string& filename, - const bool& create = false); + void open(const GFilename& filename, + const bool& create = false); void save(const bool& clobber = false); - void saveto(const std::string& filename, - const bool& clobber = false); + void saveto(const GFilename& filename, + const bool& clobber = false); void close(void); std::string print(const GChatter& chatter = NORMAL) const; diff --git a/include/GLog.hpp b/include/GLog.hpp index a2a2136..96c3db2 100644 --- a/include/GLog.hpp +++ b/include/GLog.hpp @@ -1,7 +1,7 @@ /*************************************************************************** * GLog.hpp - Information logger * * ----------------------------------------------------------------------- * - * copyright (C) 2010-2013 by Juergen Knoedlseder * + * copyright (C) 2010-2016 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -30,6 +30,7 @@ /* __ Includes ___________________________________________________________ */ #include #include +#include "GFilename.hpp" #include "GTypemaps.hpp" /* __ Forward declarations _______________________________________________ */ @@ -63,7 +64,7 @@ class GLog { public: // Constructors and destructors GLog(void); - GLog(const std::string& filename, const bool& clobber = false); + GLog(const GFilename& filename, const bool& clobber = false); GLog(const GLog& log); virtual ~GLog(void); @@ -85,7 +86,7 @@ public: void clear(void); int size(void) const; std::string classname(void) const; - void open(const std::string& filename, const bool& clobber = false); + void open(const GFilename& filename, const bool& clobber = false); void close(void); void flush(const bool& force = false); void date(const bool& flag); @@ -106,7 +107,7 @@ public: const int& max_size(void) const; const int& indent(void) const; const GChatter& chatter(void) const; - const std::string& filename(void) const; + const GFilename& filename(void) const; protected: // Protected methods @@ -126,7 +127,7 @@ protected: bool m_use_date; //!< Dump date in prefix bool m_linestart; //!< Signals that buffer is at line start FILE* m_file; //!< Log file pointer - std::string m_filename; //!< Log file name + GFilename m_filename; //!< Log file name std::string m_name; //!< Name for prefix std::string m_buffer; //!< Output string buffer GChatter m_chatter; //!< Chattiness for print() method @@ -450,7 +451,7 @@ const GChatter& GLog::chatter(void) const * Returns the filename of the log file. ***************************************************************************/ inline -const std::string& GLog::filename(void) const +const GFilename& GLog::filename(void) const { return m_filename; } diff --git a/include/GModelSpatialDiffuseCube.hpp b/include/GModelSpatialDiffuseCube.hpp index 83622b7..a75c4e3 100644 --- a/include/GModelSpatialDiffuseCube.hpp +++ b/include/GModelSpatialDiffuseCube.hpp @@ -1,7 +1,7 @@ /*************************************************************************** * GModelSpatialDiffuseCube.hpp - Spatial map cube model 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,6 +39,7 @@ #include "GXmlElement.hpp" #include "GEbounds.hpp" #include "GEnergies.hpp" +#include "GFilename.hpp" /* __ Forward declarations _______________________________________________ */ class GFits; @@ -60,8 +61,8 @@ public: // Constructors and destructors GModelSpatialDiffuseCube(void); explicit GModelSpatialDiffuseCube(const GXmlElement& xml); - GModelSpatialDiffuseCube(const std::string& filename, - const double& value = 1.0); + GModelSpatialDiffuseCube(const GFilename& filename, + const double& value = 1.0); GModelSpatialDiffuseCube(const GSkyMap& cube, const GEnergies& energies, const double& value = 1.0); @@ -94,8 +95,8 @@ public: int pixels(void) const; double value(void) const; void value(const double& value); - const std::string& filename(void) const; - void filename(const std::string& filename); + const GFilename& filename(void) const; + void filename(const GFilename& filename); const GSkyMap& cube(void) const; void cube(const GSkyMap& cube); GEnergies energies(void); @@ -103,9 +104,9 @@ public: const GModelSpectralNodes& spectrum(void) const; void set_mc_cone(const GSkyDir& centre, const double& radius) const; - void load(const std::string& filename); - void save(const std::string& filename, - const bool& clobber = false) const; + void load(const GFilename& filename); + void save(const GFilename& filename, + const bool& clobber = false) const; //void read(const GFits& file); void write(GFits& file) const; @@ -115,18 +116,18 @@ protected: void copy_members(const GModelSpatialDiffuseCube& model); void free_members(void); void fetch_cube(void) const; - void load_cube(const std::string& filename); + void load_cube(const GFilename& filename); void set_energy_boundaries(void); void update_mc_cache(void); double cube_intensity(const GPhoton& photon) const; // Protected members - GModelPar m_value; //!< Value - std::string m_filename; //!< Name of map cube - bool m_loaded; //!< Signals if map cube has been loaded - GSkyMap m_cube; //!< Map cube - GNodeArray m_logE; //!< Log10(energy) values of the maps - GEbounds m_ebounds; //!< Energy bounds of the maps + GModelPar m_value; //!< Value + GFilename m_filename; //!< Name of map cube + bool m_loaded; //!< Signals if map cube has been loaded + GSkyMap m_cube; //!< Map cube + GNodeArray m_logE; //!< Log10(energy) values of the maps + GEbounds m_ebounds; //!< Energy bounds of the maps // Monte Carlo cache mutable std::vector m_mc_cache; //!< Monte Carlo cache @@ -226,7 +227,7 @@ void GModelSpatialDiffuseCube::value(const double& value) * Returns the file name of the spatial map cube model. ***************************************************************************/ inline -const std::string& GModelSpatialDiffuseCube::filename(void) const +const GFilename& GModelSpatialDiffuseCube::filename(void) const { return (m_filename); } @@ -240,7 +241,7 @@ const std::string& GModelSpatialDiffuseCube::filename(void) const * Set the file name of the spatial map cube model. ***************************************************************************/ inline -void GModelSpatialDiffuseCube::filename(const std::string& filename) +void GModelSpatialDiffuseCube::filename(const GFilename& filename) { m_filename = filename; return; diff --git a/include/GSkyMap.hpp b/include/GSkyMap.hpp index c5a9218..de28ff4 100644 --- a/include/GSkyMap.hpp +++ b/include/GSkyMap.hpp @@ -33,15 +33,27 @@ #include "GSkyDir.hpp" #include "GSkyPixel.hpp" #include "GSkyProjection.hpp" +/* #include "GFits.hpp" #include "GFitsTable.hpp" #include "GFitsBinTable.hpp" #include "GFitsImage.hpp" #include "GFitsImageDouble.hpp" -#include "GMatrix.hpp" -#include "GVector.hpp" +*/ +//#include "GMatrix.hpp" +//#include "GVector.hpp" #include "GBilinear.hpp" +/* __ Forward declarations _______________________________________________ */ +class GFilename; +class GFits; +class GFitsTable; +class GFitsBinTable; +class GFitsImage; +class GFitsImageDouble; +class GMatrix; +class GVector; + /***********************************************************************//** * @class GSkyMap @@ -84,20 +96,20 @@ class GSkyMap : public GBase { public: // Constructors and destructors GSkyMap(void); - explicit GSkyMap(const std::string& filename); - explicit GSkyMap(const std::string& coords, - const int& nside, - const std::string& order, - const int& nmaps = 1); - explicit GSkyMap(const std::string& wcs, - const std::string& coords, - const double& x, - const double& y, - const double& dx, - const double& dy, - const int& nx, - const int& ny, - const int& nmaps = 1); + explicit GSkyMap(const GFilename& filename); + GSkyMap(const std::string& coords, + const int& nside, + const std::string& order, + const int& nmaps = 1); + GSkyMap(const std::string& wcs, + const std::string& coords, + const double& x, + const double& y, + const double& dx, + const double& dy, + const int& nx, + const int& ny, + const int& nmaps = 1); GSkyMap(const GSkyMap& map); virtual ~GSkyMap(void); @@ -148,8 +160,8 @@ public: const double* pixels(void) const; GSkyMap extract(const int& map, const int& nmaps = 1) const; void stack_maps(void); - void load(const std::string& filename); - void save(const std::string& filename, bool clobber = false) const; + void load(const GFilename& filename); + void save(const GFilename& filename, bool clobber = false) const; void read(const GFitsHDU& hdu); void write(GFits& file) const; std::string print(const GChatter& chatter = NORMAL) const; diff --git a/inst/cta/src/GCTAOnOffObservation.cpp b/inst/cta/src/GCTAOnOffObservation.cpp index 673af46..eb0c380 100644 --- a/inst/cta/src/GCTAOnOffObservation.cpp +++ b/inst/cta/src/GCTAOnOffObservation.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * GCTAOnOffObservation.cpp - CTA on-off observation class * * ----------------------------------------------------------------------- * - * copyright (C) 2014 by Chia-Chun Lu & Christoph Deil * + * copyright (C) 2014-2016 by Chia-Chun Lu & Christoph Deil * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -412,7 +412,7 @@ void GCTAOnOffObservation::write(GXmlElement& xml) const // Handle effective area else if (par->attribute("name") == "Arf") { - par->attribute("file", m_arf.filename()); + par->attribute("file", m_arf.filename().url()); npar[4]++; } diff --git a/pyext/GApplicationPars.i b/pyext/GApplicationPars.i index f1dae19..abf7792 100644 --- a/pyext/GApplicationPars.i +++ b/pyext/GApplicationPars.i @@ -1,7 +1,7 @@ /*************************************************************************** * GApplicationPars.i - Application parameter container * * ----------------------------------------------------------------------- * - * 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 * @@ -27,6 +27,7 @@ /* Put headers and other declarations here that are needed for compilation */ #include "GApplicationPars.hpp" #include "GException.hpp" +#include "GFilename.hpp" %} @@ -40,8 +41,8 @@ class GApplicationPars : public GBase { public: // Constructors and destructors GApplicationPars(void); - explicit GApplicationPars(const std::string& filename); - GApplicationPars(const std::string& filename, + explicit GApplicationPars(const GFilename& filename); + GApplicationPars(const GFilename& filename, const std::vector& args); GApplicationPars(const GApplicationPars& pars); virtual ~GApplicationPars(void); @@ -63,10 +64,10 @@ public: void reserve(const int& num); void extend(const GApplicationPars& pars); bool contains(const std::string& name) const; - void load(const std::string& filename); - void load(const std::string& filename, + void load(const GFilename& filename); + void load(const GFilename& filename, const std::vector& args); - void save(const std::string& filename); + void save(const GFilename& filename); }; diff --git a/pyext/GArf.i b/pyext/GArf.i index da3f803..c9476aa 100644 --- a/pyext/GArf.i +++ b/pyext/GArf.i @@ -1,7 +1,7 @@ /*************************************************************************** * GArf.i - XSPEC Auxiliary Response File class * * ----------------------------------------------------------------------- * - * copyright (C) 2013-2015 by Juergen Knoedlseder * + * copyright (C) 2013-2016 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -39,23 +39,25 @@ class GArf : public GBase { public: // Constructors and destructors GArf(void); - explicit GArf(const std::string& filename); + explicit GArf(const GFilename& filename); explicit GArf(const GEbounds& ebds); GArf(const GArf& arf); virtual ~GArf(void); // Methods - void clear(void); - GArf* clone(void) const; - std::string classname(void) const; - int size(void) const; - double& at(const int& index); - const GEbounds& ebounds(void) const; - void load(const std::string& filename); - void save(const std::string& filename, - const bool& clobber = false) const; - void read(const GFitsTable& table); - void write(GFits& fits) const; + void clear(void); + GArf* clone(void) const; + std::string classname(void) const; + int size(void) const; + double& at(const int& index); + const double& at(const int& index) const; + const GEbounds& ebounds(void) const; + void load(const GFilename& filename); + void save(const GFilename& filename, + const bool& clobber = false) const; + void read(const GFitsTable& table); + void write(GFits& fits) const; + const GFilename& filename(void) const; }; diff --git a/pyext/GCsv.i b/pyext/GCsv.i index 3a9645c..04cbfae 100644 --- a/pyext/GCsv.i +++ b/pyext/GCsv.i @@ -1,7 +1,7 @@ /*************************************************************************** * GCsv.i - Comma-separated values table 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 * @@ -87,7 +87,7 @@ public: // Constructors and destructors GCsv(void); GCsv(const int& nrows, const int& ncols); - GCsv(const std::string& filename, const std::string& sep = " "); + GCsv(const GFilename& filename, const std::string& sep = " "); GCsv(const GCsv& csv); virtual ~GCsv(void); @@ -106,8 +106,8 @@ public: void string(const int& row, const int& col, const std::string& value); void real(const int& row, const int& col, const double& value); void integer(const int& row, const int& col, const int& value); - void load(const std::string& filename, const std::string& sep = " "); - void save(const std::string& filename, const std::string& sep = " ", + void load(const GFilename& filename, const std::string& sep = " "); + void save(const GFilename& filename, const std::string& sep = " ", const bool& clobber = false) const; }; diff --git a/pyext/GFits.i b/pyext/GFits.i index f952311..40b6685 100644 --- a/pyext/GFits.i +++ b/pyext/GFits.i @@ -53,7 +53,7 @@ class GFits : public GContainer { public: // Constructors and destructors GFits(void); - GFits(const std::string& filename, const bool& create = false); + GFits(const GFilename& filename, const bool& create = false); GFits(const GFits& fits); virtual ~GFits(void); @@ -82,11 +82,11 @@ public: bool contains(const std::string& extname) const; const GFilename& filename(void) const; int extno(const std::string& extname) const; - void open(const std::string& filename, - const bool& create = false); + void open(const GFilename& filename, + const bool& create = false); void save(const bool& clobber = false); - void saveto(const std::string& filename, - const bool& clobber = false); + void saveto(const GFilename& filename, + const bool& clobber = false); void close(void); }; diff --git a/pyext/GLog.i b/pyext/GLog.i index 3b73552..ae62837 100644 --- a/pyext/GLog.i +++ b/pyext/GLog.i @@ -1,7 +1,7 @@ /*************************************************************************** * GLog.i - Information logger * * ----------------------------------------------------------------------- * - * 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 GLog { public: // Constructors and destructors GLog(void); - GLog(const std::string& filename, const bool& clobber = false); + GLog(const GFilename& filename, const bool& clobber = false); GLog(const GLog& log); virtual ~GLog(void); @@ -47,7 +47,7 @@ public: void clear(void); int size(void) const; std::string classname(void) const; - void open(const std::string& filename, const bool& clobber = false); + void open(const GFilename& filename, const bool& clobber = false); void close(void); void flush(const bool& force = false); void date(const bool& flag); @@ -68,7 +68,7 @@ public: const int& max_size(void) const; const int& indent(void) const; const GChatter& chatter(void) const; - const std::string& filename(void) const; + const GFilename& filename(void) const; }; diff --git a/pyext/GModelSpatialDiffuseCube.i b/pyext/GModelSpatialDiffuseCube.i index 017b2b3..cfe3cc6 100644 --- a/pyext/GModelSpatialDiffuseCube.i +++ b/pyext/GModelSpatialDiffuseCube.i @@ -1,7 +1,7 @@ /*************************************************************************** * GModelSpatialDiffuseCube.i - Spatial map cube model class * * ----------------------------------------------------------------------- * - * copyright (C) 2011-2015 by Juergen Knoedlseder * + * copyright (C) 2011-2016 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -39,8 +39,8 @@ public: // Constructors and destructors GModelSpatialDiffuseCube(void); explicit GModelSpatialDiffuseCube(const GXmlElement& xml); - GModelSpatialDiffuseCube(const std::string& filename, - const double& value = 1.0); + GModelSpatialDiffuseCube(const GFilename& filename, + const double& value = 1.0); GModelSpatialDiffuseCube(const GSkyMap& map, const GEnergies& energies, const double& value = 1.0); @@ -69,8 +69,8 @@ public: int pixels(void) const; double value(void) const; void value(const double& value); - const std::string& filename(void) const; - void filename(const std::string& filename); + const GFilename& filename(void) const; + void filename(const GFilename& filename); const GSkyMap& cube(void) const; void cube(const GSkyMap& cube); GEnergies energies(void); @@ -78,8 +78,8 @@ public: const GModelSpectralNodes& spectrum(void) const; void set_mc_cone(const GSkyDir& centre, const double& radius) const; - 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 GFits& file); void write(GFits& file) const; diff --git a/pyext/GSkyMap.i b/pyext/GSkyMap.i index 1922686..bf6d893 100644 --- a/pyext/GSkyMap.i +++ b/pyext/GSkyMap.i @@ -1,7 +1,7 @@ /*************************************************************************** * GSkyMap.i - Sky map 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 * @@ -110,20 +110,20 @@ class GSkyMap : public GBase { public: // Constructors and destructors GSkyMap(void); - explicit GSkyMap(const std::string& filename); - explicit GSkyMap(const std::string& coords, - const int& nside, - const std::string& order, - const int& nmaps = 1); - explicit GSkyMap(const std::string& wcs, - const std::string& coords, - const double& x, - const double& y, - const double& dx, - const double& dy, - const int& nx, - const int& ny, - const int& nmaps = 1); + explicit GSkyMap(const GFilename& filename); + GSkyMap(const std::string& coords, + const int& nside, + const std::string& order, + const int& nmaps = 1); + GSkyMap(const std::string& wcs, + const std::string& coords, + const double& x, + const double& y, + const double& dx, + const double& dy, + const int& nx, + const int& ny, + const int& nmaps = 1); GSkyMap(const GSkyMap& map); virtual ~GSkyMap(void); @@ -168,8 +168,8 @@ public: const double* pixels(void) const; GSkyMap extract(const int& map, const int& nmaps = 1) const; void stack_maps(void); - void load(const std::string& filename); - void save(const std::string& filename, bool clobber = false) const; + void load(const GFilename& filename); + void save(const GFilename& filename, bool clobber = false) const; void read(const GFitsHDU& hdu); void write(GFits& file) const; }; diff --git a/src/app/GApplicationPars.cpp b/src/app/GApplicationPars.cpp index 7effd5b..376a81b 100644 --- a/src/app/GApplicationPars.cpp +++ b/src/app/GApplicationPars.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * GApplicationPars.cpp - Application parameters * * ----------------------------------------------------------------------- * - * 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 * @@ -34,9 +34,10 @@ #include // mkdir() function #include // std::getenv() function #include // std::fopen(), etc. functions -#include "GApplicationPars.hpp" #include "GTools.hpp" #include "GException.hpp" +#include "GFilename.hpp" +#include "GApplicationPars.hpp" /* __ Method name definitions ____________________________________________ */ #define G_ACCESS "GApplicationPars::operator[](std::string&)" @@ -49,10 +50,10 @@ #define G_REMOVE1 "GApplicationPars::remove(int&)" #define G_REMOVE2 "GApplicationPars::remove(std::string&)" #define G_EXTEND "GApplicationPars::extend(GApplicationPars&)" -#define G_LOAD1 "GApplicationPars::load(std::string&)" -#define G_LOAD2 "GApplicationPars::load(std::string&, "\ +#define G_LOAD1 "GApplicationPars::load(GFilename&)" +#define G_LOAD2 "GApplicationPars::load(GFilename&, "\ "std::vector&)" -#define G_SAVE "GApplicationPars::save(std::string&)" +#define G_SAVE "GApplicationPars::save(GFilename&)" #define G_OUTPATH "GApplicationPars::outpath(std::string&)" #define G_READ "GApplicationPars::read(std::string&)" #define G_WRITE "GApplicationPars::write(std::string&)" @@ -91,7 +92,7 @@ GApplicationPars::GApplicationPars(void) * * @param[in] filename Parameter filename. ***************************************************************************/ -GApplicationPars::GApplicationPars(const std::string& filename) +GApplicationPars::GApplicationPars(const GFilename& filename) { // Initialise private members for clean destruction init_members(); @@ -109,7 +110,8 @@ GApplicationPars::GApplicationPars(const std::string& filename) * @param[in] filename Parameter filename. * @param[in] args Command line arguments. ***************************************************************************/ -GApplicationPars::GApplicationPars(const std::string& filename, const std::vector& args) +GApplicationPars::GApplicationPars(const GFilename& filename, + const std::vector& args) { // Initialise private members for clean destruction init_members(); @@ -631,15 +633,15 @@ bool GApplicationPars::contains(const std::string& name) const * * Loads all parameters from parameter file. ***************************************************************************/ -void GApplicationPars::load(const std::string& filename) +void GApplicationPars::load(const GFilename& filename) { // Reset parameters m_parfile.clear(); // Get path to parameter file for input - std::string path = inpath(filename); + std::string path = inpath(filename.url()); if (path.length() == 0) { - throw GException::par_file_not_found(G_LOAD1, filename); + throw GException::par_file_not_found(G_LOAD1, filename.url()); } // Read parfile @@ -667,16 +669,16 @@ void GApplicationPars::load(const std::string& filename) * Loads all parameters from parameter file. Parameters are overwritten by * the values specified in the command line arguments. ***************************************************************************/ -void GApplicationPars::load(const std::string& filename, - const std::vector& args) +void GApplicationPars::load(const GFilename& filename, + const std::vector& args) { // Reset parameters m_parfile.clear(); // Get path to parameter file for input - std::string path = inpath(filename); + std::string path = inpath(filename.url()); if (path.length() == 0) { - throw GException::par_file_not_found(G_LOAD2, filename); + throw GException::par_file_not_found(G_LOAD2, filename.url()); } // Read parfile @@ -741,12 +743,12 @@ void GApplicationPars::load(const std::string& filename, * @exception GException::par_file_not_found * No valid directory to write the parameter file has been found. ***************************************************************************/ -void GApplicationPars::save(const std::string& filename) +void GApplicationPars::save(const GFilename& filename) { // Get path to parameter file for output - std::string path = outpath(filename); + std::string path = outpath(filename.url()); if (path.size() == 0) { - throw GException::par_file_not_found(G_SAVE, filename); + throw GException::par_file_not_found(G_SAVE, filename.url()); } // Update parameter file diff --git a/src/app/GLog.cpp b/src/app/GLog.cpp index 98acc47..3cf5d31 100644 --- a/src/app/GLog.cpp +++ b/src/app/GLog.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * GLog.cpp - Information logger * * ----------------------------------------------------------------------- * - * copyright (C) 2010-2014 by Juergen Knoedlseder * + * copyright (C) 2010-2016 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -75,7 +75,7 @@ GLog::GLog(void) * * Construct a logger with an open log file. ***************************************************************************/ -GLog::GLog(const std::string& filename, const bool& clobber) +GLog::GLog(const GFilename& filename, const bool& clobber) { // Initialise private members for clean destruction init_members(); @@ -212,13 +212,13 @@ GLog& GLog::operator<<(GLog& log) log.flush(true); // Get the filename - std::string filename = log.filename(); + GFilename filename = log.filename(); // Close log's file log.close(); // Open log's file in read mode - std::ifstream file(filename.c_str(), std::ios::in); + std::ifstream file(filename.url().c_str(), std::ios::in); if (file) { // Append all lines from file to this buffer @@ -232,7 +232,7 @@ GLog& GLog::operator<<(GLog& log) } // Open log's file in append mode - log.open(filename,false); + log.open(filename, false); } // Flush @@ -477,7 +477,7 @@ int GLog::size(void) const * Opens a file for logging. If a log file was already open it is closed * before opening a new file. ***************************************************************************/ -void GLog::open(const std::string& filename, const bool& clobber) +void GLog::open(const GFilename& filename, const bool& clobber) { // Store the filename m_filename = filename; @@ -487,10 +487,10 @@ void GLog::open(const std::string& filename, const bool& clobber) // Open file if (clobber) { - m_file = std::fopen(filename.c_str(), "w"); + m_file = std::fopen(filename.url().c_str(), "w"); } else { - m_file = std::fopen(filename.c_str(), "a"); + m_file = std::fopen(filename.url().c_str(), "a"); } // Return diff --git a/src/fits/GFits.cpp b/src/fits/GFits.cpp index c0e7fcf..7d4da74 100644 --- a/src/fits/GFits.cpp +++ b/src/fits/GFits.cpp @@ -80,6 +80,8 @@ /***********************************************************************//** * @brief Void constructor + * + * Constructs empty FITS file. ***************************************************************************/ GFits::GFits(void) { @@ -100,7 +102,7 @@ GFits::GFits(void) * Construct an object by opening a FITS file. If the file does not exist it * will be created if @p create is set to true. ***************************************************************************/ -GFits::GFits(const std::string& filename, const bool& create) +GFits::GFits(const GFilename& filename, const bool& create) { // Initialise class members init_members(); @@ -1009,23 +1011,23 @@ int GFits::extno(const std::string& extname) const * hdu(int extno) method. * Any environment variable present in the filename will be expanded. ***************************************************************************/ -void GFits::open(const std::string& filename, const bool& create) +void GFits::open(const GFilename& filename, const bool& create) { // Remove any HDUs m_hdu.clear(); // Expand environment variables - std::string fname(gammalib::expand_env(filename)); + std::string fname(gammalib::expand_env(filename())); // Don't allow opening if a file is already open if (m_fitsfile != NULL) { std::string msg; - if (m_filename.filename() == GFilename(fname).filename()) { - msg = "FITS file \""+m_filename.filename()+"\" has already been " + if (m_filename.url() == GFilename(fname).url()) { + msg = "FITS file \""+m_filename.url()+"\" has already been " "opened, cannot open it again."; } else { - msg = "A FITS file \""+m_filename.filename()+"\" has already " + msg = "A FITS file \""+m_filename.url()+"\" has already " "been opened, cannot open another FITS file \""+ fname+"\" before closing the existing one."; } @@ -1146,7 +1148,7 @@ void GFits::save(const bool& clobber) // If we attempt to save an existing file without overwriting permission // then throw an error if (!m_created && !clobber) { - throw GException::fits_file_exist(G_SAVE, m_filename.filename()); + throw GException::fits_file_exist(G_SAVE, m_filename.url()); } // If no FITS file has been opened then throw an error @@ -1223,10 +1225,10 @@ void GFits::save(const bool& clobber) * Saves object into a specific FITS file. * Any environment variable present in the filename will be expanded. ***************************************************************************/ -void GFits::saveto(const std::string& filename, const bool& clobber) +void GFits::saveto(const GFilename& filename, const bool& clobber) { // Expand environment variables - std::string fname = gammalib::expand_env(filename); + std::string fname = gammalib::expand_env(filename()); // Create gzipped file name version std::string gzfname = fname + ".gz"; @@ -1320,7 +1322,7 @@ std::string GFits::print(const GChatter& chatter) const // Append file information result.append("\n"+gammalib::parformat("Filename")); - result.append(m_filename.filename()); + result.append(m_filename.url()); result.append("\n"+gammalib::parformat("History")); if (m_created) { result.append("new file"); diff --git a/src/model/GModelSpatialDiffuseCube.cpp b/src/model/GModelSpatialDiffuseCube.cpp index c9c19bb..f500ab6 100644 --- a/src/model/GModelSpatialDiffuseCube.cpp +++ b/src/model/GModelSpatialDiffuseCube.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * GModelSpatialDiffuseCube.cpp - Spatial map cube model 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 * @@ -51,7 +51,7 @@ const GModelSpatialRegistry g_spatial_cube_registry(&g_spatial_cube_seed); #define G_READ "GModelSpatialDiffuseCube::read(GXmlElement&)" #define G_WRITE "GModelSpatialDiffuseCube::write(GXmlElement&)" #define G_ENERGIES "GModelSpatialDiffuseCube::energies(GEnergies&)" -#define G_LOAD_CUBE "GModelSpatialDiffuseCube::load_cube()" +#define G_LOAD_CUBE "GModelSpatialDiffuseCube::load_cube(GFilename&)" /* __ Macros _____________________________________________________________ */ @@ -113,8 +113,8 @@ GModelSpatialDiffuseCube::GModelSpatialDiffuseCube(const GXmlElement& xml) : * Constructs map cube model by loading a map cube from @p filename and by * assigning the normalization @p value. ***************************************************************************/ -GModelSpatialDiffuseCube::GModelSpatialDiffuseCube(const std::string& filename, - const double& value) : +GModelSpatialDiffuseCube::GModelSpatialDiffuseCube(const GFilename& filename, + const double& value) : GModelSpatialDiffuse() { // Initialise members @@ -649,7 +649,7 @@ void GModelSpatialDiffuseCube::write(GXmlElement& xml) const } // Set filename - xml.attribute("file", m_filename); + xml.attribute("file", m_filename.url()); // Return return; @@ -975,7 +975,7 @@ void GModelSpatialDiffuseCube::set_mc_cone(const GSkyDir& centre, * * Loads cube into the model class. ***************************************************************************/ -void GModelSpatialDiffuseCube::load(const std::string& filename) +void GModelSpatialDiffuseCube::load(const GFilename& filename) { // Load cube load_cube(filename); @@ -992,12 +992,12 @@ void GModelSpatialDiffuseCube::load(const std::string& filename) * @brief Save cube into FITS file * * @param[in] filename Cube FITS file name. - * @param[in] clobber Overwrite existing FITS file (default=false). + * @param[in] clobber Overwrite existing FITS file (default: false). * * Saves spatial cube model into a FITS file. ***************************************************************************/ -void GModelSpatialDiffuseCube::save(const std::string& filename, - const bool& clobber) const +void GModelSpatialDiffuseCube::save(const GFilename& filename, + const bool& clobber) const { // Create empty FITS file GFits fits; @@ -1056,7 +1056,8 @@ std::string GModelSpatialDiffuseCube::print(const GChatter& chatter) const result.append("=== GModelSpatialDiffuseCube ==="); // Append parameters - result.append("\n"+gammalib::parformat("Map cube file")+m_filename); + result.append("\n"+gammalib::parformat("Map cube file")); + result.append(m_filename.url()); if (m_loaded) { result.append(" [loaded]"); } @@ -1210,7 +1211,7 @@ void GModelSpatialDiffuseCube::free_members(void) void GModelSpatialDiffuseCube::fetch_cube(void) const { // Load cube if it is not yet loaded - if (!m_loaded && !m_filename.empty()) { + if (!m_loaded && !m_filename.is_empty()) { // Put in a OMP critical zone #pragma omp critical @@ -1235,7 +1236,7 @@ void GModelSpatialDiffuseCube::fetch_cube(void) const * * Load diffuse cube. ***************************************************************************/ -void GModelSpatialDiffuseCube::load_cube(const std::string& filename) +void GModelSpatialDiffuseCube::load_cube(const GFilename& filename) { // Initialise skymap m_cube.clear(); @@ -1248,13 +1249,14 @@ void GModelSpatialDiffuseCube::load_cube(const std::string& filename) m_filename = filename; // Get expanded filename - std::string fname = gammalib::expand_env(filename); + //std::string fname = gammalib::expand_env(filename); // Load cube - m_cube.load(fname); + //m_cube.load(fname); + m_cube.load(filename); // Load energies - GEnergies energies(fname); + GEnergies energies(filename); // Extract number of energy bins int num = energies.size(); diff --git a/src/sky/GSkyMap.cpp b/src/sky/GSkyMap.cpp index edd9ed9..bd83ef7 100644 --- a/src/sky/GSkyMap.cpp +++ b/src/sky/GSkyMap.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * GSkyMap.cpp - Sky map 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 * @@ -31,13 +31,18 @@ #include "GException.hpp" #include "GMath.hpp" #include "GTools.hpp" +#include "GFits.hpp" +#include "GFitsTable.hpp" +#include "GFitsBinTable.hpp" +#include "GFitsImage.hpp" +#include "GFitsImageDouble.hpp" +#include "GFitsTableDoubleCol.hpp" #include "GSkyMap.hpp" #include "GHealpix.hpp" #include "GWcsRegistry.hpp" #include "GWcs.hpp" -#include "GFits.hpp" -#include "GFitsTableDoubleCol.hpp" -#include "GFitsImageDouble.hpp" +#include "GMatrix.hpp" +#include "GVector.hpp" /* __ Method name definitions ____________________________________________ */ #define G_CONSTRUCT_HPX "GSkyMap::GSkyMap(std::string&, int&,"\ @@ -105,7 +110,7 @@ GSkyMap::GSkyMap(void) * * @param[in] filename FITS file name. ***************************************************************************/ -GSkyMap::GSkyMap(const std::string& filename) +GSkyMap::GSkyMap(const GFilename& filename) { // Initialise class members for clean destruction init_members(); @@ -1739,7 +1744,7 @@ void GSkyMap::stack_maps(void) * @todo Do we have to restrict a HEALPix map to a BinTable and a WCS map * to a Double precision image??? ***************************************************************************/ -void GSkyMap::load(const std::string& filename) +void GSkyMap::load(const GFilename& filename) { // Free memory and initialise members free_members(); @@ -1808,7 +1813,7 @@ void GSkyMap::load(const std::string& filename) * * The method does nothing if the skymap holds no valid WCS. ***************************************************************************/ -void GSkyMap::save(const std::string& filename, bool clobber) const +void GSkyMap::save(const GFilename& filename, bool clobber) const { // Continue only if we have data to save if (m_proj != NULL) { diff --git a/src/support/GCsv.cpp b/src/support/GCsv.cpp index 0c3c13a..7134224 100644 --- a/src/support/GCsv.cpp +++ b/src/support/GCsv.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * GCsv.cpp - Comma-separated values table 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 * @@ -31,12 +31,13 @@ #include // std::fopen, std::fgets, std::fclose, etc... #include "GCsv.hpp" #include "GTools.hpp" +#include "GFilename.hpp" #include "GException.hpp" /* __ Method name definitions ____________________________________________ */ #define G_ACCESS "GCsv::operator()(int&, int&)" -#define G_LOAD "GCsv::load(std::string&, std::string&)" -#define G_SAVE "GCsv::save(std::string&, std::string&, bool&)" +#define G_LOAD "GCsv::load(GFilename&, std::string&)" +#define G_SAVE "GCsv::save(GFilename&, std::string&, bool&)" /* __ Macros _____________________________________________________________ */ @@ -96,7 +97,7 @@ GCsv::GCsv(const int& nrows, const int& ncols) * @param[in] filename Filename. * @param[in] sep Column separator (default is whitespace). ***************************************************************************/ -GCsv::GCsv(const std::string& filename, const std::string& sep) +GCsv::GCsv(const GFilename& filename, const std::string& sep) { // Initialise private init_members(); @@ -370,7 +371,7 @@ void GCsv::integer(const int& row, const int& col, const int& value) * Load CSV table from ASCII file. Any environment variable present in the * filename will be expanded. **************************************************************************/ -void GCsv::load(const std::string& filename, const std::string& sep) +void GCsv::load(const GFilename& filename, const std::string& sep) { // Clear instance clear(); @@ -380,7 +381,7 @@ void GCsv::load(const std::string& filename, const std::string& sep) char line[n]; // Expand environment variables - std::string fname = gammalib::expand_env(filename); + std::string fname = gammalib::expand_env(filename.url()); // Open CSV table (read-only) FILE* fptr = std::fopen(fname.c_str(), "r"); @@ -456,25 +457,26 @@ void GCsv::load(const std::string& filename, const std::string& sep) * Save CSV table into ASCII file. Any environment variable present in the * filename will be expanded. **************************************************************************/ -void GCsv::save(const std::string& filename, const std::string& sep, - const bool& clobber) const +void GCsv::save(const GFilename& filename, + const std::string& sep, + const bool& clobber) const { // Throw exception if file exists but clobber flag is false - if (!clobber && gammalib::file_exists(filename)) { - std::string msg = "File \""+filename+"\" exists already but the " - "clobber flag is set to \"false\". Set the " + if (!clobber && gammalib::file_exists(filename.url())) { + std::string msg = "File \""+filename.url()+"\" exists already but " + "the clobber flag is set to \"false\". Set the " "clobber flag to true to overwrite the existing " "file or specify another file name."; throw GException::invalid_value(G_SAVE, msg); } // Expand environment variables - std::string fname = gammalib::expand_env(filename); + std::string fname = gammalib::expand_env(filename.url()); // Open CSV table (write-only) FILE* fptr = std::fopen(fname.c_str(), "w"); if (fptr == NULL) { - std::string msg = "Unable to create file \""+filename+"\"."; + std::string msg = "Unable to create file \""+filename.url()+"\"."; throw GException::file_error(G_SAVE, msg); } diff --git a/src/xspec/GArf.cpp b/src/xspec/GArf.cpp index e371920..cd311ba 100644 --- a/src/xspec/GArf.cpp +++ b/src/xspec/GArf.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * GArf.cpp - XSPEC Auxiliary Response File class * * ----------------------------------------------------------------------- * - * copyright (C) 2013 by Juergen Knoedlseder * + * copyright (C) 2013-2016 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -30,7 +30,10 @@ #endif #include "GArf.hpp" #include "GException.hpp" +#include "GFilename.hpp" #include "GTools.hpp" +#include "GFits.hpp" +#include "GFitsTable.hpp" #include "GFitsBinTable.hpp" #include "GFitsTableShortCol.hpp" #include "GFitsTableFloatCol.hpp" @@ -69,7 +72,7 @@ GArf::GArf(void) * * @param[in] filename File name. ***************************************************************************/ -GArf::GArf(const std::string& filename) +GArf::GArf(const GFilename& filename) { // Initialise members init_members(); @@ -250,7 +253,7 @@ const double& GArf::at(const int& index) const * * @param[in] filename File name. ***************************************************************************/ -void GArf::load(const std::string& filename) +void GArf::load(const GFilename& filename) { // Clear any existing models clear(); @@ -279,9 +282,9 @@ void GArf::load(const std::string& filename) * @brief Save Auxiliary Response File * * @param[in] filename File name. - * @param[in] clobber Overwrite existing file? (defaults to true) + * @param[in] clobber Overwrite existing file? (defaults: false) ***************************************************************************/ -void GArf::save(const std::string& filename, const bool& clobber) const +void GArf::save(const GFilename& filename, const bool& clobber) const { // Open FITS file GFits fits; diff --git a/test/test_GModel.cpp b/test/test_GModel.cpp index cdbfe94..bbddf81 100644 --- a/test/test_GModel.cpp +++ b/test/test_GModel.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * test_GModel.cpp - test GModel 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 * @@ -584,7 +584,7 @@ void TestGModel::test_diffuse_cube(void) GModelSpatialDiffuseCube model; test_assert(model.type() == "MapCubeFunction", "Model type \"MapCubeFunction\" expected."); - test_assert(model.filename() == "", "Model filename \"\" expected."); + test_assert(model.filename().url() == "", "Model filename \"\" expected."); test_try_success(); } catch (std::exception &e) { @@ -596,7 +596,8 @@ void TestGModel::test_diffuse_cube(void) try { GModelSpatialDiffuseCube model(m_cube_file, 3.0); test_value(model.value(), 3.0); - test_assert(model.filename() == m_cube_file, "Expected \""+m_cube_file+"\""); + test_assert(model.filename().url() == m_cube_file, + "Expected \""+m_cube_file+"\""); test_try_success(); } catch (std::exception &e) { @@ -613,7 +614,7 @@ void TestGModel::test_diffuse_cube(void) } GModelSpatialDiffuseCube model(map, energies, 3.0); test_value(model.value(), 3.0); - test_assert(model.filename() == "", "Expected \"\""); + test_assert(model.filename().url() == "", "Expected \"\""); //test_assert(model.cube() == map, "Map cube is not the expected one"); test_try_success(); } @@ -631,8 +632,8 @@ void TestGModel::test_diffuse_cube(void) test_value(model.size(), 1); test_assert(model.type() == "MapCubeFunction", "Expected \"MapCubeFunction\""); test_value(model.value(), 1.0); - test_assert(model.filename() == m_cube_file, - "Model filename \""+m_cube_file+"\" expected."); + test_assert(model.filename().url() == m_cube_file, + "Model filename \""+m_cube_file+"\" expected."); // Test value method model.value(3.9); @@ -640,8 +641,8 @@ void TestGModel::test_diffuse_cube(void) // Test filename method model.filename("Help me!"); - test_assert(model.filename() == "Help me!", - "Model filename \"Help me!\" expected."); + test_assert(model.filename().url() == "Help me!", + "Model filename \"Help me!\" expected."); // Test cube method model.cube(GSkyMap("GAL", 16, "RING", 10)); diff --git a/test/test_GXspec.cpp b/test/test_GXspec.cpp index 13278d9..e95cd3b 100644 --- a/test/test_GXspec.cpp +++ b/test/test_GXspec.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * test_GXspec.hpp - Test Xspec module * * ----------------------------------------------------------------------- * - * copyright (C) 2013 by Juergen Knoedlseder * + * copyright (C) 2013-2016 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -210,11 +210,11 @@ void TestGXspec::test_GArf(void) // Test saving and loading arf.save("arf.fits", true); - test_assert(arf.filename() == "arf.fits", - "Unexpected filename \""+arf.filename()+"\"."); + test_assert(arf.filename().url() == "arf.fits", + "Unexpected filename \""+arf.filename().url()+"\"."); arf.load("arf.fits"); - test_assert(arf.filename() == "arf.fits", - "Unexpected filename \""+arf.filename()+"\"."); + test_assert(arf.filename().url() == "arf.fits", + "Unexpected filename \""+arf.filename().url()+"\"."); test_value(arf[0], 5.0, 1.0e-6); test_value(arf[1], 3.7, 1.0e-6); for (int i = 2; i < 9; i += 2) { @@ -228,8 +228,8 @@ void TestGXspec::test_GArf(void) // Test constructing GArf arf2("arf.fits"); - test_assert(arf2.filename() == "arf.fits", - "Unexpected filename \""+arf2.filename()+"\"."); + test_assert(arf2.filename().url() == "arf.fits", + "Unexpected filename \""+arf2.filename().url()+"\"."); test_value(arf2[0], 5.0, 1.0e-6); test_value(arf2[1], 3.7, 1.0e-6); for (int i = 2; i < 9; i += 2) {