Commit 710a5ee6d42049df45b053367149d8e365c2a474
1 parent
74b6c8ad
Use GFilename for filename arguments.
Showing
25 changed files
with
277 additions
and
227 deletions
NEWS
| ... | ... | @@ -30,14 +30,20 @@ The following methods have been renamed: |
| 30 | 30 | - GFilename::is_empty(), was GFilename::empty() |
| 31 | 31 | - GFilename::url(), was GFilename::filename() |
| 32 | 32 | |
| 33 | -The following classes now use for filenames a GFilename argument instead | |
| 33 | +The following classes now use GFilename for filenames arguments instead | |
| 34 | 34 | of std::string: |
| 35 | +- GApplicationPars | |
| 36 | +- GArf | |
| 37 | +- GCsv | |
| 35 | 38 | - GEbounds |
| 36 | -- GGti | |
| 37 | 39 | - GEnergies |
| 38 | -- GEvents | |
| 39 | 40 | - GEventCube, GCOMEventCube, GCTAEventCube, GLATEventCube, GMWLSpectrum |
| 40 | 41 | - GEventList, GCTAEventList, GLATEventList |
| 42 | +- GEvents | |
| 43 | +- GGti | |
| 44 | +- GLog | |
| 45 | +- GModelSpatialDiffuseCube | |
| 46 | +- GSkyMap | |
| 41 | 47 | |
| 42 | 48 | The return value has been changed for the following methods: |
| 43 | 49 | - GFits::filename() returns now GFilename instead of std::string | ... | ... |
include/GApplicationPars.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GApplicationPars.hpp - Application parameters * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2015 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -33,6 +33,9 @@ |
| 33 | 33 | #include "GContainer.hpp" |
| 34 | 34 | #include "GApplicationPar.hpp" |
| 35 | 35 | |
| 36 | +/* __ Forward declarations _______________________________________________ */ | |
| 37 | +class GFilename; | |
| 38 | + | |
| 36 | 39 | |
| 37 | 40 | /***********************************************************************//** |
| 38 | 41 | * @class GApplicationPars |
| ... | ... | @@ -49,8 +52,8 @@ class GApplicationPars : public GContainer { |
| 49 | 52 | public: |
| 50 | 53 | // Constructors and destructors |
| 51 | 54 | GApplicationPars(void); |
| 52 | - explicit GApplicationPars(const std::string& filename); | |
| 53 | - GApplicationPars(const std::string& filename, | |
| 55 | + explicit GApplicationPars(const GFilename& filename); | |
| 56 | + GApplicationPars(const GFilename& filename, | |
| 54 | 57 | const std::vector<std::string>& args); |
| 55 | 58 | GApplicationPars(const GApplicationPars& pars); |
| 56 | 59 | virtual ~GApplicationPars(void); |
| ... | ... | @@ -80,10 +83,10 @@ public: |
| 80 | 83 | void reserve(const int& num); |
| 81 | 84 | void extend(const GApplicationPars& pars); |
| 82 | 85 | bool contains(const std::string& name) const; |
| 83 | - void load(const std::string& filename); | |
| 84 | - void load(const std::string& filename, | |
| 86 | + void load(const GFilename& filename); | |
| 87 | + void load(const GFilename& filename, | |
| 85 | 88 | const std::vector<std::string>& args); |
| 86 | - void save(const std::string& filename); | |
| 89 | + void save(const GFilename& filename); | |
| 87 | 90 | std::string print(const GChatter& chatter = NORMAL) const; |
| 88 | 91 | |
| 89 | 92 | protected: | ... | ... |
include/GArf.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GArf.hpp - XSPEC Auxiliary Response File class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2013-2015 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2013-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -29,10 +29,14 @@ |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | +#include <vector> | |
| 32 | 33 | #include "GBase.hpp" |
| 33 | 34 | #include "GEbounds.hpp" |
| 34 | -#include "GFits.hpp" | |
| 35 | -#include "GFitsTable.hpp" | |
| 35 | +#include "GFilename.hpp" | |
| 36 | + | |
| 37 | +/* __ Forward declarations _______________________________________________ */ | |
| 38 | +class GFits; | |
| 39 | +class GFitsTable; | |
| 36 | 40 | |
| 37 | 41 | |
| 38 | 42 | /***********************************************************************//** |
| ... | ... | @@ -45,7 +49,7 @@ class GArf : public GBase { |
| 45 | 49 | public: |
| 46 | 50 | // Constructors and destructors |
| 47 | 51 | GArf(void); |
| 48 | - explicit GArf(const std::string& filename); | |
| 52 | + explicit GArf(const GFilename& filename); | |
| 49 | 53 | explicit GArf(const GEbounds& ebds); |
| 50 | 54 | GArf(const GArf& arf); |
| 51 | 55 | virtual ~GArf(void); |
| ... | ... | @@ -56,20 +60,20 @@ public: |
| 56 | 60 | const double& operator[](const int& index) const; |
| 57 | 61 | |
| 58 | 62 | // Methods |
| 59 | - void clear(void); | |
| 60 | - GArf* clone(void) const; | |
| 61 | - std::string classname(void) const; | |
| 62 | - int size(void) const; | |
| 63 | - double& at(const int& index); | |
| 64 | - const double& at(const int& index) const; | |
| 65 | - const GEbounds& ebounds(void) const; | |
| 66 | - void load(const std::string& filename); | |
| 67 | - void save(const std::string& filename, | |
| 68 | - const bool& clobber = false) const; | |
| 69 | - void read(const GFitsTable& table); | |
| 70 | - void write(GFits& fits) const; | |
| 71 | - const std::string& filename(void) const; | |
| 72 | - std::string print(const GChatter& chatter = NORMAL) const; | |
| 63 | + void clear(void); | |
| 64 | + GArf* clone(void) const; | |
| 65 | + std::string classname(void) const; | |
| 66 | + int size(void) const; | |
| 67 | + double& at(const int& index); | |
| 68 | + const double& at(const int& index) const; | |
| 69 | + const GEbounds& ebounds(void) const; | |
| 70 | + void load(const GFilename& filename); | |
| 71 | + void save(const GFilename& filename, | |
| 72 | + const bool& clobber = false) const; | |
| 73 | + void read(const GFitsTable& table); | |
| 74 | + void write(GFits& fits) const; | |
| 75 | + const GFilename& filename(void) const; | |
| 76 | + std::string print(const GChatter& chatter = NORMAL) const; | |
| 73 | 77 | |
| 74 | 78 | protected: |
| 75 | 79 | // Protected methods |
| ... | ... | @@ -78,7 +82,7 @@ protected: |
| 78 | 82 | void free_members(void); |
| 79 | 83 | |
| 80 | 84 | // Protected members |
| 81 | - mutable std::string m_filename; //!< Filename of origin | |
| 85 | + mutable GFilename m_filename; //!< Filename of origin | |
| 82 | 86 | GEbounds m_ebounds; //!< Energy boundaries |
| 83 | 87 | std::vector<double> m_specresp; //!< Spectral response |
| 84 | 88 | }; |
| ... | ... | @@ -163,7 +167,7 @@ const GEbounds& GArf::ebounds(void) const |
| 163 | 167 | * no load() or save() method has been called before. |
| 164 | 168 | ***************************************************************************/ |
| 165 | 169 | inline |
| 166 | -const std::string& GArf::filename(void) const | |
| 170 | +const GFilename& GArf::filename(void) const | |
| 167 | 171 | { |
| 168 | 172 | return (m_filename); |
| 169 | 173 | } | ... | ... |
include/GCsv.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GCsv.hpp - Comma-separated values table class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2015 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -32,6 +32,9 @@ |
| 32 | 32 | #include <string> |
| 33 | 33 | #include "GBase.hpp" |
| 34 | 34 | |
| 35 | +/* __ Forward declarations _______________________________________________ */ | |
| 36 | +class GFilename; | |
| 37 | + | |
| 35 | 38 | |
| 36 | 39 | /***********************************************************************//** |
| 37 | 40 | * @class GCsv |
| ... | ... | @@ -57,7 +60,7 @@ public: |
| 57 | 60 | // Constructors and destructors |
| 58 | 61 | GCsv(void); |
| 59 | 62 | GCsv(const int& nrows, const int& ncols); |
| 60 | - GCsv(const std::string& filename, const std::string& sep = " "); | |
| 63 | + GCsv(const GFilename& filename, const std::string& sep = " "); | |
| 61 | 64 | GCsv(const GCsv& csv); |
| 62 | 65 | virtual ~GCsv(void); |
| 63 | 66 | |
| ... | ... | @@ -81,8 +84,8 @@ public: |
| 81 | 84 | void string(const int& row, const int& col, const std::string& value); |
| 82 | 85 | void real(const int& row, const int& col, const double& value); |
| 83 | 86 | void integer(const int& row, const int& col, const int& value); |
| 84 | - void load(const std::string& filename, const std::string& sep = " "); | |
| 85 | - void save(const std::string& filename, const std::string& sep = " ", | |
| 87 | + void load(const GFilename& filename, const std::string& sep = " "); | |
| 88 | + void save(const GFilename& filename, const std::string& sep = " ", | |
| 86 | 89 | const bool& clobber = false) const; |
| 87 | 90 | std::string print(const GChatter& chatter = NORMAL) const; |
| 88 | 91 | ... | ... |
include/GFits.hpp
| ... | ... | @@ -65,7 +65,7 @@ class GFits : public GContainer { |
| 65 | 65 | public: |
| 66 | 66 | // Constructors and destructors |
| 67 | 67 | GFits(void); |
| 68 | - GFits(const std::string& filename, const bool& create = false); | |
| 68 | + GFits(const GFilename& filename, const bool& create = false); | |
| 69 | 69 | GFits(const GFits& fits); |
| 70 | 70 | virtual ~GFits(void); |
| 71 | 71 | |
| ... | ... | @@ -107,11 +107,11 @@ public: |
| 107 | 107 | bool contains(const std::string& extname) const; |
| 108 | 108 | const GFilename& filename(void) const; |
| 109 | 109 | int extno(const std::string& extname) const; |
| 110 | - void open(const std::string& filename, | |
| 111 | - const bool& create = false); | |
| 110 | + void open(const GFilename& filename, | |
| 111 | + const bool& create = false); | |
| 112 | 112 | void save(const bool& clobber = false); |
| 113 | - void saveto(const std::string& filename, | |
| 114 | - const bool& clobber = false); | |
| 113 | + void saveto(const GFilename& filename, | |
| 114 | + const bool& clobber = false); | |
| 115 | 115 | void close(void); |
| 116 | 116 | std::string print(const GChatter& chatter = NORMAL) const; |
| 117 | 117 | ... | ... |
include/GLog.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GLog.hpp - Information logger * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2013 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -30,6 +30,7 @@ |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | 32 | #include <iostream> |
| 33 | +#include "GFilename.hpp" | |
| 33 | 34 | #include "GTypemaps.hpp" |
| 34 | 35 | |
| 35 | 36 | /* __ Forward declarations _______________________________________________ */ |
| ... | ... | @@ -63,7 +64,7 @@ class GLog { |
| 63 | 64 | public: |
| 64 | 65 | // Constructors and destructors |
| 65 | 66 | GLog(void); |
| 66 | - GLog(const std::string& filename, const bool& clobber = false); | |
| 67 | + GLog(const GFilename& filename, const bool& clobber = false); | |
| 67 | 68 | GLog(const GLog& log); |
| 68 | 69 | virtual ~GLog(void); |
| 69 | 70 | |
| ... | ... | @@ -85,7 +86,7 @@ public: |
| 85 | 86 | void clear(void); |
| 86 | 87 | int size(void) const; |
| 87 | 88 | std::string classname(void) const; |
| 88 | - void open(const std::string& filename, const bool& clobber = false); | |
| 89 | + void open(const GFilename& filename, const bool& clobber = false); | |
| 89 | 90 | void close(void); |
| 90 | 91 | void flush(const bool& force = false); |
| 91 | 92 | void date(const bool& flag); |
| ... | ... | @@ -106,7 +107,7 @@ public: |
| 106 | 107 | const int& max_size(void) const; |
| 107 | 108 | const int& indent(void) const; |
| 108 | 109 | const GChatter& chatter(void) const; |
| 109 | - const std::string& filename(void) const; | |
| 110 | + const GFilename& filename(void) const; | |
| 110 | 111 | |
| 111 | 112 | protected: |
| 112 | 113 | // Protected methods |
| ... | ... | @@ -126,7 +127,7 @@ protected: |
| 126 | 127 | bool m_use_date; //!< Dump date in prefix |
| 127 | 128 | bool m_linestart; //!< Signals that buffer is at line start |
| 128 | 129 | FILE* m_file; //!< Log file pointer |
| 129 | - std::string m_filename; //!< Log file name | |
| 130 | + GFilename m_filename; //!< Log file name | |
| 130 | 131 | std::string m_name; //!< Name for prefix |
| 131 | 132 | std::string m_buffer; //!< Output string buffer |
| 132 | 133 | GChatter m_chatter; //!< Chattiness for print() method |
| ... | ... | @@ -450,7 +451,7 @@ const GChatter& GLog::chatter(void) const |
| 450 | 451 | * Returns the filename of the log file. |
| 451 | 452 | ***************************************************************************/ |
| 452 | 453 | inline |
| 453 | -const std::string& GLog::filename(void) const | |
| 454 | +const GFilename& GLog::filename(void) const | |
| 454 | 455 | { |
| 455 | 456 | return m_filename; |
| 456 | 457 | } | ... | ... |
include/GModelSpatialDiffuseCube.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GModelSpatialDiffuseCube.hpp - Spatial map cube model class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2015 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -39,6 +39,7 @@ |
| 39 | 39 | #include "GXmlElement.hpp" |
| 40 | 40 | #include "GEbounds.hpp" |
| 41 | 41 | #include "GEnergies.hpp" |
| 42 | +#include "GFilename.hpp" | |
| 42 | 43 | |
| 43 | 44 | /* __ Forward declarations _______________________________________________ */ |
| 44 | 45 | class GFits; |
| ... | ... | @@ -60,8 +61,8 @@ public: |
| 60 | 61 | // Constructors and destructors |
| 61 | 62 | GModelSpatialDiffuseCube(void); |
| 62 | 63 | explicit GModelSpatialDiffuseCube(const GXmlElement& xml); |
| 63 | - GModelSpatialDiffuseCube(const std::string& filename, | |
| 64 | - const double& value = 1.0); | |
| 64 | + GModelSpatialDiffuseCube(const GFilename& filename, | |
| 65 | + const double& value = 1.0); | |
| 65 | 66 | GModelSpatialDiffuseCube(const GSkyMap& cube, |
| 66 | 67 | const GEnergies& energies, |
| 67 | 68 | const double& value = 1.0); |
| ... | ... | @@ -94,8 +95,8 @@ public: |
| 94 | 95 | int pixels(void) const; |
| 95 | 96 | double value(void) const; |
| 96 | 97 | void value(const double& value); |
| 97 | - const std::string& filename(void) const; | |
| 98 | - void filename(const std::string& filename); | |
| 98 | + const GFilename& filename(void) const; | |
| 99 | + void filename(const GFilename& filename); | |
| 99 | 100 | const GSkyMap& cube(void) const; |
| 100 | 101 | void cube(const GSkyMap& cube); |
| 101 | 102 | GEnergies energies(void); |
| ... | ... | @@ -103,9 +104,9 @@ public: |
| 103 | 104 | const GModelSpectralNodes& spectrum(void) const; |
| 104 | 105 | void set_mc_cone(const GSkyDir& centre, |
| 105 | 106 | const double& radius) const; |
| 106 | - void load(const std::string& filename); | |
| 107 | - void save(const std::string& filename, | |
| 108 | - const bool& clobber = false) const; | |
| 107 | + void load(const GFilename& filename); | |
| 108 | + void save(const GFilename& filename, | |
| 109 | + const bool& clobber = false) const; | |
| 109 | 110 | //void read(const GFits& file); |
| 110 | 111 | void write(GFits& file) const; |
| 111 | 112 | |
| ... | ... | @@ -115,18 +116,18 @@ protected: |
| 115 | 116 | void copy_members(const GModelSpatialDiffuseCube& model); |
| 116 | 117 | void free_members(void); |
| 117 | 118 | void fetch_cube(void) const; |
| 118 | - void load_cube(const std::string& filename); | |
| 119 | + void load_cube(const GFilename& filename); | |
| 119 | 120 | void set_energy_boundaries(void); |
| 120 | 121 | void update_mc_cache(void); |
| 121 | 122 | double cube_intensity(const GPhoton& photon) const; |
| 122 | 123 | |
| 123 | 124 | // Protected members |
| 124 | - GModelPar m_value; //!< Value | |
| 125 | - std::string m_filename; //!< Name of map cube | |
| 126 | - bool m_loaded; //!< Signals if map cube has been loaded | |
| 127 | - GSkyMap m_cube; //!< Map cube | |
| 128 | - GNodeArray m_logE; //!< Log10(energy) values of the maps | |
| 129 | - GEbounds m_ebounds; //!< Energy bounds of the maps | |
| 125 | + GModelPar m_value; //!< Value | |
| 126 | + GFilename m_filename; //!< Name of map cube | |
| 127 | + bool m_loaded; //!< Signals if map cube has been loaded | |
| 128 | + GSkyMap m_cube; //!< Map cube | |
| 129 | + GNodeArray m_logE; //!< Log10(energy) values of the maps | |
| 130 | + GEbounds m_ebounds; //!< Energy bounds of the maps | |
| 130 | 131 | |
| 131 | 132 | // Monte Carlo cache |
| 132 | 133 | mutable std::vector<double> m_mc_cache; //!< Monte Carlo cache |
| ... | ... | @@ -226,7 +227,7 @@ void GModelSpatialDiffuseCube::value(const double& value) |
| 226 | 227 | * Returns the file name of the spatial map cube model. |
| 227 | 228 | ***************************************************************************/ |
| 228 | 229 | inline |
| 229 | -const std::string& GModelSpatialDiffuseCube::filename(void) const | |
| 230 | +const GFilename& GModelSpatialDiffuseCube::filename(void) const | |
| 230 | 231 | { |
| 231 | 232 | return (m_filename); |
| 232 | 233 | } |
| ... | ... | @@ -240,7 +241,7 @@ const std::string& GModelSpatialDiffuseCube::filename(void) const |
| 240 | 241 | * Set the file name of the spatial map cube model. |
| 241 | 242 | ***************************************************************************/ |
| 242 | 243 | inline |
| 243 | -void GModelSpatialDiffuseCube::filename(const std::string& filename) | |
| 244 | +void GModelSpatialDiffuseCube::filename(const GFilename& filename) | |
| 244 | 245 | { |
| 245 | 246 | m_filename = filename; |
| 246 | 247 | return; | ... | ... |
include/GSkyMap.hpp
| ... | ... | @@ -33,15 +33,27 @@ |
| 33 | 33 | #include "GSkyDir.hpp" |
| 34 | 34 | #include "GSkyPixel.hpp" |
| 35 | 35 | #include "GSkyProjection.hpp" |
| 36 | +/* | |
| 36 | 37 | #include "GFits.hpp" |
| 37 | 38 | #include "GFitsTable.hpp" |
| 38 | 39 | #include "GFitsBinTable.hpp" |
| 39 | 40 | #include "GFitsImage.hpp" |
| 40 | 41 | #include "GFitsImageDouble.hpp" |
| 41 | -#include "GMatrix.hpp" | |
| 42 | -#include "GVector.hpp" | |
| 42 | +*/ | |
| 43 | +//#include "GMatrix.hpp" | |
| 44 | +//#include "GVector.hpp" | |
| 43 | 45 | #include "GBilinear.hpp" |
| 44 | 46 | |
| 47 | +/* __ Forward declarations _______________________________________________ */ | |
| 48 | +class GFilename; | |
| 49 | +class GFits; | |
| 50 | +class GFitsTable; | |
| 51 | +class GFitsBinTable; | |
| 52 | +class GFitsImage; | |
| 53 | +class GFitsImageDouble; | |
| 54 | +class GMatrix; | |
| 55 | +class GVector; | |
| 56 | + | |
| 45 | 57 | |
| 46 | 58 | /***********************************************************************//** |
| 47 | 59 | * @class GSkyMap |
| ... | ... | @@ -84,20 +96,20 @@ class GSkyMap : public GBase { |
| 84 | 96 | public: |
| 85 | 97 | // Constructors and destructors |
| 86 | 98 | GSkyMap(void); |
| 87 | - explicit GSkyMap(const std::string& filename); | |
| 88 | - explicit GSkyMap(const std::string& coords, | |
| 89 | - const int& nside, | |
| 90 | - const std::string& order, | |
| 91 | - const int& nmaps = 1); | |
| 92 | - explicit GSkyMap(const std::string& wcs, | |
| 93 | - const std::string& coords, | |
| 94 | - const double& x, | |
| 95 | - const double& y, | |
| 96 | - const double& dx, | |
| 97 | - const double& dy, | |
| 98 | - const int& nx, | |
| 99 | - const int& ny, | |
| 100 | - const int& nmaps = 1); | |
| 99 | + explicit GSkyMap(const GFilename& filename); | |
| 100 | + GSkyMap(const std::string& coords, | |
| 101 | + const int& nside, | |
| 102 | + const std::string& order, | |
| 103 | + const int& nmaps = 1); | |
| 104 | + GSkyMap(const std::string& wcs, | |
| 105 | + const std::string& coords, | |
| 106 | + const double& x, | |
| 107 | + const double& y, | |
| 108 | + const double& dx, | |
| 109 | + const double& dy, | |
| 110 | + const int& nx, | |
| 111 | + const int& ny, | |
| 112 | + const int& nmaps = 1); | |
| 101 | 113 | GSkyMap(const GSkyMap& map); |
| 102 | 114 | virtual ~GSkyMap(void); |
| 103 | 115 | |
| ... | ... | @@ -148,8 +160,8 @@ public: |
| 148 | 160 | const double* pixels(void) const; |
| 149 | 161 | GSkyMap extract(const int& map, const int& nmaps = 1) const; |
| 150 | 162 | void stack_maps(void); |
| 151 | - void load(const std::string& filename); | |
| 152 | - void save(const std::string& filename, bool clobber = false) const; | |
| 163 | + void load(const GFilename& filename); | |
| 164 | + void save(const GFilename& filename, bool clobber = false) const; | |
| 153 | 165 | void read(const GFitsHDU& hdu); |
| 154 | 166 | void write(GFits& file) const; |
| 155 | 167 | std::string print(const GChatter& chatter = NORMAL) const; | ... | ... |
inst/cta/src/GCTAOnOffObservation.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GCTAOnOffObservation.cpp - CTA on-off observation class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2014 by Chia-Chun Lu & Christoph Deil * | |
| 4 | + * copyright (C) 2014-2016 by Chia-Chun Lu & Christoph Deil * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -412,7 +412,7 @@ void GCTAOnOffObservation::write(GXmlElement& xml) const |
| 412 | 412 | |
| 413 | 413 | // Handle effective area |
| 414 | 414 | else if (par->attribute("name") == "Arf") { |
| 415 | - par->attribute("file", m_arf.filename()); | |
| 415 | + par->attribute("file", m_arf.filename().url()); | |
| 416 | 416 | npar[4]++; |
| 417 | 417 | } |
| 418 | 418 | ... | ... |
pyext/GApplicationPars.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GApplicationPars.i - Application parameter container * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2015 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -27,6 +27,7 @@ |
| 27 | 27 | /* Put headers and other declarations here that are needed for compilation */ |
| 28 | 28 | #include "GApplicationPars.hpp" |
| 29 | 29 | #include "GException.hpp" |
| 30 | +#include "GFilename.hpp" | |
| 30 | 31 | %} |
| 31 | 32 | |
| 32 | 33 | |
| ... | ... | @@ -40,8 +41,8 @@ class GApplicationPars : public GBase { |
| 40 | 41 | public: |
| 41 | 42 | // Constructors and destructors |
| 42 | 43 | GApplicationPars(void); |
| 43 | - explicit GApplicationPars(const std::string& filename); | |
| 44 | - GApplicationPars(const std::string& filename, | |
| 44 | + explicit GApplicationPars(const GFilename& filename); | |
| 45 | + GApplicationPars(const GFilename& filename, | |
| 45 | 46 | const std::vector<std::string>& args); |
| 46 | 47 | GApplicationPars(const GApplicationPars& pars); |
| 47 | 48 | virtual ~GApplicationPars(void); |
| ... | ... | @@ -63,10 +64,10 @@ public: |
| 63 | 64 | void reserve(const int& num); |
| 64 | 65 | void extend(const GApplicationPars& pars); |
| 65 | 66 | bool contains(const std::string& name) const; |
| 66 | - void load(const std::string& filename); | |
| 67 | - void load(const std::string& filename, | |
| 67 | + void load(const GFilename& filename); | |
| 68 | + void load(const GFilename& filename, | |
| 68 | 69 | const std::vector<std::string>& args); |
| 69 | - void save(const std::string& filename); | |
| 70 | + void save(const GFilename& filename); | |
| 70 | 71 | }; |
| 71 | 72 | |
| 72 | 73 | ... | ... |
pyext/GArf.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GArf.i - XSPEC Auxiliary Response File class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2013-2015 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2013-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -39,23 +39,25 @@ class GArf : public GBase { |
| 39 | 39 | public: |
| 40 | 40 | // Constructors and destructors |
| 41 | 41 | GArf(void); |
| 42 | - explicit GArf(const std::string& filename); | |
| 42 | + explicit GArf(const GFilename& filename); | |
| 43 | 43 | explicit GArf(const GEbounds& ebds); |
| 44 | 44 | GArf(const GArf& arf); |
| 45 | 45 | virtual ~GArf(void); |
| 46 | 46 | |
| 47 | 47 | // Methods |
| 48 | - void clear(void); | |
| 49 | - GArf* clone(void) const; | |
| 50 | - std::string classname(void) const; | |
| 51 | - int size(void) const; | |
| 52 | - double& at(const int& index); | |
| 53 | - const GEbounds& ebounds(void) const; | |
| 54 | - void load(const std::string& filename); | |
| 55 | - void save(const std::string& filename, | |
| 56 | - const bool& clobber = false) const; | |
| 57 | - void read(const GFitsTable& table); | |
| 58 | - void write(GFits& fits) const; | |
| 48 | + void clear(void); | |
| 49 | + GArf* clone(void) const; | |
| 50 | + std::string classname(void) const; | |
| 51 | + int size(void) const; | |
| 52 | + double& at(const int& index); | |
| 53 | + const double& at(const int& index) const; | |
| 54 | + const GEbounds& ebounds(void) const; | |
| 55 | + void load(const GFilename& filename); | |
| 56 | + void save(const GFilename& filename, | |
| 57 | + const bool& clobber = false) const; | |
| 58 | + void read(const GFitsTable& table); | |
| 59 | + void write(GFits& fits) const; | |
| 60 | + const GFilename& filename(void) const; | |
| 59 | 61 | }; |
| 60 | 62 | |
| 61 | 63 | ... | ... |
pyext/GCsv.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GCsv.i - Comma-separated values table class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2015 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -87,7 +87,7 @@ public: |
| 87 | 87 | // Constructors and destructors |
| 88 | 88 | GCsv(void); |
| 89 | 89 | GCsv(const int& nrows, const int& ncols); |
| 90 | - GCsv(const std::string& filename, const std::string& sep = " "); | |
| 90 | + GCsv(const GFilename& filename, const std::string& sep = " "); | |
| 91 | 91 | GCsv(const GCsv& csv); |
| 92 | 92 | virtual ~GCsv(void); |
| 93 | 93 | |
| ... | ... | @@ -106,8 +106,8 @@ public: |
| 106 | 106 | void string(const int& row, const int& col, const std::string& value); |
| 107 | 107 | void real(const int& row, const int& col, const double& value); |
| 108 | 108 | void integer(const int& row, const int& col, const int& value); |
| 109 | - void load(const std::string& filename, const std::string& sep = " "); | |
| 110 | - void save(const std::string& filename, const std::string& sep = " ", | |
| 109 | + void load(const GFilename& filename, const std::string& sep = " "); | |
| 110 | + void save(const GFilename& filename, const std::string& sep = " ", | |
| 111 | 111 | const bool& clobber = false) const; |
| 112 | 112 | }; |
| 113 | 113 | ... | ... |
pyext/GFits.i
| ... | ... | @@ -53,7 +53,7 @@ class GFits : public GContainer { |
| 53 | 53 | public: |
| 54 | 54 | // Constructors and destructors |
| 55 | 55 | GFits(void); |
| 56 | - GFits(const std::string& filename, const bool& create = false); | |
| 56 | + GFits(const GFilename& filename, const bool& create = false); | |
| 57 | 57 | GFits(const GFits& fits); |
| 58 | 58 | virtual ~GFits(void); |
| 59 | 59 | |
| ... | ... | @@ -82,11 +82,11 @@ public: |
| 82 | 82 | bool contains(const std::string& extname) const; |
| 83 | 83 | const GFilename& filename(void) const; |
| 84 | 84 | int extno(const std::string& extname) const; |
| 85 | - void open(const std::string& filename, | |
| 86 | - const bool& create = false); | |
| 85 | + void open(const GFilename& filename, | |
| 86 | + const bool& create = false); | |
| 87 | 87 | void save(const bool& clobber = false); |
| 88 | - void saveto(const std::string& filename, | |
| 89 | - const bool& clobber = false); | |
| 88 | + void saveto(const GFilename& filename, | |
| 89 | + const bool& clobber = false); | |
| 90 | 90 | void close(void); |
| 91 | 91 | }; |
| 92 | 92 | ... | ... |
pyext/GLog.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GLog.i - Information logger * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2015 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -39,7 +39,7 @@ class GLog { |
| 39 | 39 | public: |
| 40 | 40 | // Constructors and destructors |
| 41 | 41 | GLog(void); |
| 42 | - GLog(const std::string& filename, const bool& clobber = false); | |
| 42 | + GLog(const GFilename& filename, const bool& clobber = false); | |
| 43 | 43 | GLog(const GLog& log); |
| 44 | 44 | virtual ~GLog(void); |
| 45 | 45 | |
| ... | ... | @@ -47,7 +47,7 @@ public: |
| 47 | 47 | void clear(void); |
| 48 | 48 | int size(void) const; |
| 49 | 49 | std::string classname(void) const; |
| 50 | - void open(const std::string& filename, const bool& clobber = false); | |
| 50 | + void open(const GFilename& filename, const bool& clobber = false); | |
| 51 | 51 | void close(void); |
| 52 | 52 | void flush(const bool& force = false); |
| 53 | 53 | void date(const bool& flag); |
| ... | ... | @@ -68,7 +68,7 @@ public: |
| 68 | 68 | const int& max_size(void) const; |
| 69 | 69 | const int& indent(void) const; |
| 70 | 70 | const GChatter& chatter(void) const; |
| 71 | - const std::string& filename(void) const; | |
| 71 | + const GFilename& filename(void) const; | |
| 72 | 72 | }; |
| 73 | 73 | |
| 74 | 74 | ... | ... |
pyext/GModelSpatialDiffuseCube.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GModelSpatialDiffuseCube.i - Spatial map cube model class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011-2015 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2011-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -39,8 +39,8 @@ public: |
| 39 | 39 | // Constructors and destructors |
| 40 | 40 | GModelSpatialDiffuseCube(void); |
| 41 | 41 | explicit GModelSpatialDiffuseCube(const GXmlElement& xml); |
| 42 | - GModelSpatialDiffuseCube(const std::string& filename, | |
| 43 | - const double& value = 1.0); | |
| 42 | + GModelSpatialDiffuseCube(const GFilename& filename, | |
| 43 | + const double& value = 1.0); | |
| 44 | 44 | GModelSpatialDiffuseCube(const GSkyMap& map, |
| 45 | 45 | const GEnergies& energies, |
| 46 | 46 | const double& value = 1.0); |
| ... | ... | @@ -69,8 +69,8 @@ public: |
| 69 | 69 | int pixels(void) const; |
| 70 | 70 | double value(void) const; |
| 71 | 71 | void value(const double& value); |
| 72 | - const std::string& filename(void) const; | |
| 73 | - void filename(const std::string& filename); | |
| 72 | + const GFilename& filename(void) const; | |
| 73 | + void filename(const GFilename& filename); | |
| 74 | 74 | const GSkyMap& cube(void) const; |
| 75 | 75 | void cube(const GSkyMap& cube); |
| 76 | 76 | GEnergies energies(void); |
| ... | ... | @@ -78,8 +78,8 @@ public: |
| 78 | 78 | const GModelSpectralNodes& spectrum(void) const; |
| 79 | 79 | void set_mc_cone(const GSkyDir& centre, |
| 80 | 80 | const double& radius) const; |
| 81 | - void load(const std::string& filename); | |
| 82 | - void save(const std::string& filename, | |
| 81 | + void load(const GFilename& filename); | |
| 82 | + void save(const GFilename& filename, | |
| 83 | 83 | const bool& clobber = false) const; |
| 84 | 84 | //void read(const GFits& file); |
| 85 | 85 | void write(GFits& file) const; | ... | ... |
pyext/GSkyMap.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GSkyMap.i - Sky map class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2015 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -110,20 +110,20 @@ class GSkyMap : public GBase { |
| 110 | 110 | public: |
| 111 | 111 | // Constructors and destructors |
| 112 | 112 | GSkyMap(void); |
| 113 | - explicit GSkyMap(const std::string& filename); | |
| 114 | - explicit GSkyMap(const std::string& coords, | |
| 115 | - const int& nside, | |
| 116 | - const std::string& order, | |
| 117 | - const int& nmaps = 1); | |
| 118 | - explicit GSkyMap(const std::string& wcs, | |
| 119 | - const std::string& coords, | |
| 120 | - const double& x, | |
| 121 | - const double& y, | |
| 122 | - const double& dx, | |
| 123 | - const double& dy, | |
| 124 | - const int& nx, | |
| 125 | - const int& ny, | |
| 126 | - const int& nmaps = 1); | |
| 113 | + explicit GSkyMap(const GFilename& filename); | |
| 114 | + GSkyMap(const std::string& coords, | |
| 115 | + const int& nside, | |
| 116 | + const std::string& order, | |
| 117 | + const int& nmaps = 1); | |
| 118 | + GSkyMap(const std::string& wcs, | |
| 119 | + const std::string& coords, | |
| 120 | + const double& x, | |
| 121 | + const double& y, | |
| 122 | + const double& dx, | |
| 123 | + const double& dy, | |
| 124 | + const int& nx, | |
| 125 | + const int& ny, | |
| 126 | + const int& nmaps = 1); | |
| 127 | 127 | GSkyMap(const GSkyMap& map); |
| 128 | 128 | virtual ~GSkyMap(void); |
| 129 | 129 | |
| ... | ... | @@ -168,8 +168,8 @@ public: |
| 168 | 168 | const double* pixels(void) const; |
| 169 | 169 | GSkyMap extract(const int& map, const int& nmaps = 1) const; |
| 170 | 170 | void stack_maps(void); |
| 171 | - void load(const std::string& filename); | |
| 172 | - void save(const std::string& filename, bool clobber = false) const; | |
| 171 | + void load(const GFilename& filename); | |
| 172 | + void save(const GFilename& filename, bool clobber = false) const; | |
| 173 | 173 | void read(const GFitsHDU& hdu); |
| 174 | 174 | void write(GFits& file) const; |
| 175 | 175 | }; | ... | ... |
src/app/GApplicationPars.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GApplicationPars.cpp - Application parameters * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2015 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -34,9 +34,10 @@ |
| 34 | 34 | #include <sys/stat.h> // mkdir() function |
| 35 | 35 | #include <cstdlib> // std::getenv() function |
| 36 | 36 | #include <cstdio> // std::fopen(), etc. functions |
| 37 | -#include "GApplicationPars.hpp" | |
| 38 | 37 | #include "GTools.hpp" |
| 39 | 38 | #include "GException.hpp" |
| 39 | +#include "GFilename.hpp" | |
| 40 | +#include "GApplicationPars.hpp" | |
| 40 | 41 | |
| 41 | 42 | /* __ Method name definitions ____________________________________________ */ |
| 42 | 43 | #define G_ACCESS "GApplicationPars::operator[](std::string&)" |
| ... | ... | @@ -49,10 +50,10 @@ |
| 49 | 50 | #define G_REMOVE1 "GApplicationPars::remove(int&)" |
| 50 | 51 | #define G_REMOVE2 "GApplicationPars::remove(std::string&)" |
| 51 | 52 | #define G_EXTEND "GApplicationPars::extend(GApplicationPars&)" |
| 52 | -#define G_LOAD1 "GApplicationPars::load(std::string&)" | |
| 53 | -#define G_LOAD2 "GApplicationPars::load(std::string&, "\ | |
| 53 | +#define G_LOAD1 "GApplicationPars::load(GFilename&)" | |
| 54 | +#define G_LOAD2 "GApplicationPars::load(GFilename&, "\ | |
| 54 | 55 | "std::vector<std::string>&)" |
| 55 | -#define G_SAVE "GApplicationPars::save(std::string&)" | |
| 56 | +#define G_SAVE "GApplicationPars::save(GFilename&)" | |
| 56 | 57 | #define G_OUTPATH "GApplicationPars::outpath(std::string&)" |
| 57 | 58 | #define G_READ "GApplicationPars::read(std::string&)" |
| 58 | 59 | #define G_WRITE "GApplicationPars::write(std::string&)" |
| ... | ... | @@ -91,7 +92,7 @@ GApplicationPars::GApplicationPars(void) |
| 91 | 92 | * |
| 92 | 93 | * @param[in] filename Parameter filename. |
| 93 | 94 | ***************************************************************************/ |
| 94 | -GApplicationPars::GApplicationPars(const std::string& filename) | |
| 95 | +GApplicationPars::GApplicationPars(const GFilename& filename) | |
| 95 | 96 | { |
| 96 | 97 | // Initialise private members for clean destruction |
| 97 | 98 | init_members(); |
| ... | ... | @@ -109,7 +110,8 @@ GApplicationPars::GApplicationPars(const std::string& filename) |
| 109 | 110 | * @param[in] filename Parameter filename. |
| 110 | 111 | * @param[in] args Command line arguments. |
| 111 | 112 | ***************************************************************************/ |
| 112 | -GApplicationPars::GApplicationPars(const std::string& filename, const std::vector<std::string>& args) | |
| 113 | +GApplicationPars::GApplicationPars(const GFilename& filename, | |
| 114 | + const std::vector<std::string>& args) | |
| 113 | 115 | { |
| 114 | 116 | // Initialise private members for clean destruction |
| 115 | 117 | init_members(); |
| ... | ... | @@ -631,15 +633,15 @@ bool GApplicationPars::contains(const std::string& name) const |
| 631 | 633 | * |
| 632 | 634 | * Loads all parameters from parameter file. |
| 633 | 635 | ***************************************************************************/ |
| 634 | -void GApplicationPars::load(const std::string& filename) | |
| 636 | +void GApplicationPars::load(const GFilename& filename) | |
| 635 | 637 | { |
| 636 | 638 | // Reset parameters |
| 637 | 639 | m_parfile.clear(); |
| 638 | 640 | |
| 639 | 641 | // Get path to parameter file for input |
| 640 | - std::string path = inpath(filename); | |
| 642 | + std::string path = inpath(filename.url()); | |
| 641 | 643 | if (path.length() == 0) { |
| 642 | - throw GException::par_file_not_found(G_LOAD1, filename); | |
| 644 | + throw GException::par_file_not_found(G_LOAD1, filename.url()); | |
| 643 | 645 | } |
| 644 | 646 | |
| 645 | 647 | // Read parfile |
| ... | ... | @@ -667,16 +669,16 @@ void GApplicationPars::load(const std::string& filename) |
| 667 | 669 | * Loads all parameters from parameter file. Parameters are overwritten by |
| 668 | 670 | * the values specified in the command line arguments. |
| 669 | 671 | ***************************************************************************/ |
| 670 | -void GApplicationPars::load(const std::string& filename, | |
| 671 | - const std::vector<std::string>& args) | |
| 672 | +void GApplicationPars::load(const GFilename& filename, | |
| 673 | + const std::vector<std::string>& args) | |
| 672 | 674 | { |
| 673 | 675 | // Reset parameters |
| 674 | 676 | m_parfile.clear(); |
| 675 | 677 | |
| 676 | 678 | // Get path to parameter file for input |
| 677 | - std::string path = inpath(filename); | |
| 679 | + std::string path = inpath(filename.url()); | |
| 678 | 680 | if (path.length() == 0) { |
| 679 | - throw GException::par_file_not_found(G_LOAD2, filename); | |
| 681 | + throw GException::par_file_not_found(G_LOAD2, filename.url()); | |
| 680 | 682 | } |
| 681 | 683 | |
| 682 | 684 | // Read parfile |
| ... | ... | @@ -741,12 +743,12 @@ void GApplicationPars::load(const std::string& filename, |
| 741 | 743 | * @exception GException::par_file_not_found |
| 742 | 744 | * No valid directory to write the parameter file has been found. |
| 743 | 745 | ***************************************************************************/ |
| 744 | -void GApplicationPars::save(const std::string& filename) | |
| 746 | +void GApplicationPars::save(const GFilename& filename) | |
| 745 | 747 | { |
| 746 | 748 | // Get path to parameter file for output |
| 747 | - std::string path = outpath(filename); | |
| 749 | + std::string path = outpath(filename.url()); | |
| 748 | 750 | if (path.size() == 0) { |
| 749 | - throw GException::par_file_not_found(G_SAVE, filename); | |
| 751 | + throw GException::par_file_not_found(G_SAVE, filename.url()); | |
| 750 | 752 | } |
| 751 | 753 | |
| 752 | 754 | // Update parameter file | ... | ... |
src/app/GLog.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GLog.cpp - Information logger * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2014 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -75,7 +75,7 @@ GLog::GLog(void) |
| 75 | 75 | * |
| 76 | 76 | * Construct a logger with an open log file. |
| 77 | 77 | ***************************************************************************/ |
| 78 | -GLog::GLog(const std::string& filename, const bool& clobber) | |
| 78 | +GLog::GLog(const GFilename& filename, const bool& clobber) | |
| 79 | 79 | { |
| 80 | 80 | // Initialise private members for clean destruction |
| 81 | 81 | init_members(); |
| ... | ... | @@ -212,13 +212,13 @@ GLog& GLog::operator<<(GLog& log) |
| 212 | 212 | log.flush(true); |
| 213 | 213 | |
| 214 | 214 | // Get the filename |
| 215 | - std::string filename = log.filename(); | |
| 215 | + GFilename filename = log.filename(); | |
| 216 | 216 | |
| 217 | 217 | // Close log's file |
| 218 | 218 | log.close(); |
| 219 | 219 | |
| 220 | 220 | // Open log's file in read mode |
| 221 | - std::ifstream file(filename.c_str(), std::ios::in); | |
| 221 | + std::ifstream file(filename.url().c_str(), std::ios::in); | |
| 222 | 222 | if (file) { |
| 223 | 223 | |
| 224 | 224 | // Append all lines from file to this buffer |
| ... | ... | @@ -232,7 +232,7 @@ GLog& GLog::operator<<(GLog& log) |
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | // Open log's file in append mode |
| 235 | - log.open(filename,false); | |
| 235 | + log.open(filename, false); | |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | // Flush |
| ... | ... | @@ -477,7 +477,7 @@ int GLog::size(void) const |
| 477 | 477 | * Opens a file for logging. If a log file was already open it is closed |
| 478 | 478 | * before opening a new file. |
| 479 | 479 | ***************************************************************************/ |
| 480 | -void GLog::open(const std::string& filename, const bool& clobber) | |
| 480 | +void GLog::open(const GFilename& filename, const bool& clobber) | |
| 481 | 481 | { |
| 482 | 482 | // Store the filename |
| 483 | 483 | m_filename = filename; |
| ... | ... | @@ -487,10 +487,10 @@ void GLog::open(const std::string& filename, const bool& clobber) |
| 487 | 487 | |
| 488 | 488 | // Open file |
| 489 | 489 | if (clobber) { |
| 490 | - m_file = std::fopen(filename.c_str(), "w"); | |
| 490 | + m_file = std::fopen(filename.url().c_str(), "w"); | |
| 491 | 491 | } |
| 492 | 492 | else { |
| 493 | - m_file = std::fopen(filename.c_str(), "a"); | |
| 493 | + m_file = std::fopen(filename.url().c_str(), "a"); | |
| 494 | 494 | } |
| 495 | 495 | |
| 496 | 496 | // Return | ... | ... |
src/fits/GFits.cpp
| ... | ... | @@ -80,6 +80,8 @@ |
| 80 | 80 | |
| 81 | 81 | /***********************************************************************//** |
| 82 | 82 | * @brief Void constructor |
| 83 | + * | |
| 84 | + * Constructs empty FITS file. | |
| 83 | 85 | ***************************************************************************/ |
| 84 | 86 | GFits::GFits(void) |
| 85 | 87 | { |
| ... | ... | @@ -100,7 +102,7 @@ GFits::GFits(void) |
| 100 | 102 | * Construct an object by opening a FITS file. If the file does not exist it |
| 101 | 103 | * will be created if @p create is set to true. |
| 102 | 104 | ***************************************************************************/ |
| 103 | -GFits::GFits(const std::string& filename, const bool& create) | |
| 105 | +GFits::GFits(const GFilename& filename, const bool& create) | |
| 104 | 106 | { |
| 105 | 107 | // Initialise class members |
| 106 | 108 | init_members(); |
| ... | ... | @@ -1009,23 +1011,23 @@ int GFits::extno(const std::string& extname) const |
| 1009 | 1011 | * hdu(int extno) method. |
| 1010 | 1012 | * Any environment variable present in the filename will be expanded. |
| 1011 | 1013 | ***************************************************************************/ |
| 1012 | -void GFits::open(const std::string& filename, const bool& create) | |
| 1014 | +void GFits::open(const GFilename& filename, const bool& create) | |
| 1013 | 1015 | { |
| 1014 | 1016 | // Remove any HDUs |
| 1015 | 1017 | m_hdu.clear(); |
| 1016 | 1018 | |
| 1017 | 1019 | // Expand environment variables |
| 1018 | - std::string fname(gammalib::expand_env(filename)); | |
| 1020 | + std::string fname(gammalib::expand_env(filename())); | |
| 1019 | 1021 | |
| 1020 | 1022 | // Don't allow opening if a file is already open |
| 1021 | 1023 | if (m_fitsfile != NULL) { |
| 1022 | 1024 | std::string msg; |
| 1023 | - if (m_filename.filename() == GFilename(fname).filename()) { | |
| 1024 | - msg = "FITS file \""+m_filename.filename()+"\" has already been " | |
| 1025 | + if (m_filename.url() == GFilename(fname).url()) { | |
| 1026 | + msg = "FITS file \""+m_filename.url()+"\" has already been " | |
| 1025 | 1027 | "opened, cannot open it again."; |
| 1026 | 1028 | } |
| 1027 | 1029 | else { |
| 1028 | - msg = "A FITS file \""+m_filename.filename()+"\" has already " | |
| 1030 | + msg = "A FITS file \""+m_filename.url()+"\" has already " | |
| 1029 | 1031 | "been opened, cannot open another FITS file \""+ |
| 1030 | 1032 | fname+"\" before closing the existing one."; |
| 1031 | 1033 | } |
| ... | ... | @@ -1146,7 +1148,7 @@ void GFits::save(const bool& clobber) |
| 1146 | 1148 | // If we attempt to save an existing file without overwriting permission |
| 1147 | 1149 | // then throw an error |
| 1148 | 1150 | if (!m_created && !clobber) { |
| 1149 | - throw GException::fits_file_exist(G_SAVE, m_filename.filename()); | |
| 1151 | + throw GException::fits_file_exist(G_SAVE, m_filename.url()); | |
| 1150 | 1152 | } |
| 1151 | 1153 | |
| 1152 | 1154 | // If no FITS file has been opened then throw an error |
| ... | ... | @@ -1223,10 +1225,10 @@ void GFits::save(const bool& clobber) |
| 1223 | 1225 | * Saves object into a specific FITS file. |
| 1224 | 1226 | * Any environment variable present in the filename will be expanded. |
| 1225 | 1227 | ***************************************************************************/ |
| 1226 | -void GFits::saveto(const std::string& filename, const bool& clobber) | |
| 1228 | +void GFits::saveto(const GFilename& filename, const bool& clobber) | |
| 1227 | 1229 | { |
| 1228 | 1230 | // Expand environment variables |
| 1229 | - std::string fname = gammalib::expand_env(filename); | |
| 1231 | + std::string fname = gammalib::expand_env(filename()); | |
| 1230 | 1232 | |
| 1231 | 1233 | // Create gzipped file name version |
| 1232 | 1234 | std::string gzfname = fname + ".gz"; |
| ... | ... | @@ -1320,7 +1322,7 @@ std::string GFits::print(const GChatter& chatter) const |
| 1320 | 1322 | |
| 1321 | 1323 | // Append file information |
| 1322 | 1324 | result.append("\n"+gammalib::parformat("Filename")); |
| 1323 | - result.append(m_filename.filename()); | |
| 1325 | + result.append(m_filename.url()); | |
| 1324 | 1326 | result.append("\n"+gammalib::parformat("History")); |
| 1325 | 1327 | if (m_created) { |
| 1326 | 1328 | result.append("new file"); | ... | ... |
src/model/GModelSpatialDiffuseCube.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GModelSpatialDiffuseCube.cpp - Spatial map cube model class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2015 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * 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); |
| 51 | 51 | #define G_READ "GModelSpatialDiffuseCube::read(GXmlElement&)" |
| 52 | 52 | #define G_WRITE "GModelSpatialDiffuseCube::write(GXmlElement&)" |
| 53 | 53 | #define G_ENERGIES "GModelSpatialDiffuseCube::energies(GEnergies&)" |
| 54 | -#define G_LOAD_CUBE "GModelSpatialDiffuseCube::load_cube()" | |
| 54 | +#define G_LOAD_CUBE "GModelSpatialDiffuseCube::load_cube(GFilename&)" | |
| 55 | 55 | |
| 56 | 56 | /* __ Macros _____________________________________________________________ */ |
| 57 | 57 | |
| ... | ... | @@ -113,8 +113,8 @@ GModelSpatialDiffuseCube::GModelSpatialDiffuseCube(const GXmlElement& xml) : |
| 113 | 113 | * Constructs map cube model by loading a map cube from @p filename and by |
| 114 | 114 | * assigning the normalization @p value. |
| 115 | 115 | ***************************************************************************/ |
| 116 | -GModelSpatialDiffuseCube::GModelSpatialDiffuseCube(const std::string& filename, | |
| 117 | - const double& value) : | |
| 116 | +GModelSpatialDiffuseCube::GModelSpatialDiffuseCube(const GFilename& filename, | |
| 117 | + const double& value) : | |
| 118 | 118 | GModelSpatialDiffuse() |
| 119 | 119 | { |
| 120 | 120 | // Initialise members |
| ... | ... | @@ -649,7 +649,7 @@ void GModelSpatialDiffuseCube::write(GXmlElement& xml) const |
| 649 | 649 | } |
| 650 | 650 | |
| 651 | 651 | // Set filename |
| 652 | - xml.attribute("file", m_filename); | |
| 652 | + xml.attribute("file", m_filename.url()); | |
| 653 | 653 | |
| 654 | 654 | // Return |
| 655 | 655 | return; |
| ... | ... | @@ -975,7 +975,7 @@ void GModelSpatialDiffuseCube::set_mc_cone(const GSkyDir& centre, |
| 975 | 975 | * |
| 976 | 976 | * Loads cube into the model class. |
| 977 | 977 | ***************************************************************************/ |
| 978 | -void GModelSpatialDiffuseCube::load(const std::string& filename) | |
| 978 | +void GModelSpatialDiffuseCube::load(const GFilename& filename) | |
| 979 | 979 | { |
| 980 | 980 | // Load cube |
| 981 | 981 | load_cube(filename); |
| ... | ... | @@ -992,12 +992,12 @@ void GModelSpatialDiffuseCube::load(const std::string& filename) |
| 992 | 992 | * @brief Save cube into FITS file |
| 993 | 993 | * |
| 994 | 994 | * @param[in] filename Cube FITS file name. |
| 995 | - * @param[in] clobber Overwrite existing FITS file (default=false). | |
| 995 | + * @param[in] clobber Overwrite existing FITS file (default: false). | |
| 996 | 996 | * |
| 997 | 997 | * Saves spatial cube model into a FITS file. |
| 998 | 998 | ***************************************************************************/ |
| 999 | -void GModelSpatialDiffuseCube::save(const std::string& filename, | |
| 1000 | - const bool& clobber) const | |
| 999 | +void GModelSpatialDiffuseCube::save(const GFilename& filename, | |
| 1000 | + const bool& clobber) const | |
| 1001 | 1001 | { |
| 1002 | 1002 | // Create empty FITS file |
| 1003 | 1003 | GFits fits; |
| ... | ... | @@ -1056,7 +1056,8 @@ std::string GModelSpatialDiffuseCube::print(const GChatter& chatter) const |
| 1056 | 1056 | result.append("=== GModelSpatialDiffuseCube ==="); |
| 1057 | 1057 | |
| 1058 | 1058 | // Append parameters |
| 1059 | - result.append("\n"+gammalib::parformat("Map cube file")+m_filename); | |
| 1059 | + result.append("\n"+gammalib::parformat("Map cube file")); | |
| 1060 | + result.append(m_filename.url()); | |
| 1060 | 1061 | if (m_loaded) { |
| 1061 | 1062 | result.append(" [loaded]"); |
| 1062 | 1063 | } |
| ... | ... | @@ -1210,7 +1211,7 @@ void GModelSpatialDiffuseCube::free_members(void) |
| 1210 | 1211 | void GModelSpatialDiffuseCube::fetch_cube(void) const |
| 1211 | 1212 | { |
| 1212 | 1213 | // Load cube if it is not yet loaded |
| 1213 | - if (!m_loaded && !m_filename.empty()) { | |
| 1214 | + if (!m_loaded && !m_filename.is_empty()) { | |
| 1214 | 1215 | |
| 1215 | 1216 | // Put in a OMP critical zone |
| 1216 | 1217 | #pragma omp critical |
| ... | ... | @@ -1235,7 +1236,7 @@ void GModelSpatialDiffuseCube::fetch_cube(void) const |
| 1235 | 1236 | * |
| 1236 | 1237 | * Load diffuse cube. |
| 1237 | 1238 | ***************************************************************************/ |
| 1238 | -void GModelSpatialDiffuseCube::load_cube(const std::string& filename) | |
| 1239 | +void GModelSpatialDiffuseCube::load_cube(const GFilename& filename) | |
| 1239 | 1240 | { |
| 1240 | 1241 | // Initialise skymap |
| 1241 | 1242 | m_cube.clear(); |
| ... | ... | @@ -1248,13 +1249,14 @@ void GModelSpatialDiffuseCube::load_cube(const std::string& filename) |
| 1248 | 1249 | m_filename = filename; |
| 1249 | 1250 | |
| 1250 | 1251 | // Get expanded filename |
| 1251 | - std::string fname = gammalib::expand_env(filename); | |
| 1252 | + //std::string fname = gammalib::expand_env(filename); | |
| 1252 | 1253 | |
| 1253 | 1254 | // Load cube |
| 1254 | - m_cube.load(fname); | |
| 1255 | + //m_cube.load(fname); | |
| 1256 | + m_cube.load(filename); | |
| 1255 | 1257 | |
| 1256 | 1258 | // Load energies |
| 1257 | - GEnergies energies(fname); | |
| 1259 | + GEnergies energies(filename); | |
| 1258 | 1260 | |
| 1259 | 1261 | // Extract number of energy bins |
| 1260 | 1262 | int num = energies.size(); | ... | ... |
src/sky/GSkyMap.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GSkyMap.cpp - Sky map class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2015 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -31,13 +31,18 @@ |
| 31 | 31 | #include "GException.hpp" |
| 32 | 32 | #include "GMath.hpp" |
| 33 | 33 | #include "GTools.hpp" |
| 34 | +#include "GFits.hpp" | |
| 35 | +#include "GFitsTable.hpp" | |
| 36 | +#include "GFitsBinTable.hpp" | |
| 37 | +#include "GFitsImage.hpp" | |
| 38 | +#include "GFitsImageDouble.hpp" | |
| 39 | +#include "GFitsTableDoubleCol.hpp" | |
| 34 | 40 | #include "GSkyMap.hpp" |
| 35 | 41 | #include "GHealpix.hpp" |
| 36 | 42 | #include "GWcsRegistry.hpp" |
| 37 | 43 | #include "GWcs.hpp" |
| 38 | -#include "GFits.hpp" | |
| 39 | -#include "GFitsTableDoubleCol.hpp" | |
| 40 | -#include "GFitsImageDouble.hpp" | |
| 44 | +#include "GMatrix.hpp" | |
| 45 | +#include "GVector.hpp" | |
| 41 | 46 | |
| 42 | 47 | /* __ Method name definitions ____________________________________________ */ |
| 43 | 48 | #define G_CONSTRUCT_HPX "GSkyMap::GSkyMap(std::string&, int&,"\ |
| ... | ... | @@ -105,7 +110,7 @@ GSkyMap::GSkyMap(void) |
| 105 | 110 | * |
| 106 | 111 | * @param[in] filename FITS file name. |
| 107 | 112 | ***************************************************************************/ |
| 108 | -GSkyMap::GSkyMap(const std::string& filename) | |
| 113 | +GSkyMap::GSkyMap(const GFilename& filename) | |
| 109 | 114 | { |
| 110 | 115 | // Initialise class members for clean destruction |
| 111 | 116 | init_members(); |
| ... | ... | @@ -1739,7 +1744,7 @@ void GSkyMap::stack_maps(void) |
| 1739 | 1744 | * @todo Do we have to restrict a HEALPix map to a BinTable and a WCS map |
| 1740 | 1745 | * to a Double precision image??? |
| 1741 | 1746 | ***************************************************************************/ |
| 1742 | -void GSkyMap::load(const std::string& filename) | |
| 1747 | +void GSkyMap::load(const GFilename& filename) | |
| 1743 | 1748 | { |
| 1744 | 1749 | // Free memory and initialise members |
| 1745 | 1750 | free_members(); |
| ... | ... | @@ -1808,7 +1813,7 @@ void GSkyMap::load(const std::string& filename) |
| 1808 | 1813 | * |
| 1809 | 1814 | * The method does nothing if the skymap holds no valid WCS. |
| 1810 | 1815 | ***************************************************************************/ |
| 1811 | -void GSkyMap::save(const std::string& filename, bool clobber) const | |
| 1816 | +void GSkyMap::save(const GFilename& filename, bool clobber) const | |
| 1812 | 1817 | { |
| 1813 | 1818 | // Continue only if we have data to save |
| 1814 | 1819 | if (m_proj != NULL) { | ... | ... |
src/support/GCsv.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GCsv.cpp - Comma-separated values table class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2015 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -31,12 +31,13 @@ |
| 31 | 31 | #include <cstdio> // std::fopen, std::fgets, std::fclose, etc... |
| 32 | 32 | #include "GCsv.hpp" |
| 33 | 33 | #include "GTools.hpp" |
| 34 | +#include "GFilename.hpp" | |
| 34 | 35 | #include "GException.hpp" |
| 35 | 36 | |
| 36 | 37 | /* __ Method name definitions ____________________________________________ */ |
| 37 | 38 | #define G_ACCESS "GCsv::operator()(int&, int&)" |
| 38 | -#define G_LOAD "GCsv::load(std::string&, std::string&)" | |
| 39 | -#define G_SAVE "GCsv::save(std::string&, std::string&, bool&)" | |
| 39 | +#define G_LOAD "GCsv::load(GFilename&, std::string&)" | |
| 40 | +#define G_SAVE "GCsv::save(GFilename&, std::string&, bool&)" | |
| 40 | 41 | |
| 41 | 42 | /* __ Macros _____________________________________________________________ */ |
| 42 | 43 | |
| ... | ... | @@ -96,7 +97,7 @@ GCsv::GCsv(const int& nrows, const int& ncols) |
| 96 | 97 | * @param[in] filename Filename. |
| 97 | 98 | * @param[in] sep Column separator (default is whitespace). |
| 98 | 99 | ***************************************************************************/ |
| 99 | -GCsv::GCsv(const std::string& filename, const std::string& sep) | |
| 100 | +GCsv::GCsv(const GFilename& filename, const std::string& sep) | |
| 100 | 101 | { |
| 101 | 102 | // Initialise private |
| 102 | 103 | init_members(); |
| ... | ... | @@ -370,7 +371,7 @@ void GCsv::integer(const int& row, const int& col, const int& value) |
| 370 | 371 | * Load CSV table from ASCII file. Any environment variable present in the |
| 371 | 372 | * filename will be expanded. |
| 372 | 373 | **************************************************************************/ |
| 373 | -void GCsv::load(const std::string& filename, const std::string& sep) | |
| 374 | +void GCsv::load(const GFilename& filename, const std::string& sep) | |
| 374 | 375 | { |
| 375 | 376 | // Clear instance |
| 376 | 377 | clear(); |
| ... | ... | @@ -380,7 +381,7 @@ void GCsv::load(const std::string& filename, const std::string& sep) |
| 380 | 381 | char line[n]; |
| 381 | 382 | |
| 382 | 383 | // Expand environment variables |
| 383 | - std::string fname = gammalib::expand_env(filename); | |
| 384 | + std::string fname = gammalib::expand_env(filename.url()); | |
| 384 | 385 | |
| 385 | 386 | // Open CSV table (read-only) |
| 386 | 387 | FILE* fptr = std::fopen(fname.c_str(), "r"); |
| ... | ... | @@ -456,25 +457,26 @@ void GCsv::load(const std::string& filename, const std::string& sep) |
| 456 | 457 | * Save CSV table into ASCII file. Any environment variable present in the |
| 457 | 458 | * filename will be expanded. |
| 458 | 459 | **************************************************************************/ |
| 459 | -void GCsv::save(const std::string& filename, const std::string& sep, | |
| 460 | - const bool& clobber) const | |
| 460 | +void GCsv::save(const GFilename& filename, | |
| 461 | + const std::string& sep, | |
| 462 | + const bool& clobber) const | |
| 461 | 463 | { |
| 462 | 464 | // Throw exception if file exists but clobber flag is false |
| 463 | - if (!clobber && gammalib::file_exists(filename)) { | |
| 464 | - std::string msg = "File \""+filename+"\" exists already but the " | |
| 465 | - "clobber flag is set to \"false\". Set the " | |
| 465 | + if (!clobber && gammalib::file_exists(filename.url())) { | |
| 466 | + std::string msg = "File \""+filename.url()+"\" exists already but " | |
| 467 | + "the clobber flag is set to \"false\". Set the " | |
| 466 | 468 | "clobber flag to true to overwrite the existing " |
| 467 | 469 | "file or specify another file name."; |
| 468 | 470 | throw GException::invalid_value(G_SAVE, msg); |
| 469 | 471 | } |
| 470 | 472 | |
| 471 | 473 | // Expand environment variables |
| 472 | - std::string fname = gammalib::expand_env(filename); | |
| 474 | + std::string fname = gammalib::expand_env(filename.url()); | |
| 473 | 475 | |
| 474 | 476 | // Open CSV table (write-only) |
| 475 | 477 | FILE* fptr = std::fopen(fname.c_str(), "w"); |
| 476 | 478 | if (fptr == NULL) { |
| 477 | - std::string msg = "Unable to create file \""+filename+"\"."; | |
| 479 | + std::string msg = "Unable to create file \""+filename.url()+"\"."; | |
| 478 | 480 | throw GException::file_error(G_SAVE, msg); |
| 479 | 481 | } |
| 480 | 482 | ... | ... |
src/xspec/GArf.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GArf.cpp - XSPEC Auxiliary Response File class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2013 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2013-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -30,7 +30,10 @@ |
| 30 | 30 | #endif |
| 31 | 31 | #include "GArf.hpp" |
| 32 | 32 | #include "GException.hpp" |
| 33 | +#include "GFilename.hpp" | |
| 33 | 34 | #include "GTools.hpp" |
| 35 | +#include "GFits.hpp" | |
| 36 | +#include "GFitsTable.hpp" | |
| 34 | 37 | #include "GFitsBinTable.hpp" |
| 35 | 38 | #include "GFitsTableShortCol.hpp" |
| 36 | 39 | #include "GFitsTableFloatCol.hpp" |
| ... | ... | @@ -69,7 +72,7 @@ GArf::GArf(void) |
| 69 | 72 | * |
| 70 | 73 | * @param[in] filename File name. |
| 71 | 74 | ***************************************************************************/ |
| 72 | -GArf::GArf(const std::string& filename) | |
| 75 | +GArf::GArf(const GFilename& filename) | |
| 73 | 76 | { |
| 74 | 77 | // Initialise members |
| 75 | 78 | init_members(); |
| ... | ... | @@ -250,7 +253,7 @@ const double& GArf::at(const int& index) const |
| 250 | 253 | * |
| 251 | 254 | * @param[in] filename File name. |
| 252 | 255 | ***************************************************************************/ |
| 253 | -void GArf::load(const std::string& filename) | |
| 256 | +void GArf::load(const GFilename& filename) | |
| 254 | 257 | { |
| 255 | 258 | // Clear any existing models |
| 256 | 259 | clear(); |
| ... | ... | @@ -279,9 +282,9 @@ void GArf::load(const std::string& filename) |
| 279 | 282 | * @brief Save Auxiliary Response File |
| 280 | 283 | * |
| 281 | 284 | * @param[in] filename File name. |
| 282 | - * @param[in] clobber Overwrite existing file? (defaults to true) | |
| 285 | + * @param[in] clobber Overwrite existing file? (defaults: false) | |
| 283 | 286 | ***************************************************************************/ |
| 284 | -void GArf::save(const std::string& filename, const bool& clobber) const | |
| 287 | +void GArf::save(const GFilename& filename, const bool& clobber) const | |
| 285 | 288 | { |
| 286 | 289 | // Open FITS file |
| 287 | 290 | GFits fits; | ... | ... |
test/test_GModel.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * test_GModel.cpp - test GModel class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2009-2015 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2009-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -584,7 +584,7 @@ void TestGModel::test_diffuse_cube(void) |
| 584 | 584 | GModelSpatialDiffuseCube model; |
| 585 | 585 | test_assert(model.type() == "MapCubeFunction", |
| 586 | 586 | "Model type \"MapCubeFunction\" expected."); |
| 587 | - test_assert(model.filename() == "", "Model filename \"\" expected."); | |
| 587 | + test_assert(model.filename().url() == "", "Model filename \"\" expected."); | |
| 588 | 588 | test_try_success(); |
| 589 | 589 | } |
| 590 | 590 | catch (std::exception &e) { |
| ... | ... | @@ -596,7 +596,8 @@ void TestGModel::test_diffuse_cube(void) |
| 596 | 596 | try { |
| 597 | 597 | GModelSpatialDiffuseCube model(m_cube_file, 3.0); |
| 598 | 598 | test_value(model.value(), 3.0); |
| 599 | - test_assert(model.filename() == m_cube_file, "Expected \""+m_cube_file+"\""); | |
| 599 | + test_assert(model.filename().url() == m_cube_file, | |
| 600 | + "Expected \""+m_cube_file+"\""); | |
| 600 | 601 | test_try_success(); |
| 601 | 602 | } |
| 602 | 603 | catch (std::exception &e) { |
| ... | ... | @@ -613,7 +614,7 @@ void TestGModel::test_diffuse_cube(void) |
| 613 | 614 | } |
| 614 | 615 | GModelSpatialDiffuseCube model(map, energies, 3.0); |
| 615 | 616 | test_value(model.value(), 3.0); |
| 616 | - test_assert(model.filename() == "", "Expected \"\""); | |
| 617 | + test_assert(model.filename().url() == "", "Expected \"\""); | |
| 617 | 618 | //test_assert(model.cube() == map, "Map cube is not the expected one"); |
| 618 | 619 | test_try_success(); |
| 619 | 620 | } |
| ... | ... | @@ -631,8 +632,8 @@ void TestGModel::test_diffuse_cube(void) |
| 631 | 632 | test_value(model.size(), 1); |
| 632 | 633 | test_assert(model.type() == "MapCubeFunction", "Expected \"MapCubeFunction\""); |
| 633 | 634 | test_value(model.value(), 1.0); |
| 634 | - test_assert(model.filename() == m_cube_file, | |
| 635 | - "Model filename \""+m_cube_file+"\" expected."); | |
| 635 | + test_assert(model.filename().url() == m_cube_file, | |
| 636 | + "Model filename \""+m_cube_file+"\" expected."); | |
| 636 | 637 | |
| 637 | 638 | // Test value method |
| 638 | 639 | model.value(3.9); |
| ... | ... | @@ -640,8 +641,8 @@ void TestGModel::test_diffuse_cube(void) |
| 640 | 641 | |
| 641 | 642 | // Test filename method |
| 642 | 643 | model.filename("Help me!"); |
| 643 | - test_assert(model.filename() == "Help me!", | |
| 644 | - "Model filename \"Help me!\" expected."); | |
| 644 | + test_assert(model.filename().url() == "Help me!", | |
| 645 | + "Model filename \"Help me!\" expected."); | |
| 645 | 646 | |
| 646 | 647 | // Test cube method |
| 647 | 648 | model.cube(GSkyMap("GAL", 16, "RING", 10)); | ... | ... |
test/test_GXspec.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * test_GXspec.hpp - Test Xspec module * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2013 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2013-2016 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -210,11 +210,11 @@ void TestGXspec::test_GArf(void) |
| 210 | 210 | |
| 211 | 211 | // Test saving and loading |
| 212 | 212 | arf.save("arf.fits", true); |
| 213 | - test_assert(arf.filename() == "arf.fits", | |
| 214 | - "Unexpected filename \""+arf.filename()+"\"."); | |
| 213 | + test_assert(arf.filename().url() == "arf.fits", | |
| 214 | + "Unexpected filename \""+arf.filename().url()+"\"."); | |
| 215 | 215 | arf.load("arf.fits"); |
| 216 | - test_assert(arf.filename() == "arf.fits", | |
| 217 | - "Unexpected filename \""+arf.filename()+"\"."); | |
| 216 | + test_assert(arf.filename().url() == "arf.fits", | |
| 217 | + "Unexpected filename \""+arf.filename().url()+"\"."); | |
| 218 | 218 | test_value(arf[0], 5.0, 1.0e-6); |
| 219 | 219 | test_value(arf[1], 3.7, 1.0e-6); |
| 220 | 220 | for (int i = 2; i < 9; i += 2) { |
| ... | ... | @@ -228,8 +228,8 @@ void TestGXspec::test_GArf(void) |
| 228 | 228 | |
| 229 | 229 | // Test constructing |
| 230 | 230 | GArf arf2("arf.fits"); |
| 231 | - test_assert(arf2.filename() == "arf.fits", | |
| 232 | - "Unexpected filename \""+arf2.filename()+"\"."); | |
| 231 | + test_assert(arf2.filename().url() == "arf.fits", | |
| 232 | + "Unexpected filename \""+arf2.filename().url()+"\"."); | |
| 233 | 233 | test_value(arf2[0], 5.0, 1.0e-6); |
| 234 | 234 | test_value(arf2[1], 3.7, 1.0e-6); |
| 235 | 235 | for (int i = 2; i < 9; i += 2) { | ... | ... |