Commit e64cb7dedf9ae5a46361f06a2d00d37873f95851
1 parent
4a1f879a
Replace alias() method by type constructor for spatial model components (#1818).
It seems better to not introduce the alias method but to use a type constructor instead. This allows writing out the same model type that was read in, enhancing the compatibility with the legacy XML format.
Showing
24 changed files
with
327 additions
and
214 deletions
configure.ac
| ... | ... | @@ -699,16 +699,16 @@ fi |
| 699 | 699 | |
| 700 | 700 | |
| 701 | 701 | ############################################################################# |
| 702 | -# Checks for Legacy model names option (G_LEGACY_MODEL_NAMES) # | |
| 703 | -############################################################################# | |
| 704 | -AC_MSG_CHECKING(whether to enable legacy model names option) | |
| 705 | -AC_ARG_ENABLE([legacy_model_names], | |
| 706 | - AS_HELP_STRING([--enable-legacy-model-names], | |
| 707 | - [enables legacy model names [default=yes]]), | |
| 708 | - [LEGACY_MODEL_NAMES="$enableval"], | |
| 709 | - [LEGACY_MODEL_NAMES="yes"]) | |
| 710 | -if test "x$LEGACY_MODEL_NAMES" = "xyes"; then | |
| 711 | - AC_DEFINE([G_LEGACY_MODEL_NAMES], [1], [Legacy model names are enabled]) | |
| 702 | +# Checks for Legacy XML format option (G_LEGACY_XML_FORMAT) # | |
| 703 | +############################################################################# | |
| 704 | +AC_MSG_CHECKING(whether to support legacy XML format option) | |
| 705 | +AC_ARG_ENABLE([legacy_xml_format], | |
| 706 | + AS_HELP_STRING([--enable-legacy-xml-format], | |
| 707 | + [support legacy XML format [default=yes]]), | |
| 708 | + [LEGACY_XML_FORMAT="$enableval"], | |
| 709 | + [LEGACY_XML_FORMAT="yes"]) | |
| 710 | +if test "x$LEGACY_XML_FORMAT" = "xyes"; then | |
| 711 | + AC_DEFINE([G_LEGACY_XML_FORMAT], [1], [Legacy XML format is supported]) | |
| 712 | 712 | AC_MSG_RESULT(yes) |
| 713 | 713 | else |
| 714 | 714 | AC_MSG_RESULT(no) |
| ... | ... | @@ -1577,10 +1577,10 @@ if test "x$SMALL_MEMORY" = "xyes"; then |
| 1577 | 1577 | else |
| 1578 | 1578 | echo " - Optimize memory usage (no)" |
| 1579 | 1579 | fi |
| 1580 | -if test "x$LEGACY_MODEL_NAMES" = "xyes"; then | |
| 1581 | - echo " * Enable legacy model names (yes) (default)" | |
| 1580 | +if test "x$LEGACY_XML_FORMAT" = "xyes"; then | |
| 1581 | + echo " * Support legacy XML format (yes) (default)" | |
| 1582 | 1582 | else |
| 1583 | - echo " - Enable legacy model names (no)" | |
| 1583 | + echo " - Support legacy XML format (no)" | |
| 1584 | 1584 | fi |
| 1585 | 1585 | if test "x$enable_openmp" = "xyes"; then |
| 1586 | 1586 | echo " * Enable OpenMP (yes) (default)" | ... | ... |
include/GModelSpatial.hpp
| ... | ... | @@ -86,7 +86,6 @@ public: |
| 86 | 86 | virtual GModelSpatial* clone(void) const = 0; |
| 87 | 87 | virtual std::string classname(void) const = 0; |
| 88 | 88 | virtual std::string type(void) const = 0; |
| 89 | - virtual std::string alias(void) const = 0; | |
| 90 | 89 | virtual GClassCode code(void) const = 0; |
| 91 | 90 | virtual double eval(const GPhoton& photon) const = 0; |
| 92 | 91 | virtual double eval_gradients(const GPhoton& photon) const = 0; | ... | ... |
include/GModelSpatialDiffuse.hpp
| ... | ... | @@ -62,7 +62,6 @@ public: |
| 62 | 62 | virtual GModelSpatialDiffuse* clone(void) const = 0; |
| 63 | 63 | virtual std::string classname(void) const = 0; |
| 64 | 64 | virtual std::string type(void) const = 0; |
| 65 | - virtual std::string alias(void) const = 0; | |
| 66 | 65 | virtual double eval(const GPhoton& photon) const = 0; |
| 67 | 66 | virtual double eval_gradients(const GPhoton& photon) const = 0; |
| 68 | 67 | virtual GSkyDir mc(const GEnergy& energy, const GTime& time, | ... | ... |
include/GModelSpatialDiffuseConst.hpp
| ... | ... | @@ -49,6 +49,7 @@ class GModelSpatialDiffuseConst : public GModelSpatialDiffuse { |
| 49 | 49 | public: |
| 50 | 50 | // Constructors and destructors |
| 51 | 51 | GModelSpatialDiffuseConst(void); |
| 52 | + GModelSpatialDiffuseConst(const bool& dummy, const std::string& type); | |
| 52 | 53 | explicit GModelSpatialDiffuseConst(const GXmlElement& xml); |
| 53 | 54 | explicit GModelSpatialDiffuseConst(const double& value); |
| 54 | 55 | GModelSpatialDiffuseConst(const GModelSpatialDiffuseConst& model); |
| ... | ... | @@ -62,7 +63,6 @@ public: |
| 62 | 63 | virtual GModelSpatialDiffuseConst* clone(void) const; |
| 63 | 64 | virtual std::string classname(void) const; |
| 64 | 65 | virtual std::string type(void) const; |
| 65 | - virtual std::string alias(void) const; | |
| 66 | 66 | virtual double eval(const GPhoton& photon) const; |
| 67 | 67 | virtual double eval_gradients(const GPhoton& photon) const; |
| 68 | 68 | virtual GSkyDir mc(const GEnergy& energy, |
| ... | ... | @@ -87,6 +87,7 @@ protected: |
| 87 | 87 | void free_members(void); |
| 88 | 88 | |
| 89 | 89 | // Protected members |
| 90 | + std::string m_type; //!< Model type | |
| 90 | 91 | GModelPar m_value; //!< Value |
| 91 | 92 | mutable GSkyDir m_mc_centre; //!< Simulation cone centre |
| 92 | 93 | mutable double m_mc_cos_radius; //!< Cosine of simulation cone radius |
| ... | ... | @@ -108,28 +109,14 @@ std::string GModelSpatialDiffuseConst::classname(void) const |
| 108 | 109 | /***********************************************************************//** |
| 109 | 110 | * @brief Return spatial model type |
| 110 | 111 | * |
| 111 | - * @return "DiffuseIsotropic". | |
| 112 | + * @return Model type. | |
| 112 | 113 | * |
| 113 | 114 | * Returns the type of the isotropic spatial model. |
| 114 | 115 | ***************************************************************************/ |
| 115 | 116 | inline |
| 116 | 117 | std::string GModelSpatialDiffuseConst::type(void) const |
| 117 | 118 | { |
| 118 | - return "DiffuseIsotropic"; | |
| 119 | -} | |
| 120 | - | |
| 121 | - | |
| 122 | -/***********************************************************************//** | |
| 123 | - * @brief Return spatial model type alias | |
| 124 | - * | |
| 125 | - * @return "ConstantValue". | |
| 126 | - * | |
| 127 | - * Returns the alias of the isotropic spatial model. | |
| 128 | - ***************************************************************************/ | |
| 129 | -inline | |
| 130 | -std::string GModelSpatialDiffuseConst::alias(void) const | |
| 131 | -{ | |
| 132 | - return "ConstantValue"; | |
| 119 | + return (m_type); | |
| 133 | 120 | } |
| 134 | 121 | |
| 135 | 122 | ... | ... |
include/GModelSpatialDiffuseCube.hpp
| ... | ... | @@ -60,6 +60,7 @@ class GModelSpatialDiffuseCube : public GModelSpatialDiffuse { |
| 60 | 60 | public: |
| 61 | 61 | // Constructors and destructors |
| 62 | 62 | GModelSpatialDiffuseCube(void); |
| 63 | + GModelSpatialDiffuseCube(const bool& dummy, const std::string& type); | |
| 63 | 64 | explicit GModelSpatialDiffuseCube(const GXmlElement& xml); |
| 64 | 65 | GModelSpatialDiffuseCube(const GFilename& filename, |
| 65 | 66 | const double& value = 1.0); |
| ... | ... | @@ -77,7 +78,6 @@ public: |
| 77 | 78 | virtual GModelSpatialDiffuseCube* clone(void) const; |
| 78 | 79 | virtual std::string classname(void) const; |
| 79 | 80 | virtual std::string type(void) const; |
| 80 | - virtual std::string alias(void) const; | |
| 81 | 81 | virtual double eval(const GPhoton& photon) const; |
| 82 | 82 | virtual double eval_gradients(const GPhoton& photon) const; |
| 83 | 83 | virtual GSkyDir mc(const GEnergy& energy, |
| ... | ... | @@ -122,12 +122,13 @@ protected: |
| 122 | 122 | double cube_intensity(const GPhoton& photon) const; |
| 123 | 123 | |
| 124 | 124 | // Protected members |
| 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 | |
| 125 | + std::string m_type; //!< Model type | |
| 126 | + GModelPar m_value; //!< Value | |
| 127 | + GFilename m_filename; //!< Name of map cube | |
| 128 | + bool m_loaded; //!< Signals if map cube has been loaded | |
| 129 | + GSkyMap m_cube; //!< Map cube | |
| 130 | + GNodeArray m_logE; //!< Log10(energy) values of the maps | |
| 131 | + GEbounds m_ebounds; //!< Energy bounds of the maps | |
| 131 | 132 | |
| 132 | 133 | // Monte Carlo cache |
| 133 | 134 | mutable GSkyDir m_mc_centre; //!< Centre of MC cone |
| ... | ... | @@ -153,28 +154,14 @@ std::string GModelSpatialDiffuseCube::classname(void) const |
| 153 | 154 | /***********************************************************************//** |
| 154 | 155 | * @brief Return spatial model type |
| 155 | 156 | * |
| 156 | - * @return "DiffuseMapCube". | |
| 157 | + * @return Model type. | |
| 157 | 158 | * |
| 158 | 159 | * Returns the type of the spatial map cube model. |
| 159 | 160 | ***************************************************************************/ |
| 160 | 161 | inline |
| 161 | 162 | std::string GModelSpatialDiffuseCube::type(void) const |
| 162 | 163 | { |
| 163 | - return "DiffuseMapCube"; | |
| 164 | -} | |
| 165 | - | |
| 166 | - | |
| 167 | -/***********************************************************************//** | |
| 168 | - * @brief Return spatial model type alias | |
| 169 | - * | |
| 170 | - * @return "MapCubeFunction". | |
| 171 | - * | |
| 172 | - * Returns the alias of the spatial map cube model. | |
| 173 | - ***************************************************************************/ | |
| 174 | -inline | |
| 175 | -std::string GModelSpatialDiffuseCube::alias(void) const | |
| 176 | -{ | |
| 177 | - return "MapCubeFunction"; | |
| 164 | + return (m_type); | |
| 178 | 165 | } |
| 179 | 166 | |
| 180 | 167 | ... | ... |
include/GModelSpatialDiffuseMap.hpp
| ... | ... | @@ -51,6 +51,7 @@ class GModelSpatialDiffuseMap : public GModelSpatialDiffuse { |
| 51 | 51 | public: |
| 52 | 52 | // Constructors and destructors |
| 53 | 53 | GModelSpatialDiffuseMap(void); |
| 54 | + GModelSpatialDiffuseMap(const bool& dummy, const std::string& type); | |
| 54 | 55 | explicit GModelSpatialDiffuseMap(const GXmlElement& xml); |
| 55 | 56 | GModelSpatialDiffuseMap(const GFilename& filename, |
| 56 | 57 | const double& value = 1.0, |
| ... | ... | @@ -69,7 +70,6 @@ public: |
| 69 | 70 | virtual GModelSpatialDiffuseMap* clone(void) const; |
| 70 | 71 | virtual std::string classname(void) const; |
| 71 | 72 | virtual std::string type(void) const; |
| 72 | - virtual std::string alias(void) const; | |
| 73 | 73 | virtual double eval(const GPhoton& photon) const; |
| 74 | 74 | virtual double eval_gradients(const GPhoton& photon) const; |
| 75 | 75 | virtual GSkyDir mc(const GEnergy& energy, |
| ... | ... | @@ -102,13 +102,14 @@ protected: |
| 102 | 102 | void prepare_map(void); |
| 103 | 103 | |
| 104 | 104 | // Protected members |
| 105 | - GModelPar m_value; //!< Value | |
| 106 | - GSkyMap m_map; //!< Skymap | |
| 107 | - GFilename m_filename; //!< Name of skymap | |
| 108 | - GSkyDir m_centre; //!< Centre of bounding circle | |
| 109 | - double m_radius; //!< Radius of bounding circle | |
| 110 | - bool m_normalize; //!< Normalize map (default: true) | |
| 111 | - bool m_has_normalize; //!< XML has normalize attribute | |
| 105 | + std::string m_type; //!< Model type | |
| 106 | + GModelPar m_value; //!< Value | |
| 107 | + GSkyMap m_map; //!< Skymap | |
| 108 | + GFilename m_filename; //!< Name of skymap | |
| 109 | + GSkyDir m_centre; //!< Centre of bounding circle | |
| 110 | + double m_radius; //!< Radius of bounding circle | |
| 111 | + bool m_normalize; //!< Normalize map (default: true) | |
| 112 | + bool m_has_normalize; //!< XML has normalize attribute | |
| 112 | 113 | |
| 113 | 114 | // MC simulation cache |
| 114 | 115 | mutable GSkyDir m_mc_centre; //!< Centre of MC cone |
| ... | ... | @@ -134,28 +135,14 @@ std::string GModelSpatialDiffuseMap::classname(void) const |
| 134 | 135 | /***********************************************************************//** |
| 135 | 136 | * @brief Return spatial model type |
| 136 | 137 | * |
| 137 | - * @return "DiffuseMap". | |
| 138 | + * @return Model type. | |
| 138 | 139 | * |
| 139 | 140 | * Returns the type of the spatial map model. |
| 140 | 141 | ***************************************************************************/ |
| 141 | 142 | inline |
| 142 | 143 | std::string GModelSpatialDiffuseMap::type(void) const |
| 143 | 144 | { |
| 144 | - return "DiffuseMap"; | |
| 145 | -} | |
| 146 | - | |
| 147 | - | |
| 148 | -/***********************************************************************//** | |
| 149 | - * @brief Return spatial model type alias | |
| 150 | - * | |
| 151 | - * @return "SpatialMap". | |
| 152 | - * | |
| 153 | - * Returns the alias of the spatial map model. | |
| 154 | - ***************************************************************************/ | |
| 155 | -inline | |
| 156 | -std::string GModelSpatialDiffuseMap::alias(void) const | |
| 157 | -{ | |
| 158 | - return "SpatialMap"; | |
| 145 | + return (m_type); | |
| 159 | 146 | } |
| 160 | 147 | |
| 161 | 148 | ... | ... |
include/GModelSpatialElliptical.hpp
| ... | ... | @@ -66,7 +66,6 @@ public: |
| 66 | 66 | virtual GModelSpatialElliptical* clone(void) const = 0; |
| 67 | 67 | virtual std::string classname(void) const = 0; |
| 68 | 68 | virtual std::string type(void) const = 0; |
| 69 | - virtual std::string alias(void) const = 0; | |
| 70 | 69 | virtual double eval(const double& theta, |
| 71 | 70 | const double& posangle, |
| 72 | 71 | const GEnergy& energy, | ... | ... |
include/GModelSpatialEllipticalDisk.hpp
| ... | ... | @@ -65,7 +65,6 @@ public: |
| 65 | 65 | virtual GModelSpatialEllipticalDisk* clone(void) const; |
| 66 | 66 | virtual std::string classname(void) const; |
| 67 | 67 | virtual std::string type(void) const; |
| 68 | - virtual std::string alias(void) const; | |
| 69 | 68 | virtual double eval(const double& theta, |
| 70 | 69 | const double& posangle, |
| 71 | 70 | const GEnergy& energy, |
| ... | ... | @@ -126,18 +125,4 @@ std::string GModelSpatialEllipticalDisk::type(void) const |
| 126 | 125 | return "EllipticalDisk"; |
| 127 | 126 | } |
| 128 | 127 | |
| 129 | - | |
| 130 | -/***********************************************************************//** | |
| 131 | - * @brief Return model type alias | |
| 132 | - * | |
| 133 | - * @return "EllipticalDisk". | |
| 134 | - * | |
| 135 | - * Returns the alias of the elliptical disk model. | |
| 136 | - ***************************************************************************/ | |
| 137 | -inline | |
| 138 | -std::string GModelSpatialEllipticalDisk::alias(void) const | |
| 139 | -{ | |
| 140 | - return "EllipticalDisk"; | |
| 141 | -} | |
| 142 | - | |
| 143 | 128 | #endif /* GMODELSPATIALELLIPTICALDISK_HPP */ | ... | ... |
include/GModelSpatialEllipticalGauss.hpp
| ... | ... | @@ -49,6 +49,7 @@ class GModelSpatialEllipticalGauss : public GModelSpatialElliptical { |
| 49 | 49 | public: |
| 50 | 50 | // Constructors and destructors |
| 51 | 51 | GModelSpatialEllipticalGauss(void); |
| 52 | + GModelSpatialEllipticalGauss(const bool& dummy, const std::string& type); | |
| 52 | 53 | GModelSpatialEllipticalGauss(const GSkyDir& dir, |
| 53 | 54 | const double& major, |
| 54 | 55 | const double& minor, |
| ... | ... | @@ -65,7 +66,6 @@ public: |
| 65 | 66 | virtual GModelSpatialEllipticalGauss* clone(void) const; |
| 66 | 67 | virtual std::string classname(void) const; |
| 67 | 68 | virtual std::string type(void) const; |
| 68 | - virtual std::string alias(void) const; | |
| 69 | 69 | virtual double eval(const double& theta, |
| 70 | 70 | const double& posangle, |
| 71 | 71 | const GEnergy& energy, |
| ... | ... | @@ -92,6 +92,9 @@ protected: |
| 92 | 92 | void free_members(void); |
| 93 | 93 | void update(void) const; |
| 94 | 94 | |
| 95 | + // Protected members | |
| 96 | + std::string m_type; //!< Model type | |
| 97 | + | |
| 95 | 98 | // Cached members used for pre-computations |
| 96 | 99 | mutable double m_last_minor; //!< Last semi-minor axis |
| 97 | 100 | mutable double m_last_major; //!< Last semi-major axis |
| ... | ... | @@ -126,28 +129,14 @@ std::string GModelSpatialEllipticalGauss::classname(void) const |
| 126 | 129 | /***********************************************************************//** |
| 127 | 130 | * @brief Return model type |
| 128 | 131 | * |
| 129 | - * @return "EllipticalGaussian". | |
| 132 | + * @return Model type. | |
| 130 | 133 | * |
| 131 | 134 | * Returns the type of the elliptical gauss model. |
| 132 | 135 | ***************************************************************************/ |
| 133 | 136 | inline |
| 134 | 137 | std::string GModelSpatialEllipticalGauss::type(void) const |
| 135 | 138 | { |
| 136 | - return "EllipticalGaussian"; | |
| 137 | -} | |
| 138 | - | |
| 139 | - | |
| 140 | -/***********************************************************************//** | |
| 141 | - * @brief Return model type alias | |
| 142 | - * | |
| 143 | - * @return "EllipticalGauss". | |
| 144 | - * | |
| 145 | - * Returns the alias of the elliptical gauss model. | |
| 146 | - ***************************************************************************/ | |
| 147 | -inline | |
| 148 | -std::string GModelSpatialEllipticalGauss::alias(void) const | |
| 149 | -{ | |
| 150 | - return "EllipticalGauss"; | |
| 139 | + return (m_type); | |
| 151 | 140 | } |
| 152 | 141 | |
| 153 | 142 | #endif /* GMODELSPATIALELLIPTICALGAUSS_HPP */ | ... | ... |
include/GModelSpatialPointSource.hpp
| ... | ... | @@ -43,14 +43,13 @@ |
| 43 | 43 | * This class implements a point source as the spatial component of the |
| 44 | 44 | * factorised source model. The point source has two parameters: the Right |
| 45 | 45 | * Ascension and Declination of the point source location. |
| 46 | - * | |
| 47 | - * The model is of type "SkyDirFunction". | |
| 48 | 46 | ***************************************************************************/ |
| 49 | 47 | class GModelSpatialPointSource : public GModelSpatial { |
| 50 | 48 | |
| 51 | 49 | public: |
| 52 | 50 | // Constructors and destructors |
| 53 | 51 | GModelSpatialPointSource(void); |
| 52 | + GModelSpatialPointSource(const bool& dummy, const std::string& type); | |
| 54 | 53 | explicit GModelSpatialPointSource(const GSkyDir& dir); |
| 55 | 54 | GModelSpatialPointSource(const double& ra, const double& dec); |
| 56 | 55 | explicit GModelSpatialPointSource(const GXmlElement& xml); |
| ... | ... | @@ -65,7 +64,6 @@ public: |
| 65 | 64 | virtual GModelSpatialPointSource* clone(void) const; |
| 66 | 65 | virtual std::string classname(void) const; |
| 67 | 66 | virtual std::string type(void) const; |
| 68 | - virtual std::string alias(void) const; | |
| 69 | 67 | virtual GClassCode code(void) const; |
| 70 | 68 | virtual double eval(const GPhoton& photon) const; |
| 71 | 69 | virtual double eval_gradients(const GPhoton& photon) const; |
| ... | ... | @@ -95,8 +93,9 @@ protected: |
| 95 | 93 | void free_members(void); |
| 96 | 94 | |
| 97 | 95 | // Protected members |
| 98 | - GModelPar m_ra; //!< Right Ascension (deg) | |
| 99 | - GModelPar m_dec; //!< Declination (deg) | |
| 96 | + std::string m_type; //!< Model type | |
| 97 | + GModelPar m_ra; //!< Right Ascension (deg) | |
| 98 | + GModelPar m_dec; //!< Declination (deg) | |
| 100 | 99 | }; |
| 101 | 100 | |
| 102 | 101 | |
| ... | ... | @@ -115,28 +114,14 @@ std::string GModelSpatialPointSource::classname(void) const |
| 115 | 114 | /***********************************************************************//** |
| 116 | 115 | * @brief Return model type |
| 117 | 116 | * |
| 118 | - * @return "PointSource". | |
| 117 | + * @return Model type. | |
| 119 | 118 | * |
| 120 | 119 | * Returns the type of the spatial model. |
| 121 | 120 | ***************************************************************************/ |
| 122 | 121 | inline |
| 123 | 122 | std::string GModelSpatialPointSource::type(void) const |
| 124 | 123 | { |
| 125 | - return "PointSource"; | |
| 126 | -} | |
| 127 | - | |
| 128 | - | |
| 129 | -/***********************************************************************//** | |
| 130 | - * @brief Return model type alias | |
| 131 | - * | |
| 132 | - * @return "SkyDirFunction". | |
| 133 | - * | |
| 134 | - * Returns the alias of the spatial model. | |
| 135 | - ***************************************************************************/ | |
| 136 | -inline | |
| 137 | -std::string GModelSpatialPointSource::alias(void) const | |
| 138 | -{ | |
| 139 | - return "SkyDirFunction"; | |
| 124 | + return (m_type); | |
| 140 | 125 | } |
| 141 | 126 | |
| 142 | 127 | ... | ... |
include/GModelSpatialRadial.hpp
| ... | ... | @@ -66,7 +66,6 @@ public: |
| 66 | 66 | virtual GModelSpatialRadial* clone(void) const = 0; |
| 67 | 67 | virtual std::string classname(void) const = 0; |
| 68 | 68 | virtual std::string type(void) const = 0; |
| 69 | - virtual std::string alias(void) const = 0; | |
| 70 | 69 | virtual double eval(const double& theta, |
| 71 | 70 | const GEnergy& energy, |
| 72 | 71 | const GTime& time) const = 0; | ... | ... |
include/GModelSpatialRadialDisk.hpp
| ... | ... | @@ -49,6 +49,7 @@ class GModelSpatialRadialDisk : public GModelSpatialRadial { |
| 49 | 49 | public: |
| 50 | 50 | // Constructors and destructors |
| 51 | 51 | GModelSpatialRadialDisk(void); |
| 52 | + GModelSpatialRadialDisk(const bool& dummy, const std::string& type); | |
| 52 | 53 | GModelSpatialRadialDisk(const GSkyDir& dir, const double& radius); |
| 53 | 54 | explicit GModelSpatialRadialDisk(const GXmlElement& xml); |
| 54 | 55 | GModelSpatialRadialDisk(const GModelSpatialRadialDisk& model); |
| ... | ... | @@ -62,7 +63,6 @@ public: |
| 62 | 63 | virtual GModelSpatialRadialDisk* clone(void) const; |
| 63 | 64 | virtual std::string classname(void) const; |
| 64 | 65 | virtual std::string type(void) const; |
| 65 | - virtual std::string alias(void) const; | |
| 66 | 66 | virtual double eval(const double& theta, |
| 67 | 67 | const GEnergy& energy, |
| 68 | 68 | const GTime& time) const; |
| ... | ... | @@ -91,7 +91,8 @@ protected: |
| 91 | 91 | void update(void) const; |
| 92 | 92 | |
| 93 | 93 | // Protected members |
| 94 | - GModelPar m_radius; //!< Disk radius (degrees) | |
| 94 | + std::string m_type; //!< Model type | |
| 95 | + GModelPar m_radius; //!< Disk radius (degrees) | |
| 95 | 96 | |
| 96 | 97 | // Cached members used for pre-computations |
| 97 | 98 | mutable double m_last_radius; //!< Last disk radius |
| ... | ... | @@ -115,28 +116,14 @@ std::string GModelSpatialRadialDisk::classname(void) const |
| 115 | 116 | /***********************************************************************//** |
| 116 | 117 | * @brief Return model type |
| 117 | 118 | * |
| 118 | - * @return "RadialDisk". | |
| 119 | + * @return Model type. | |
| 119 | 120 | * |
| 120 | 121 | * Returns the type of the radial disk model. |
| 121 | 122 | ***************************************************************************/ |
| 122 | 123 | inline |
| 123 | 124 | std::string GModelSpatialRadialDisk::type(void) const |
| 124 | 125 | { |
| 125 | - return "RadialDisk"; | |
| 126 | -} | |
| 127 | - | |
| 128 | - | |
| 129 | -/***********************************************************************//** | |
| 130 | - * @brief Return model type alias | |
| 131 | - * | |
| 132 | - * @return "DiskFunction". | |
| 133 | - * | |
| 134 | - * Returns the alias of the radial disk model. | |
| 135 | - ***************************************************************************/ | |
| 136 | -inline | |
| 137 | -std::string GModelSpatialRadialDisk::alias(void) const | |
| 138 | -{ | |
| 139 | - return "DiskFunction"; | |
| 126 | + return (m_type); | |
| 140 | 127 | } |
| 141 | 128 | |
| 142 | 129 | ... | ... |
include/GModelSpatialRadialGauss.hpp
| ... | ... | @@ -50,6 +50,7 @@ class GModelSpatialRadialGauss : public GModelSpatialRadial { |
| 50 | 50 | public: |
| 51 | 51 | // Constructors and destructors |
| 52 | 52 | GModelSpatialRadialGauss(void); |
| 53 | + GModelSpatialRadialGauss(const bool& dummy, const std::string& type); | |
| 53 | 54 | GModelSpatialRadialGauss(const GSkyDir& dir, const double& sigma); |
| 54 | 55 | explicit GModelSpatialRadialGauss(const GXmlElement& xml); |
| 55 | 56 | GModelSpatialRadialGauss(const GModelSpatialRadialGauss& model); |
| ... | ... | @@ -63,7 +64,6 @@ public: |
| 63 | 64 | virtual GModelSpatialRadialGauss* clone(void) const; |
| 64 | 65 | virtual std::string classname(void) const; |
| 65 | 66 | virtual std::string type(void) const; |
| 66 | - virtual std::string alias(void) const; | |
| 67 | 67 | virtual double eval(const double& theta, |
| 68 | 68 | const GEnergy& energy, |
| 69 | 69 | const GTime& time) const; |
| ... | ... | @@ -91,7 +91,8 @@ protected: |
| 91 | 91 | void free_members(void); |
| 92 | 92 | |
| 93 | 93 | // Protected members |
| 94 | - GModelPar m_sigma; //!< Gaussian width (deg) | |
| 94 | + std::string m_type; //!< Model type | |
| 95 | + GModelPar m_sigma; //!< Gaussian width (deg) | |
| 95 | 96 | }; |
| 96 | 97 | |
| 97 | 98 | |
| ... | ... | @@ -110,28 +111,14 @@ std::string GModelSpatialRadialGauss::classname(void) const |
| 110 | 111 | /***********************************************************************//** |
| 111 | 112 | * @brief Return model type |
| 112 | 113 | * |
| 113 | - * @return "RadialGaussian". | |
| 114 | + * @return Model type. | |
| 114 | 115 | * |
| 115 | 116 | * Returns the type of the radial Gauss model. |
| 116 | 117 | ***************************************************************************/ |
| 117 | 118 | inline |
| 118 | 119 | std::string GModelSpatialRadialGauss::type(void) const |
| 119 | 120 | { |
| 120 | - return "RadialGaussian"; | |
| 121 | -} | |
| 122 | - | |
| 123 | - | |
| 124 | -/***********************************************************************//** | |
| 125 | - * @brief Return model type alias | |
| 126 | - * | |
| 127 | - * @return "GaussFunction". | |
| 128 | - * | |
| 129 | - * Returns the alias of the radial Gauss model. | |
| 130 | - ***************************************************************************/ | |
| 131 | -inline | |
| 132 | -std::string GModelSpatialRadialGauss::alias(void) const | |
| 133 | -{ | |
| 134 | - return "GaussFunction"; | |
| 121 | + return (m_type); | |
| 135 | 122 | } |
| 136 | 123 | |
| 137 | 124 | ... | ... |
include/GModelSpatialRadialShell.hpp
| ... | ... | @@ -59,6 +59,7 @@ class GModelSpatialRadialShell : public GModelSpatialRadial { |
| 59 | 59 | public: |
| 60 | 60 | // Constructors and destructors |
| 61 | 61 | GModelSpatialRadialShell(void); |
| 62 | + GModelSpatialRadialShell(const bool& dummy, const std::string& type); | |
| 62 | 63 | GModelSpatialRadialShell(const GSkyDir& dir, |
| 63 | 64 | const double& radius, |
| 64 | 65 | const double& width); |
| ... | ... | @@ -74,7 +75,6 @@ public: |
| 74 | 75 | virtual GModelSpatialRadialShell* clone(void) const; |
| 75 | 76 | virtual std::string classname(void) const; |
| 76 | 77 | virtual std::string type(void) const; |
| 77 | - virtual std::string alias(void) const; | |
| 78 | 78 | virtual double eval(const double& theta, |
| 79 | 79 | const GEnergy& energy, |
| 80 | 80 | const GTime& time) const; |
| ... | ... | @@ -107,6 +107,7 @@ protected: |
| 107 | 107 | static double f2(double x); |
| 108 | 108 | |
| 109 | 109 | // Protected members |
| 110 | + std::string m_type; //!< Model type | |
| 110 | 111 | GModelPar m_radius; //!< Inner shell radius (deg) |
| 111 | 112 | GModelPar m_width; //!< Shell thickness (deg) |
| 112 | 113 | |
| ... | ... | @@ -136,28 +137,14 @@ std::string GModelSpatialRadialShell::classname(void) const |
| 136 | 137 | /***********************************************************************//** |
| 137 | 138 | * @brief Return model type |
| 138 | 139 | * |
| 139 | - * @return "RadialShell". | |
| 140 | + * @return Model type. | |
| 140 | 141 | * |
| 141 | 142 | * Returns the type of the radial shell model. |
| 142 | 143 | ***************************************************************************/ |
| 143 | 144 | inline |
| 144 | 145 | std::string GModelSpatialRadialShell::type(void) const |
| 145 | 146 | { |
| 146 | - return "RadialShell"; | |
| 147 | -} | |
| 148 | - | |
| 149 | - | |
| 150 | -/***********************************************************************//** | |
| 151 | - * @brief Return model type alias | |
| 152 | - * | |
| 153 | - * @return "ShellFunction". | |
| 154 | - * | |
| 155 | - * Returns the alias of the radial shell model. | |
| 156 | - ***************************************************************************/ | |
| 157 | -inline | |
| 158 | -std::string GModelSpatialRadialShell::alias(void) const | |
| 159 | -{ | |
| 160 | - return "ShellFunction"; | |
| 147 | + return (m_type); | |
| 161 | 148 | } |
| 162 | 149 | |
| 163 | 150 | ... | ... |
src/model/GModelSpatialDiffuseConst.cpp
| ... | ... | @@ -39,6 +39,10 @@ |
| 39 | 39 | /* __ Globals ____________________________________________________________ */ |
| 40 | 40 | const GModelSpatialDiffuseConst g_spatial_const_seed; |
| 41 | 41 | const GModelSpatialRegistry g_spatial_const_registry(&g_spatial_const_seed); |
| 42 | +#if defined(G_LEGACY_XML_FORMAT) | |
| 43 | +const GModelSpatialDiffuseConst g_spatial_const_legacy_seed(true, "ConstantValue"); | |
| 44 | +const GModelSpatialRegistry g_spatial_const_legacy_registry(&g_spatial_const_legacy_seed); | |
| 45 | +#endif | |
| 42 | 46 | |
| 43 | 47 | /* __ Method name definitions ____________________________________________ */ |
| 44 | 48 | #define G_MC_NORM "GModelSpatialDiffuseConst::mc_norm(GSkyDir&, double&)" |
| ... | ... | @@ -61,7 +65,7 @@ const GModelSpatialRegistry g_spatial_const_registry(&g_spatial_const_seed); |
| 61 | 65 | /***********************************************************************//** |
| 62 | 66 | * @brief Void constructor |
| 63 | 67 | * |
| 64 | - * Construct empty isotropic spatial model. | |
| 68 | + * Constructs empty isotropic spatial model. | |
| 65 | 69 | ***************************************************************************/ |
| 66 | 70 | GModelSpatialDiffuseConst::GModelSpatialDiffuseConst(void) : |
| 67 | 71 | GModelSpatialDiffuse() |
| ... | ... | @@ -75,6 +79,29 @@ GModelSpatialDiffuseConst::GModelSpatialDiffuseConst(void) : |
| 75 | 79 | |
| 76 | 80 | |
| 77 | 81 | /***********************************************************************//** |
| 82 | + * @brief Model type constructor | |
| 83 | + * | |
| 84 | + * @param[in] dummy Dummy flag. | |
| 85 | + * @param[in] type Model type. | |
| 86 | + * | |
| 87 | + * Constructs empty isotropic spatial model by specifying a model @p type. | |
| 88 | + ***************************************************************************/ | |
| 89 | +GModelSpatialDiffuseConst::GModelSpatialDiffuseConst(const bool& dummy, | |
| 90 | + const std::string& type) : | |
| 91 | + GModelSpatialDiffuse() | |
| 92 | +{ | |
| 93 | + // Initialise members | |
| 94 | + init_members(); | |
| 95 | + | |
| 96 | + // Set model type | |
| 97 | + m_type = type; | |
| 98 | + | |
| 99 | + // Return | |
| 100 | + return; | |
| 101 | +} | |
| 102 | + | |
| 103 | + | |
| 104 | +/***********************************************************************//** | |
| 78 | 105 | * @brief XML constructor |
| 79 | 106 | * |
| 80 | 107 | * @param[in] xml XML element. |
| ... | ... | @@ -513,6 +540,9 @@ std::string GModelSpatialDiffuseConst::print(const GChatter& chatter) const |
| 513 | 540 | ***************************************************************************/ |
| 514 | 541 | void GModelSpatialDiffuseConst::init_members(void) |
| 515 | 542 | { |
| 543 | + // Initialise model type | |
| 544 | + m_type = "DiffuseIsotropic"; | |
| 545 | + | |
| 516 | 546 | // Initialise Value |
| 517 | 547 | m_value.clear(); |
| 518 | 548 | m_value.name("Value"); |
| ... | ... | @@ -544,6 +574,7 @@ void GModelSpatialDiffuseConst::init_members(void) |
| 544 | 574 | void GModelSpatialDiffuseConst::copy_members(const GModelSpatialDiffuseConst& model) |
| 545 | 575 | { |
| 546 | 576 | // Copy members |
| 577 | + m_type = model.m_type; | |
| 547 | 578 | m_value = model.m_value; |
| 548 | 579 | m_mc_centre = model.m_mc_centre; |
| 549 | 580 | m_mc_cos_radius = model.m_mc_cos_radius; | ... | ... |
src/model/GModelSpatialDiffuseCube.cpp
| ... | ... | @@ -45,6 +45,10 @@ |
| 45 | 45 | /* __ Globals ____________________________________________________________ */ |
| 46 | 46 | const GModelSpatialDiffuseCube g_spatial_cube_seed; |
| 47 | 47 | const GModelSpatialRegistry g_spatial_cube_registry(&g_spatial_cube_seed); |
| 48 | +#if defined(G_LEGACY_XML_FORMAT) | |
| 49 | +const GModelSpatialDiffuseCube g_spatial_cube_legacy_seed(true, "MapCubeFunction"); | |
| 50 | +const GModelSpatialRegistry g_spatial_cube_legacy_registry(&g_spatial_cube_legacy_seed); | |
| 51 | +#endif | |
| 48 | 52 | |
| 49 | 53 | /* __ Method name definitions ____________________________________________ */ |
| 50 | 54 | #define G_MC "GModelSpatialDiffuseCube::mc(GEnergy&, GTime&, GRan&)" |
| ... | ... | @@ -85,6 +89,29 @@ GModelSpatialDiffuseCube::GModelSpatialDiffuseCube(void) : |
| 85 | 89 | |
| 86 | 90 | |
| 87 | 91 | /***********************************************************************//** |
| 92 | + * @brief Model type constructor | |
| 93 | + * | |
| 94 | + * @param[in] dummy Dummy flag. | |
| 95 | + * @param[in] type Model type. | |
| 96 | + * | |
| 97 | + * Constructs empty map cube model by specifying a model @p type. | |
| 98 | + ***************************************************************************/ | |
| 99 | +GModelSpatialDiffuseCube::GModelSpatialDiffuseCube(const bool& dummy, | |
| 100 | + const std::string& type) : | |
| 101 | + GModelSpatialDiffuse() | |
| 102 | +{ | |
| 103 | + // Initialise members | |
| 104 | + init_members(); | |
| 105 | + | |
| 106 | + // Set model type | |
| 107 | + m_type = type; | |
| 108 | + | |
| 109 | + // Return | |
| 110 | + return; | |
| 111 | +} | |
| 112 | + | |
| 113 | + | |
| 114 | +/***********************************************************************//** | |
| 88 | 115 | * @brief XML constructor |
| 89 | 116 | * |
| 90 | 117 | * @param[in] xml XML element. |
| ... | ... | @@ -1017,6 +1044,9 @@ std::string GModelSpatialDiffuseCube::print(const GChatter& chatter) const |
| 1017 | 1044 | ***************************************************************************/ |
| 1018 | 1045 | void GModelSpatialDiffuseCube::init_members(void) |
| 1019 | 1046 | { |
| 1047 | + // Initialise model type | |
| 1048 | + m_type = "DiffuseMapCube"; | |
| 1049 | + | |
| 1020 | 1050 | // Initialise Value |
| 1021 | 1051 | m_value.clear(); |
| 1022 | 1052 | m_value.name("Normalization"); |
| ... | ... | @@ -1058,6 +1088,7 @@ void GModelSpatialDiffuseCube::init_members(void) |
| 1058 | 1088 | void GModelSpatialDiffuseCube::copy_members(const GModelSpatialDiffuseCube& model) |
| 1059 | 1089 | { |
| 1060 | 1090 | // Copy members |
| 1091 | + m_type = model.m_type; | |
| 1061 | 1092 | m_value = model.m_value; |
| 1062 | 1093 | m_filename = model.m_filename; |
| 1063 | 1094 | m_cube = model.m_cube; | ... | ... |
src/model/GModelSpatialDiffuseMap.cpp
| ... | ... | @@ -40,6 +40,10 @@ |
| 40 | 40 | /* __ Globals ____________________________________________________________ */ |
| 41 | 41 | const GModelSpatialDiffuseMap g_spatial_map_seed; |
| 42 | 42 | const GModelSpatialRegistry g_spatial_map_registry(&g_spatial_map_seed); |
| 43 | +#if defined(G_LEGACY_XML_FORMAT) | |
| 44 | +const GModelSpatialDiffuseMap g_spatial_map_legacy_seed(true, "SpatialMap"); | |
| 45 | +const GModelSpatialRegistry g_spatial_map_legacy_registry(&g_spatial_map_legacy_seed); | |
| 46 | +#endif | |
| 43 | 47 | |
| 44 | 48 | /* __ Method name definitions ____________________________________________ */ |
| 45 | 49 | #define G_MC "GModelSpatialDiffuseMap::mc(GEnergy&, GTime&, GRan&)" |
| ... | ... | @@ -78,6 +82,29 @@ GModelSpatialDiffuseMap::GModelSpatialDiffuseMap(void) : |
| 78 | 82 | |
| 79 | 83 | |
| 80 | 84 | /***********************************************************************//** |
| 85 | + * @brief Model type constructor | |
| 86 | + * | |
| 87 | + * @param[in] dummy Dummy flag. | |
| 88 | + * @param[in] type Model type. | |
| 89 | + * | |
| 90 | + * Constructs empty spatial map model by specifying a model @p type. | |
| 91 | + ***************************************************************************/ | |
| 92 | +GModelSpatialDiffuseMap::GModelSpatialDiffuseMap(const bool& dummy, | |
| 93 | + const std::string& type) : | |
| 94 | + GModelSpatialDiffuse() | |
| 95 | +{ | |
| 96 | + // Initialise members | |
| 97 | + init_members(); | |
| 98 | + | |
| 99 | + // Set model type | |
| 100 | + m_type = type; | |
| 101 | + | |
| 102 | + // Return | |
| 103 | + return; | |
| 104 | +} | |
| 105 | + | |
| 106 | + | |
| 107 | +/***********************************************************************//** | |
| 81 | 108 | * @brief XML constructor |
| 82 | 109 | * |
| 83 | 110 | * @param[in] xml XML element. |
| ... | ... | @@ -814,6 +841,9 @@ void GModelSpatialDiffuseMap::load(const GFilename& filename) |
| 814 | 841 | ***************************************************************************/ |
| 815 | 842 | void GModelSpatialDiffuseMap::init_members(void) |
| 816 | 843 | { |
| 844 | + // Initialise model type | |
| 845 | + m_type = "DiffuseMap"; | |
| 846 | + | |
| 817 | 847 | // Initialise Value |
| 818 | 848 | m_value.clear(); |
| 819 | 849 | m_value.name("Prefactor"); |
| ... | ... | @@ -856,6 +886,7 @@ void GModelSpatialDiffuseMap::init_members(void) |
| 856 | 886 | void GModelSpatialDiffuseMap::copy_members(const GModelSpatialDiffuseMap& model) |
| 857 | 887 | { |
| 858 | 888 | // Copy members |
| 889 | + m_type = model.m_type; | |
| 859 | 890 | m_value = model.m_value; |
| 860 | 891 | m_map = model.m_map; |
| 861 | 892 | m_filename = model.m_filename; | ... | ... |
src/model/GModelSpatialEllipticalGauss.cpp
| ... | ... | @@ -44,7 +44,11 @@ namespace { |
| 44 | 44 | |
| 45 | 45 | /* __ Globals ____________________________________________________________ */ |
| 46 | 46 | const GModelSpatialEllipticalGauss g_elliptical_gauss_seed; |
| 47 | -const GModelSpatialRegistry g_elliptical_gauss_registry(&g_elliptical_gauss_seed); | |
| 47 | +const GModelSpatialRegistry g_elliptical_gauss_registry(&g_elliptical_gauss_seed); | |
| 48 | +#if defined(G_LEGACY_XML_FORMAT) | |
| 49 | +const GModelSpatialEllipticalGauss g_elliptical_gauss_legacy_seed(true, "EllipticalGauss"); | |
| 50 | +const GModelSpatialRegistry g_elliptical_gauss_legacy_registry(&g_elliptical_gauss_legacy_seed); | |
| 51 | +#endif | |
| 48 | 52 | |
| 49 | 53 | /* __ Method name definitions ____________________________________________ */ |
| 50 | 54 | #define G_READ "GModelSpatialEllipticalGauss::read(GXmlElement&)" |
| ... | ... | @@ -79,6 +83,29 @@ GModelSpatialEllipticalGauss::GModelSpatialEllipticalGauss(void) : |
| 79 | 83 | |
| 80 | 84 | |
| 81 | 85 | /***********************************************************************//** |
| 86 | + * @brief Model type constructor | |
| 87 | + * | |
| 88 | + * @param[in] dummy Dummy flag. | |
| 89 | + * @param[in] type Model type. | |
| 90 | + * | |
| 91 | + * Constructs empty elliptical Gaussian model by specifying a model @p type. | |
| 92 | + ***************************************************************************/ | |
| 93 | +GModelSpatialEllipticalGauss::GModelSpatialEllipticalGauss(const bool& dummy, | |
| 94 | + const std::string& type) : | |
| 95 | + GModelSpatialElliptical() | |
| 96 | +{ | |
| 97 | + // Initialise members | |
| 98 | + init_members(); | |
| 99 | + | |
| 100 | + // Set model type | |
| 101 | + m_type = type; | |
| 102 | + | |
| 103 | + // Return | |
| 104 | + return; | |
| 105 | +} | |
| 106 | + | |
| 107 | + | |
| 108 | +/***********************************************************************//** | |
| 82 | 109 | * @brief Elliptical Gaussian constructor |
| 83 | 110 | * |
| 84 | 111 | * @param[in] dir Centre of elliptical Gaussian. |
| ... | ... | @@ -700,6 +727,9 @@ std::string GModelSpatialEllipticalGauss::print(const GChatter& chatter) const |
| 700 | 727 | ***************************************************************************/ |
| 701 | 728 | void GModelSpatialEllipticalGauss::init_members(void) |
| 702 | 729 | { |
| 730 | + // Initialise model type | |
| 731 | + m_type = "EllipticalGaussian"; | |
| 732 | + | |
| 703 | 733 | // Initialise precomputation cache. Note that zero values flag |
| 704 | 734 | // uninitialised as a zero radius is not meaningful |
| 705 | 735 | m_last_minor = 0.0; |
| ... | ... | @@ -729,6 +759,9 @@ void GModelSpatialEllipticalGauss::init_members(void) |
| 729 | 759 | ***************************************************************************/ |
| 730 | 760 | void GModelSpatialEllipticalGauss::copy_members(const GModelSpatialEllipticalGauss& model) |
| 731 | 761 | { |
| 762 | + // Copy members | |
| 763 | + m_type = model.m_type; | |
| 764 | + | |
| 732 | 765 | // Copy precomputation cache |
| 733 | 766 | m_last_minor = model.m_last_minor; |
| 734 | 767 | m_last_major = model.m_last_major; | ... | ... |
src/model/GModelSpatialPointSource.cpp
| ... | ... | @@ -37,9 +37,14 @@ |
| 37 | 37 | /* __ Constants __________________________________________________________ */ |
| 38 | 38 | const double tolerance = 0.000027777778; // angular tolerance is 1 arcsec |
| 39 | 39 | |
| 40 | + | |
| 40 | 41 | /* __ Globals ____________________________________________________________ */ |
| 41 | 42 | const GModelSpatialPointSource g_spatial_ptsrc_seed; |
| 42 | 43 | const GModelSpatialRegistry g_spatial_ptsrc_registry(&g_spatial_ptsrc_seed); |
| 44 | +#if defined(G_LEGACY_XML_FORMAT) | |
| 45 | +const GModelSpatialPointSource g_spatial_ptsrc_legacy_seed(true, "SkyDirFunction"); | |
| 46 | +const GModelSpatialRegistry g_spatial_ptsrc_legacy_registry(&g_spatial_ptsrc_legacy_seed); | |
| 47 | +#endif | |
| 43 | 48 | |
| 44 | 49 | /* __ Method name definitions ____________________________________________ */ |
| 45 | 50 | #define G_READ "GModelSpatialPointSource::read(GXmlElement&)" |
| ... | ... | @@ -60,6 +65,8 @@ const GModelSpatialRegistry g_spatial_ptsrc_registry(&g_spatial_ptsrc_seed); |
| 60 | 65 | |
| 61 | 66 | /***********************************************************************//** |
| 62 | 67 | * @brief Void constructor |
| 68 | + * | |
| 69 | + * Constructs empty point source model. | |
| 63 | 70 | ***************************************************************************/ |
| 64 | 71 | GModelSpatialPointSource::GModelSpatialPointSource(void) : GModelSpatial() |
| 65 | 72 | { |
| ... | ... | @@ -72,6 +79,29 @@ GModelSpatialPointSource::GModelSpatialPointSource(void) : GModelSpatial() |
| 72 | 79 | |
| 73 | 80 | |
| 74 | 81 | /***********************************************************************//** |
| 82 | + * @brief Model type constructor | |
| 83 | + * | |
| 84 | + * @param[in] dummy Dummy flag. | |
| 85 | + * @param[in] type Model type. | |
| 86 | + * | |
| 87 | + * Constructs empty point source model by specifying a model @p type. | |
| 88 | + ***************************************************************************/ | |
| 89 | +GModelSpatialPointSource::GModelSpatialPointSource(const bool& dummy, | |
| 90 | + const std::string& type) : | |
| 91 | + GModelSpatial() | |
| 92 | +{ | |
| 93 | + // Initialise members | |
| 94 | + init_members(); | |
| 95 | + | |
| 96 | + // Set model type | |
| 97 | + m_type = type; | |
| 98 | + | |
| 99 | + // Return | |
| 100 | + return; | |
| 101 | +} | |
| 102 | + | |
| 103 | + | |
| 104 | +/***********************************************************************//** | |
| 75 | 105 | * @brief Sky direction constructor |
| 76 | 106 | * |
| 77 | 107 | * @param[in] dir Sky direction. |
| ... | ... | @@ -560,6 +590,9 @@ void GModelSpatialPointSource::dir(const GSkyDir& dir) |
| 560 | 590 | ***************************************************************************/ |
| 561 | 591 | void GModelSpatialPointSource::init_members(void) |
| 562 | 592 | { |
| 593 | + // Initialise model type | |
| 594 | + m_type = "PointSource"; | |
| 595 | + | |
| 563 | 596 | // Initialise Right Ascension |
| 564 | 597 | m_ra.clear(); |
| 565 | 598 | m_ra.name("RA"); |
| ... | ... | @@ -596,8 +629,9 @@ void GModelSpatialPointSource::init_members(void) |
| 596 | 629 | void GModelSpatialPointSource::copy_members(const GModelSpatialPointSource& model) |
| 597 | 630 | { |
| 598 | 631 | // Copy members |
| 599 | - m_ra = model.m_ra; | |
| 600 | - m_dec = model.m_dec; | |
| 632 | + m_type = model.m_type; | |
| 633 | + m_ra = model.m_ra; | |
| 634 | + m_dec = model.m_dec; | |
| 601 | 635 | |
| 602 | 636 | // Set parameter pointer(s) |
| 603 | 637 | m_pars.clear(); | ... | ... |
src/model/GModelSpatialRadialDisk.cpp
| ... | ... | @@ -39,6 +39,10 @@ |
| 39 | 39 | /* __ Globals ____________________________________________________________ */ |
| 40 | 40 | const GModelSpatialRadialDisk g_radial_disk_seed; |
| 41 | 41 | const GModelSpatialRegistry g_radial_disk_registry(&g_radial_disk_seed); |
| 42 | +#if defined(G_LEGACY_XML_FORMAT) | |
| 43 | +const GModelSpatialRadialDisk g_radial_disk_legacy_seed(true, "DiskFunction"); | |
| 44 | +const GModelSpatialRegistry g_radial_disk_legacy_registry(&g_radial_disk_legacy_seed); | |
| 45 | +#endif | |
| 42 | 46 | |
| 43 | 47 | /* __ Method name definitions ____________________________________________ */ |
| 44 | 48 | #define G_READ "GModelSpatialRadialDisk::read(GXmlElement&)" |
| ... | ... | @@ -59,6 +63,8 @@ const GModelSpatialRegistry g_radial_disk_registry(&g_radial_disk_seed); |
| 59 | 63 | |
| 60 | 64 | /***********************************************************************//** |
| 61 | 65 | * @brief Void constructor |
| 66 | + * | |
| 67 | + * Constructs empty radial disk model. | |
| 62 | 68 | ***************************************************************************/ |
| 63 | 69 | GModelSpatialRadialDisk::GModelSpatialRadialDisk(void) : GModelSpatialRadial() |
| 64 | 70 | { |
| ... | ... | @@ -71,6 +77,29 @@ GModelSpatialRadialDisk::GModelSpatialRadialDisk(void) : GModelSpatialRadial() |
| 71 | 77 | |
| 72 | 78 | |
| 73 | 79 | /***********************************************************************//** |
| 80 | + * @brief Model type constructor | |
| 81 | + * | |
| 82 | + * @param[in] dummy Dummy flag. | |
| 83 | + * @param[in] type Model type. | |
| 84 | + * | |
| 85 | + * Constructs empty radial disk model by specifying a model @p type. | |
| 86 | + ***************************************************************************/ | |
| 87 | +GModelSpatialRadialDisk::GModelSpatialRadialDisk(const bool& dummy, | |
| 88 | + const std::string& type) : | |
| 89 | + GModelSpatialRadial() | |
| 90 | +{ | |
| 91 | + // Initialise members | |
| 92 | + init_members(); | |
| 93 | + | |
| 94 | + // Set model type | |
| 95 | + m_type = type; | |
| 96 | + | |
| 97 | + // Return | |
| 98 | + return; | |
| 99 | +} | |
| 100 | + | |
| 101 | + | |
| 102 | +/***********************************************************************//** | |
| 74 | 103 | * @brief Disk constructor |
| 75 | 104 | * |
| 76 | 105 | * @param[in] dir Sky position of disk centre. |
| ... | ... | @@ -549,6 +578,9 @@ std::string GModelSpatialRadialDisk::print(const GChatter& chatter) const |
| 549 | 578 | ***************************************************************************/ |
| 550 | 579 | void GModelSpatialRadialDisk::init_members(void) |
| 551 | 580 | { |
| 581 | + // Initialise model type | |
| 582 | + m_type = "RadialDisk"; | |
| 583 | + | |
| 552 | 584 | // Initialise Radius |
| 553 | 585 | m_radius.clear(); |
| 554 | 586 | m_radius.name("Radius"); |
| ... | ... | @@ -586,6 +618,7 @@ void GModelSpatialRadialDisk::init_members(void) |
| 586 | 618 | void GModelSpatialRadialDisk::copy_members(const GModelSpatialRadialDisk& model) |
| 587 | 619 | { |
| 588 | 620 | // Copy members |
| 621 | + m_type = model.m_type; | |
| 589 | 622 | m_radius = model.m_radius; |
| 590 | 623 | |
| 591 | 624 | // Copy precomputation cache | ... | ... |
src/model/GModelSpatialRadialGauss.cpp
| ... | ... | @@ -39,6 +39,10 @@ |
| 39 | 39 | /* __ Globals ____________________________________________________________ */ |
| 40 | 40 | const GModelSpatialRadialGauss g_radial_gauss_seed; |
| 41 | 41 | const GModelSpatialRegistry g_radial_gauss_registry(&g_radial_gauss_seed); |
| 42 | +#if defined(G_LEGACY_XML_FORMAT) | |
| 43 | +const GModelSpatialRadialGauss g_radial_gauss_legacy_seed(true, "GaussFunction"); | |
| 44 | +const GModelSpatialRegistry g_radial_gauss_legacy_registry(&g_radial_gauss_legacy_seed); | |
| 45 | +#endif | |
| 42 | 46 | |
| 43 | 47 | /* __ Method name definitions ____________________________________________ */ |
| 44 | 48 | #define G_READ "GModelSpatialRadialGauss::read(GXmlElement&)" |
| ... | ... | @@ -59,6 +63,8 @@ const GModelSpatialRegistry g_radial_gauss_registry(&g_radial_gauss_seed); |
| 59 | 63 | |
| 60 | 64 | /***********************************************************************//** |
| 61 | 65 | * @brief Void constructor |
| 66 | + * | |
| 67 | + * Constructs empty radial Gaussian model. | |
| 62 | 68 | ***************************************************************************/ |
| 63 | 69 | GModelSpatialRadialGauss::GModelSpatialRadialGauss(void) : GModelSpatialRadial() |
| 64 | 70 | { |
| ... | ... | @@ -71,6 +77,29 @@ GModelSpatialRadialGauss::GModelSpatialRadialGauss(void) : GModelSpatialRadial() |
| 71 | 77 | |
| 72 | 78 | |
| 73 | 79 | /***********************************************************************//** |
| 80 | + * @brief Model type constructor | |
| 81 | + * | |
| 82 | + * @param[in] dummy Dummy flag. | |
| 83 | + * @param[in] type Model type. | |
| 84 | + * | |
| 85 | + * Constructs empty radial Gaussian model by specifying a model @p type. | |
| 86 | + ***************************************************************************/ | |
| 87 | +GModelSpatialRadialGauss::GModelSpatialRadialGauss(const bool& dummy, | |
| 88 | + const std::string& type) : | |
| 89 | + GModelSpatialRadial() | |
| 90 | +{ | |
| 91 | + // Initialise members | |
| 92 | + init_members(); | |
| 93 | + | |
| 94 | + // Set model type | |
| 95 | + m_type = type; | |
| 96 | + | |
| 97 | + // Return | |
| 98 | + return; | |
| 99 | +} | |
| 100 | + | |
| 101 | + | |
| 102 | +/***********************************************************************//** | |
| 74 | 103 | * @brief Constructor |
| 75 | 104 | * |
| 76 | 105 | * @param[in] dir Sky position of Gaussian. |
| ... | ... | @@ -548,6 +577,8 @@ std::string GModelSpatialRadialGauss::print(const GChatter& chatter) const |
| 548 | 577 | ***************************************************************************/ |
| 549 | 578 | void GModelSpatialRadialGauss::init_members(void) |
| 550 | 579 | { |
| 580 | + // Initialise model type | |
| 581 | + m_type = "RadialGaussian"; | |
| 551 | 582 | |
| 552 | 583 | // Initialise Gaussian sigma |
| 553 | 584 | m_sigma.clear(); |
| ... | ... | @@ -580,6 +611,7 @@ void GModelSpatialRadialGauss::init_members(void) |
| 580 | 611 | void GModelSpatialRadialGauss::copy_members(const GModelSpatialRadialGauss& model) |
| 581 | 612 | { |
| 582 | 613 | // Copy members |
| 614 | + m_type = model.m_type; | |
| 583 | 615 | m_sigma = model.m_sigma; |
| 584 | 616 | |
| 585 | 617 | // Return | ... | ... |
src/model/GModelSpatialRadialShell.cpp
| ... | ... | @@ -39,6 +39,10 @@ |
| 39 | 39 | /* __ Globals ____________________________________________________________ */ |
| 40 | 40 | const GModelSpatialRadialShell g_radial_shell_seed; |
| 41 | 41 | const GModelSpatialRegistry g_radial_shell_registry(&g_radial_shell_seed); |
| 42 | +#if defined(G_LEGACY_XML_FORMAT) | |
| 43 | +const GModelSpatialRadialShell g_radial_shell_legacy_seed(true, "ShellFunction"); | |
| 44 | +const GModelSpatialRegistry g_radial_shell_legacy_registry(&g_radial_shell_legacy_seed); | |
| 45 | +#endif | |
| 42 | 46 | |
| 43 | 47 | /* __ Method name definitions ____________________________________________ */ |
| 44 | 48 | #define G_READ "GModelSpatialRadialShell::read(GXmlElement&)" |
| ... | ... | @@ -60,6 +64,8 @@ const GModelSpatialRegistry g_radial_shell_registry(&g_radial_shell_seed); |
| 60 | 64 | |
| 61 | 65 | /***********************************************************************//** |
| 62 | 66 | * @brief Void constructor |
| 67 | + * | |
| 68 | + * Constructs empty radial shell model. | |
| 63 | 69 | ***************************************************************************/ |
| 64 | 70 | GModelSpatialRadialShell::GModelSpatialRadialShell(void) : GModelSpatialRadial() |
| 65 | 71 | { |
| ... | ... | @@ -72,6 +78,29 @@ GModelSpatialRadialShell::GModelSpatialRadialShell(void) : GModelSpatialRadial() |
| 72 | 78 | |
| 73 | 79 | |
| 74 | 80 | /***********************************************************************//** |
| 81 | + * @brief Model type constructor | |
| 82 | + * | |
| 83 | + * @param[in] dummy Dummy flag. | |
| 84 | + * @param[in] type Model type. | |
| 85 | + * | |
| 86 | + * Constructs empty radial shell model by specifying a model @p type. | |
| 87 | + ***************************************************************************/ | |
| 88 | +GModelSpatialRadialShell::GModelSpatialRadialShell(const bool& dummy, | |
| 89 | + const std::string& type) : | |
| 90 | + GModelSpatialRadial() | |
| 91 | +{ | |
| 92 | + // Initialise members | |
| 93 | + init_members(); | |
| 94 | + | |
| 95 | + // Set model type | |
| 96 | + m_type = type; | |
| 97 | + | |
| 98 | + // Return | |
| 99 | + return; | |
| 100 | +} | |
| 101 | + | |
| 102 | + | |
| 103 | +/***********************************************************************//** | |
| 75 | 104 | * @brief Shell constructor |
| 76 | 105 | * |
| 77 | 106 | * @param[in] dir Sky position of shell centre. |
| ... | ... | @@ -616,6 +645,9 @@ std::string GModelSpatialRadialShell::print(const GChatter& chatter) const |
| 616 | 645 | ***************************************************************************/ |
| 617 | 646 | void GModelSpatialRadialShell::init_members(void) |
| 618 | 647 | { |
| 648 | + // Initialise model type | |
| 649 | + m_type = "RadialShell"; | |
| 650 | + | |
| 619 | 651 | // Initialise Radius |
| 620 | 652 | m_radius.clear(); |
| 621 | 653 | m_radius.name("Radius"); |
| ... | ... | @@ -669,6 +701,7 @@ void GModelSpatialRadialShell::init_members(void) |
| 669 | 701 | void GModelSpatialRadialShell::copy_members(const GModelSpatialRadialShell& model) |
| 670 | 702 | { |
| 671 | 703 | // Copy members |
| 704 | + m_type = model.m_type; | |
| 672 | 705 | m_radius = model.m_radius; |
| 673 | 706 | m_width = model.m_width; |
| 674 | 707 | ... | ... |
src/model/GModelSpatialRegistry.cpp
| ... | ... | @@ -91,13 +91,8 @@ GModelSpatialRegistry::GModelSpatialRegistry(const GModelSpatial* model) |
| 91 | 91 | #endif |
| 92 | 92 | |
| 93 | 93 | // Allocate new registry |
| 94 | - #if defined(G_LEGACY_MODEL_NAMES) | |
| 95 | - std::string* new_names = new std::string[size()+2]; | |
| 96 | - const GModelSpatial** new_models = new const GModelSpatial*[size()+2]; | |
| 97 | - #else | |
| 98 | 94 | std::string* new_names = new std::string[size()+1]; |
| 99 | 95 | const GModelSpatial** new_models = new const GModelSpatial*[size()+1]; |
| 100 | - #endif | |
| 101 | 96 | |
| 102 | 97 | // Save old registry |
| 103 | 98 | for (int i = 0; i < size(); ++i) { |
| ... | ... | @@ -109,20 +104,11 @@ GModelSpatialRegistry::GModelSpatialRegistry(const GModelSpatial* model) |
| 109 | 104 | new_names[size()] = model->type(); |
| 110 | 105 | new_models[size()] = model; |
| 111 | 106 | |
| 112 | - // Add new model with alias to registry for legacy naming convention | |
| 113 | - #if defined(G_LEGACY_MODEL_NAMES) | |
| 114 | - new_names[size()+1] = model->alias(); | |
| 115 | - new_models[size()+1] = model; | |
| 116 | - #endif | |
| 117 | - | |
| 118 | 107 | // Set pointers on new registry |
| 119 | 108 | names().assign(new_names); |
| 120 | 109 | models().assign(new_models); |
| 121 | 110 | |
| 122 | 111 | // Increment number of models in registry |
| 123 | - #if defined(G_LEGACY_MODEL_NAMES) | |
| 124 | - number()++; | |
| 125 | - #endif | |
| 126 | 112 | number()++; |
| 127 | 113 | |
| 128 | 114 | // Debug option: Show actual registry |
| ... | ... | @@ -182,7 +168,7 @@ GModelSpatialRegistry::~GModelSpatialRegistry(void) |
| 182 | 168 | * @param[in] registry Registry. |
| 183 | 169 | * @return Reference to registry. |
| 184 | 170 | ***************************************************************************/ |
| 185 | -GModelSpatialRegistry& GModelSpatialRegistry::operator= (const GModelSpatialRegistry& registry) | |
| 171 | +GModelSpatialRegistry& GModelSpatialRegistry::operator=(const GModelSpatialRegistry& registry) | |
| 186 | 172 | { |
| 187 | 173 | // Execute only if object is not identical |
| 188 | 174 | if (this != ®istry) { | ... | ... |
test/test_GModel.cpp
| ... | ... | @@ -2642,17 +2642,9 @@ void TestGModel::test_model_registry(void) |
| 2642 | 2642 | if (ptr != NULL) { |
| 2643 | 2643 | |
| 2644 | 2644 | // Test model type |
| 2645 | - #if defined(G_LEGACY_MODEL_NAMES) | |
| 2646 | - test_assert((ptr->type() == registry.name(i)) || | |
| 2647 | - (ptr->alias() == registry.name(i)), | |
| 2648 | - "Expected \""+registry.name(i)+"\" instead" | |
| 2649 | - " of \""+ptr->type()+"\" or \""+ | |
| 2650 | - ptr->alias()+"\"."); | |
| 2651 | - #else | |
| 2652 | 2645 | test_assert(ptr->type() == registry.name(i), |
| 2653 | 2646 | "Expected \""+registry.name(i)+"\" instead" |
| 2654 | 2647 | " of \""+ptr->type()+"\"."); |
| 2655 | - #endif | |
| 2656 | 2648 | |
| 2657 | 2649 | // Free model |
| 2658 | 2650 | delete ptr; | ... | ... |