Commit cb2fd58a96cb6683ca0c99e09b7712724bb6bfc5
1 parent
91f2b412
Base classes on GRegistry interface.
All registry classes are now based on the GRegistry interface. The ostream and GLog friend functions have been removed from the classes as they are now implement on the GRegistry level. The source code was checked to comply to the actual coding standards. The Doxygen documentation of the source code was improved.
Showing
29 changed files
with
339 additions
and
575 deletions
include/GModelRadialRegistry.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * GModelRadialRegistry.hpp - Radial spatial model registry class * | |
| 2 | + * GModelRadialRegistry.hpp - Radial model registry class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2011-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -20,8 +20,8 @@ |
| 20 | 20 | ***************************************************************************/ |
| 21 | 21 | /** |
| 22 | 22 | * @file GModelRadialRegistry.hpp |
| 23 | - * @brief Radial spatial model class interface definition | |
| 24 | - * @author J. Knodlseder | |
| 23 | + * @brief Radial model registry class interface definition | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GMODELRADIALREGISTRY_HPP |
| ... | ... | @@ -29,31 +29,28 @@ |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | -#include <iostream> | |
| 33 | -#include "GLog.hpp" | |
| 32 | +#include "GRegistry.hpp" | |
| 34 | 33 | #include "GModelRadial.hpp" |
| 35 | 34 | |
| 36 | 35 | |
| 37 | 36 | /***********************************************************************//** |
| 38 | 37 | * @class GModelRadialRegistry |
| 39 | 38 | * |
| 40 | - * @brief Radial spatial model registry class | |
| 39 | + * @brief Radial model registry class | |
| 41 | 40 | * |
| 42 | - * The registry class allows the registration of radial spatial models that | |
| 43 | - * are not necessarily compiled into the GammaLib. It uses the static members | |
| 41 | + * The registry class allows the registration of radial models that are not | |
| 42 | + * necessarily compiled into the GammaLib. It uses the static members | |
| 44 | 43 | * m_number, m_names, and m_models which are allocated globally to keep track |
| 45 | - * of radial spatial models that are available throughout all linked | |
| 46 | - * libraries. To register a radial spatial model it is sufficient to add | |
| 47 | - * const GModelRadialXXX g_radial_XXX_seed; | |
| 48 | - * const GModelRadialRegistry g_radial_XXX_registry(&g_radial_XXX_seed); | |
| 49 | - * at the top of the .cpp file of the radial spatial model. Here, XXX is a | |
| 50 | - * unique name that describes the model. | |
| 44 | + * of radial models that are available throughout all linked libraries. To | |
| 45 | + * register a radial model it is sufficient to add | |
| 46 | + * | |
| 47 | + * const GModelRadialXXX g_radial_XXX_seed; | |
| 48 | + * const GModelRadialRegistry g_radial_XXX_registry(&g_radial_XXX_seed); | |
| 49 | + * | |
| 50 | + * at the top of the .cpp file of the radial model. Here, XXX is a unique | |
| 51 | + * name that describes the model. | |
| 51 | 52 | ***************************************************************************/ |
| 52 | -class GModelRadialRegistry { | |
| 53 | - | |
| 54 | - // I/O friends | |
| 55 | - friend std::ostream& operator<<(std::ostream& os, const GModelRadialRegistry& registry); | |
| 56 | - friend GLog& operator<<(GLog& log, const GModelRadialRegistry& registry); | |
| 53 | +class GModelRadialRegistry : public GRegistry { | |
| 57 | 54 | |
| 58 | 55 | public: |
| 59 | 56 | // Constructors and destructors |
| ... | ... | @@ -67,7 +64,7 @@ public: |
| 67 | 64 | |
| 68 | 65 | // Methods |
| 69 | 66 | int size(void) const { return m_number; } |
| 70 | - GModelRadial* alloc(const std::string& type) const; | |
| 67 | + GModelRadial* alloc(const std::string& name) const; | |
| 71 | 68 | std::string name(const int& index) const; |
| 72 | 69 | std::string print(void) const; |
| 73 | 70 | ... | ... |
include/GModelRegistry.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * GModelRegistry.hpp - Model registry class * | |
| 2 | + * GModelRegistry.hpp - Model registry class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2011-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -20,8 +20,8 @@ |
| 20 | 20 | ***************************************************************************/ |
| 21 | 21 | /** |
| 22 | 22 | * @file GModelRegistry.hpp |
| 23 | - * @brief GModelRegistry class interface definition | |
| 24 | - * @author J. Knodlseder | |
| 23 | + * @brief Model registry class definition | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GMODELREGISTRY_HPP |
| ... | ... | @@ -29,31 +29,28 @@ |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | -#include <iostream> | |
| 33 | -#include "GLog.hpp" | |
| 32 | +#include "GRegistry.hpp" | |
| 34 | 33 | #include "GModel.hpp" |
| 35 | 34 | |
| 36 | 35 | |
| 37 | 36 | /***********************************************************************//** |
| 38 | 37 | * @class GModelRegistry |
| 39 | 38 | * |
| 40 | - * @brief Interface definition for the model registry class. | |
| 39 | + * @brief Interface definition for the model registry class | |
| 41 | 40 | * |
| 42 | 41 | * The registry class allows the registration of models that are not |
| 43 | 42 | * necessarily compiled into the GammaLib. It uses the static members |
| 44 | 43 | * m_number, m_names, and m_models which are allocated globally to keep track |
| 45 | 44 | * of models that are available throughout all linked libraries. To register |
| 46 | 45 | * a model it is sufficient to add |
| 47 | - * const GModelXXX g_XXX_seed; | |
| 48 | - * const GModelRegistry g_XXX_registry(&g_XXX_seed); | |
| 46 | + * | |
| 47 | + * const GModelXXX g_XXX_seed; | |
| 48 | + * const GModelRegistry g_XXX_registry(&g_XXX_seed); | |
| 49 | + * | |
| 49 | 50 | * at the top of the .cpp file of the model. Here, XXX is a unique name that |
| 50 | 51 | * describes the model. |
| 51 | 52 | ***************************************************************************/ |
| 52 | -class GModelRegistry { | |
| 53 | - | |
| 54 | - // I/O friends | |
| 55 | - friend std::ostream& operator<<(std::ostream& os, const GModelRegistry& registry); | |
| 56 | - friend GLog& operator<<(GLog& log, const GModelRegistry& registry); | |
| 53 | +class GModelRegistry : public GRegistry { | |
| 57 | 54 | |
| 58 | 55 | public: |
| 59 | 56 | // Constructors and destructors |
| ... | ... | @@ -67,7 +64,7 @@ public: |
| 67 | 64 | |
| 68 | 65 | // Methods |
| 69 | 66 | int size(void) const { return m_number; } |
| 70 | - GModel* alloc(const std::string& type) const; | |
| 67 | + GModel* alloc(const std::string& name) const; | |
| 71 | 68 | std::string name(const int& index) const; |
| 72 | 69 | std::string print(void) const; |
| 73 | 70 | ... | ... |
include/GModelSpatialRegistry.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * GModelSpatialRegistry.hpp - Spatial model registry class * | |
| 2 | + * GModelSpatialRegistry.hpp - Spatial model registry class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2011-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -20,8 +20,8 @@ |
| 20 | 20 | ***************************************************************************/ |
| 21 | 21 | /** |
| 22 | 22 | * @file GModelSpatialRegistry.hpp |
| 23 | - * @brief GModelSpatialRegistry class interface definition | |
| 24 | - * @author J. Knodlseder | |
| 23 | + * @brief Spatial model registry class definition | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GMODELSPATIALREGISTRY_HPP |
| ... | ... | @@ -29,31 +29,28 @@ |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | -#include <iostream> | |
| 33 | -#include "GLog.hpp" | |
| 32 | +#include "GRegistry.hpp" | |
| 34 | 33 | #include "GModelSpatial.hpp" |
| 35 | 34 | |
| 36 | 35 | |
| 37 | 36 | /***********************************************************************//** |
| 38 | 37 | * @class GModelSpatialRegistry |
| 39 | 38 | * |
| 40 | - * @brief Interface definition for the spatial model registry class. | |
| 39 | + * @brief Interface definition for the spatial model registry class | |
| 41 | 40 | * |
| 42 | 41 | * The registry class allows the registration of spatial models that are not |
| 43 | 42 | * necessarily compiled into the GammaLib. It uses the static members |
| 44 | 43 | * m_number, m_names, and m_models which are allocated globally to keep track |
| 45 | 44 | * of spatial models that are available throughout all linked libraries. To |
| 46 | 45 | * register a spatial model it is sufficient to add |
| 47 | - * const GModelSpatialXXX g_spatial_XXX_seed; | |
| 48 | - * const GModelSpatialRegistry g_spatial_XXX_registry(&g_spatial_XXX_seed); | |
| 46 | + * | |
| 47 | + * const GModelSpatialXXX g_spatial_XXX_seed; | |
| 48 | + * const GModelSpatialRegistry g_spatial_XXX_registry(&g_spatial_XXX_seed); | |
| 49 | + * | |
| 49 | 50 | * at the top of the .cpp file of the spatial model. Here, XXX is a unique |
| 50 | 51 | * name that describes the model. |
| 51 | 52 | ***************************************************************************/ |
| 52 | -class GModelSpatialRegistry { | |
| 53 | - | |
| 54 | - // I/O friends | |
| 55 | - friend std::ostream& operator<<(std::ostream& os, const GModelSpatialRegistry& registry); | |
| 56 | - friend GLog& operator<<(GLog& log, const GModelSpatialRegistry& registry); | |
| 53 | +class GModelSpatialRegistry : public GRegistry { | |
| 57 | 54 | |
| 58 | 55 | public: |
| 59 | 56 | // Constructors and destructors |
| ... | ... | @@ -67,7 +64,7 @@ public: |
| 67 | 64 | |
| 68 | 65 | // Methods |
| 69 | 66 | int size(void) const { return m_number; } |
| 70 | - GModelSpatial* alloc(const std::string& type) const; | |
| 67 | + GModelSpatial* alloc(const std::string& name) const; | |
| 71 | 68 | std::string name(const int& index) const; |
| 72 | 69 | std::string print(void) const; |
| 73 | 70 | ... | ... |
include/GModelSpectralRegistry.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * GModelSpectralRegistry.hpp - Spectral model registry class * | |
| 2 | + * GModelSpectralRegistry.hpp - Spectral model registry class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2011-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -20,8 +20,8 @@ |
| 20 | 20 | ***************************************************************************/ |
| 21 | 21 | /** |
| 22 | 22 | * @file GModelSpectralRegistry.hpp |
| 23 | - * @brief GModelSpectralRegistry class interface definition | |
| 24 | - * @author J. Knodlseder | |
| 23 | + * @brief Spectral model registry class definition | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GMODELSPECTRALREGISTRY_HPP |
| ... | ... | @@ -29,31 +29,28 @@ |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | -#include <iostream> | |
| 33 | -#include "GLog.hpp" | |
| 32 | +#include "GRegistry.hpp" | |
| 34 | 33 | #include "GModelSpectral.hpp" |
| 35 | 34 | |
| 36 | 35 | |
| 37 | 36 | /***********************************************************************//** |
| 38 | 37 | * @class GModelSpectralRegistry |
| 39 | 38 | * |
| 40 | - * @brief Interface definition for the spectral model registry class. | |
| 39 | + * @brief Interface definition for the spectral model registry class | |
| 41 | 40 | * |
| 42 | 41 | * The registry class allows the registration of spectral models that are not |
| 43 | 42 | * necessarily compiled into the GammaLib. It uses the static members |
| 44 | 43 | * m_number, m_names, and m_models which are allocated globally to keep track |
| 45 | 44 | * of spectral models that are available throughout all linked libraries. To |
| 46 | 45 | * register a spectral model it is sufficient to add |
| 47 | - * const GModelSpectralXXX g_spectral_XXX_seed; | |
| 48 | - * const GModelSpectralRegistry g_spectral_XXX_registry(&g_spectral_XXX_seed); | |
| 46 | + * | |
| 47 | + * const GModelSpectralXXX g_spectral_XXX_seed; | |
| 48 | + * const GModelSpectralRegistry g_spectral_XXX_registry(&g_spectral_XXX_seed); | |
| 49 | + * | |
| 49 | 50 | * at the top of the .cpp file of the spectral model. Here, XXX is a unique |
| 50 | 51 | * name that describes the model. |
| 51 | 52 | ***************************************************************************/ |
| 52 | -class GModelSpectralRegistry { | |
| 53 | - | |
| 54 | - // I/O friends | |
| 55 | - friend std::ostream& operator<<(std::ostream& os, const GModelSpectralRegistry& registry); | |
| 56 | - friend GLog& operator<<(GLog& log, const GModelSpectralRegistry& registry); | |
| 53 | +class GModelSpectralRegistry : public GRegistry { | |
| 57 | 54 | |
| 58 | 55 | public: |
| 59 | 56 | // Constructors and destructors |
| ... | ... | @@ -67,7 +64,7 @@ public: |
| 67 | 64 | |
| 68 | 65 | // Methods |
| 69 | 66 | int size(void) const { return m_number; } |
| 70 | - GModelSpectral* alloc(const std::string& type) const; | |
| 67 | + GModelSpectral* alloc(const std::string& name) const; | |
| 71 | 68 | std::string name(const int& index) const; |
| 72 | 69 | std::string print(void) const; |
| 73 | 70 | ... | ... |
include/GModelTemporalRegistry.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * GModelTemporalRegistry.hpp - Temporal model registry class * | |
| 2 | + * GModelTemporalRegistry.hpp - Temporal model registry class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2011-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -20,8 +20,8 @@ |
| 20 | 20 | ***************************************************************************/ |
| 21 | 21 | /** |
| 22 | 22 | * @file GModelTemporalRegistry.hpp |
| 23 | - * @brief GModelTemporalRegistry class interface definition | |
| 24 | - * @author J. Knodlseder | |
| 23 | + * @brief Temporal model registry class definition | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GMODELTEMPORALREGISTRY_HPP |
| ... | ... | @@ -29,8 +29,7 @@ |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | -#include <iostream> | |
| 33 | -#include "GLog.hpp" | |
| 32 | +#include "GRegistry.hpp" | |
| 34 | 33 | #include "GModelTemporal.hpp" |
| 35 | 34 | |
| 36 | 35 | |
| ... | ... | @@ -44,16 +43,14 @@ |
| 44 | 43 | * m_number, m_names, and m_models which are allocated globally to keep track |
| 45 | 44 | * of temporal models that are available throughout all linked libraries. To |
| 46 | 45 | * register a temporal model it is sufficient to add |
| 47 | - * const GModelTemporalXXX g_temporal_XXX_seed; | |
| 48 | - * const GModelTemporalRegistry g_temporal_XXX_registry(&g_spectral_XXX_seed); | |
| 46 | + * | |
| 47 | + * const GModelTemporalXXX g_temporal_XXX_seed; | |
| 48 | + * const GModelTemporalRegistry g_temporal_XXX_registry(&g_spectral_XXX_seed); | |
| 49 | + * | |
| 49 | 50 | * at the top of the .cpp file of the temporal model. Here, XXX is a unique |
| 50 | 51 | * name that describes the model. |
| 51 | 52 | ***************************************************************************/ |
| 52 | -class GModelTemporalRegistry { | |
| 53 | - | |
| 54 | - // I/O friends | |
| 55 | - friend std::ostream& operator<<(std::ostream& os, const GModelTemporalRegistry& registry); | |
| 56 | - friend GLog& operator<<(GLog& log, const GModelTemporalRegistry& registry); | |
| 53 | +class GModelTemporalRegistry : public GRegistry { | |
| 57 | 54 | |
| 58 | 55 | public: |
| 59 | 56 | // Constructors and destructors |
| ... | ... | @@ -67,7 +64,7 @@ public: |
| 67 | 64 | |
| 68 | 65 | // Methods |
| 69 | 66 | int size(void) const { return m_number; } |
| 70 | - GModelTemporal* alloc(const std::string& type) const; | |
| 67 | + GModelTemporal* alloc(const std::string& name) const; | |
| 71 | 68 | std::string name(const int& index) const; |
| 72 | 69 | std::string print(void) const; |
| 73 | 70 | ... | ... |
include/GObservationRegistry.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * GObservationRegistry.hpp - Observation registry class * | |
| 2 | + * GObservationRegistry.hpp - Observation registry class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2011-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -20,8 +20,8 @@ |
| 20 | 20 | ***************************************************************************/ |
| 21 | 21 | /** |
| 22 | 22 | * @file GObservationRegistry.hpp |
| 23 | - * @brief GObservationRegistry class interface definition | |
| 24 | - * @author J. Knoedlseder | |
| 23 | + * @brief Observation registry class definition | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GOBSERVATIONREGISTRY_HPP |
| ... | ... | @@ -29,8 +29,7 @@ |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | -#include <iostream> | |
| 33 | -#include "GLog.hpp" | |
| 32 | +#include "GRegistry.hpp" | |
| 34 | 33 | #include "GObservation.hpp" |
| 35 | 34 | |
| 36 | 35 | |
| ... | ... | @@ -44,17 +43,15 @@ |
| 44 | 43 | * m_number, m_names, and m_obs which are allocated globally to keep track |
| 45 | 44 | * of observations that are available throughout all linked libraries. To |
| 46 | 45 | * register an observation it is sufficient to add |
| 47 | - * const GXXXObservation g_obs_XXX_seed; | |
| 48 | - * const GObservationRegistry g_obs_XXX_registry(&g_obs_XXX_seed); | |
| 46 | + * | |
| 47 | + * const GXXXObservation g_obs_XXX_seed; | |
| 48 | + * const GObservationRegistry g_obs_XXX_registry(&g_obs_XXX_seed); | |
| 49 | + * | |
| 49 | 50 | * at the top of the .cpp file of the observation. Here, XXX is a unique |
| 50 | 51 | * name that describes the instrument for which the observation class is |
| 51 | 52 | * implemented. |
| 52 | 53 | ***************************************************************************/ |
| 53 | -class GObservationRegistry { | |
| 54 | - | |
| 55 | - // I/O friends | |
| 56 | - friend std::ostream& operator<<(std::ostream& os, const GObservationRegistry& registry); | |
| 57 | - friend GLog& operator<<(GLog& log, const GObservationRegistry& registry); | |
| 54 | +class GObservationRegistry : public GRegistry { | |
| 58 | 55 | |
| 59 | 56 | public: |
| 60 | 57 | // Constructors and destructors |
| ... | ... | @@ -68,8 +65,8 @@ public: |
| 68 | 65 | |
| 69 | 66 | // Methods |
| 70 | 67 | int size(void) const { return m_number; } |
| 71 | - GObservation* alloc(const std::string& instrument) const; | |
| 72 | - std::string instrument(const int& index) const; | |
| 68 | + GObservation* alloc(const std::string& name) const; | |
| 69 | + std::string name(const int& index) const; | |
| 73 | 70 | std::string print(void) const; |
| 74 | 71 | |
| 75 | 72 | protected: | ... | ... |
include/GWcsRegistry.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * GWcsRegistry.hpp - World Coordinate Projection registry class * | |
| 2 | + * GWcsRegistry.hpp - World Coordinate Projection registry class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2011-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GWcsRegistry.hpp |
| 23 | 23 | * @brief World Coordinate Projection registry class interface definition |
| 24 | - * @author J. Knodlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GWCSREGISTRY_HPP |
| ... | ... | @@ -29,8 +29,7 @@ |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | -#include <iostream> | |
| 33 | -#include "GLog.hpp" | |
| 32 | +#include "GRegistry.hpp" | |
| 34 | 33 | #include "GWcslib.hpp" |
| 35 | 34 | |
| 36 | 35 | |
| ... | ... | @@ -44,16 +43,14 @@ |
| 44 | 43 | * m_number, m_codes, m_names, and m_prjs which are allocated globally to keep |
| 45 | 44 | * track of projections that are available throughout all linked libraries. To |
| 46 | 45 | * register a projection it is sufficient to add |
| 47 | - * const GWcsXXX g_wcs_XXX_seed; | |
| 48 | - * const GWcsRegistry g_wcs_XXX_registry(&g_wcs_XXX_seed); | |
| 46 | + * | |
| 47 | + * const GWcsXXX g_wcs_XXX_seed; | |
| 48 | + * const GWcsRegistry g_wcs_XXX_registry(&g_wcs_XXX_seed); | |
| 49 | + * | |
| 49 | 50 | * at the top of the .cpp file of the projection. Here, XXX is a unique |
| 50 | 51 | * code that describes the projection. |
| 51 | 52 | ***************************************************************************/ |
| 52 | -class GWcsRegistry { | |
| 53 | - | |
| 54 | - // I/O friends | |
| 55 | - friend std::ostream& operator<<(std::ostream& os, const GWcsRegistry& registry); | |
| 56 | - friend GLog& operator<<(GLog& log, const GWcsRegistry& registry); | |
| 53 | +class GWcsRegistry : public GRegistry { | |
| 57 | 54 | |
| 58 | 55 | public: |
| 59 | 56 | // Constructors and destructors | ... | ... |
inst/cta/include/GCTAModelRadialRegistry.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * GCTAModelRadialRegistry.hpp - CTA Radial model registry class * | |
| 2 | + * GCTAModelRadialRegistry.hpp - CTA Radial model registry class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2011-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -20,8 +20,8 @@ |
| 20 | 20 | ***************************************************************************/ |
| 21 | 21 | /** |
| 22 | 22 | * @file GCTAModelRadialRegistry.hpp |
| 23 | - * @brief GCTAModelRadialRegistry class interface definition | |
| 24 | - * @author J. Knodlseder | |
| 23 | + * @brief CTA radial model registry class definition | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GCTAMODELRADIALREGISTRY_HPP |
| ... | ... | @@ -29,31 +29,28 @@ |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | -#include <iostream> | |
| 33 | -#include "GLog.hpp" | |
| 32 | +#include "GRegistry.hpp" | |
| 34 | 33 | #include "GCTAModelRadial.hpp" |
| 35 | 34 | |
| 36 | 35 | |
| 37 | 36 | /***********************************************************************//** |
| 38 | 37 | * @class GCTAModelRadialRegistry |
| 39 | 38 | * |
| 40 | - * @brief Interface definition for the CTA radial model registry class. | |
| 39 | + * @brief Interface definition for the CTA radial model registry class | |
| 41 | 40 | * |
| 42 | 41 | * The registry class allows the registration of radial models for CTA that |
| 43 | 42 | * are not necessarily compiled into the GammaLib. It uses the static members |
| 44 | 43 | * m_number, m_names, and m_models which are allocated globally to keep track |
| 45 | 44 | * of radial models that are available throughout all linked libraries. To |
| 46 | 45 | * register a radial model it is sufficient to add |
| 47 | - * const GCTAModelRadialXXX g_cta_radial_XXX_seed; | |
| 48 | - * const GCTAModelRadialRegistry g_cta_radial_XXX_registry(&g_cta_radial_XXX_seed); | |
| 46 | + * | |
| 47 | + * const GCTAModelRadialXXX g_cta_radial_XXX_seed; | |
| 48 | + * const GCTAModelRadialRegistry g_cta_radial_XXX_registry(&g_cta_radial_XXX_seed); | |
| 49 | + * | |
| 49 | 50 | * at the top of the .cpp file of the radial model. Here, XXX is a unique |
| 50 | 51 | * name that describes the model. |
| 51 | 52 | ***************************************************************************/ |
| 52 | -class GCTAModelRadialRegistry { | |
| 53 | - | |
| 54 | - // I/O friends | |
| 55 | - friend std::ostream& operator<<(std::ostream& os, const GCTAModelRadialRegistry& registry); | |
| 56 | - friend GLog& operator<<(GLog& log, const GCTAModelRadialRegistry& registry); | |
| 53 | +class GCTAModelRadialRegistry : public GRegistry { | |
| 57 | 54 | |
| 58 | 55 | public: |
| 59 | 56 | // Constructors and destructors |
| ... | ... | @@ -67,7 +64,7 @@ public: |
| 67 | 64 | |
| 68 | 65 | // Methods |
| 69 | 66 | int size(void) const { return m_number; } |
| 70 | - GCTAModelRadial* alloc(const std::string& type) const; | |
| 67 | + GCTAModelRadial* alloc(const std::string& name) const; | |
| 71 | 68 | std::string name(const int& index) const; |
| 72 | 69 | std::string print(void) const; |
| 73 | 70 | ... | ... |
inst/cta/pyext/GCTAModelRadialRegistry.i
| 1 | 1 | /*************************************************************************** |
| 2 | - * GCTAModelRadialRegistry.i - CTA Radial model registry class python I/F* | |
| 2 | + * GCTAModelRadialRegistry.i - CTA Radial model registry class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2011-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -20,8 +20,8 @@ |
| 20 | 20 | ***************************************************************************/ |
| 21 | 21 | /** |
| 22 | 22 | * @file GCTAModelRadialRegistry.i |
| 23 | - * @brief GCTAModelRadialRegistry class python interface. | |
| 24 | - * @author J. Knodlseder | |
| 23 | + * @brief CTA radial model registry class definition | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | %{ |
| 27 | 27 | /* Put headers and other declarations here that are needed for compilation */ |
| ... | ... | @@ -33,9 +33,10 @@ |
| 33 | 33 | /***********************************************************************//** |
| 34 | 34 | * @class GCTAModelRadialRegistry |
| 35 | 35 | * |
| 36 | - * @brief Interface definition for the spatial model registry class. | |
| 36 | + * @brief Interface definition for the CTA radial model registry class | |
| 37 | 37 | ***************************************************************************/ |
| 38 | -class GCTAModelRadialRegistry { | |
| 38 | +class GCTAModelRadialRegistry : public GRegistry { | |
| 39 | + | |
| 39 | 40 | public: |
| 40 | 41 | // Constructors and destructors |
| 41 | 42 | GCTAModelRadialRegistry(void); |
| ... | ... | @@ -45,7 +46,7 @@ public: |
| 45 | 46 | |
| 46 | 47 | // Methods |
| 47 | 48 | int size(void) const; |
| 48 | - GCTAModelRadial* alloc(const std::string& type) const; | |
| 49 | + GCTAModelRadial* alloc(const std::string& name) const; | |
| 49 | 50 | std::string name(const int& index) const; |
| 50 | 51 | }; |
| 51 | 52 | ... | ... |
inst/cta/pyext/cta.i
| ... | ... | @@ -27,6 +27,10 @@ |
| 27 | 27 | /* __ Include standard typemaps for vectors and strings __________________ */ |
| 28 | 28 | %include stl.i |
| 29 | 29 | |
| 30 | +/* __ Include interface classes __________________________________________ */ | |
| 31 | +%import(module="gammalib.base") "GBase.i"; | |
| 32 | +%import(module="gammalib.base") "GRegistry.i"; | |
| 33 | + | |
| 30 | 34 | /* __ Make sure that exceptions are catched ______________________________ */ |
| 31 | 35 | %import(module="gammalib.support") "GException.i"; |
| 32 | 36 | ... | ... |
inst/cta/src/GCTAModelRadialRegistry.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * GCTAModelRadialRegistry.cpp - CTA radial model registry class * | |
| 2 | + * GCTAModelRadialRegistry.cpp - CTA Radial model registry class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2011-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -20,8 +20,8 @@ |
| 20 | 20 | ***************************************************************************/ |
| 21 | 21 | /** |
| 22 | 22 | * @file GCTAModelRadialRegistry.cpp |
| 23 | - * @brief GCTAModelRadialRegistry class interface definition | |
| 24 | - * @author J. Knodlseder | |
| 23 | + * @brief CTA radial model registry class implementation | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | /* __ Includes ___________________________________________________________ */ |
| ... | ... | @@ -118,8 +118,9 @@ GCTAModelRadialRegistry::GCTAModelRadialRegistry(const GCTAModelRadial* model) |
| 118 | 118 | // Debug option: Show actual registry |
| 119 | 119 | #if G_DEBUG_REGISTRY |
| 120 | 120 | std::cout << "GCTAModelRadialRegistry(const GCTAModelRadial*): "; |
| 121 | - for (int i = 0; i < m_number; ++i) | |
| 121 | + for (int i = 0; i < m_number; ++i) { | |
| 122 | 122 | std::cout << "\"" << m_names[i] << "\" "; |
| 123 | + } | |
| 123 | 124 | std::cout << std::endl; |
| 124 | 125 | #endif |
| 125 | 126 | |
| ... | ... | @@ -169,6 +170,7 @@ GCTAModelRadialRegistry::~GCTAModelRadialRegistry(void) |
| 169 | 170 | * @brief Assignment operator |
| 170 | 171 | * |
| 171 | 172 | * @param[in] registry Registry. |
| 173 | + * @return Reference to registry. | |
| 172 | 174 | ***************************************************************************/ |
| 173 | 175 | GCTAModelRadialRegistry& GCTAModelRadialRegistry::operator= (const GCTAModelRadialRegistry& registry) |
| 174 | 176 | { |
| ... | ... | @@ -198,22 +200,22 @@ GCTAModelRadialRegistry& GCTAModelRadialRegistry::operator= (const GCTAModelRadi |
| 198 | 200 | ==========================================================================*/ |
| 199 | 201 | |
| 200 | 202 | /***********************************************************************//** |
| 201 | - * @brief Allocate radial model of given type | |
| 203 | + * @brief Allocate radial model of given name | |
| 202 | 204 | * |
| 203 | - * @param[in] type Radial model type. | |
| 205 | + * @param[in] name Radial model name. | |
| 204 | 206 | * |
| 205 | - * Returns a pointer to a void radial model instance of the specified | |
| 206 | - * type. If the type has not been found in the registry, a NULL pointer is | |
| 207 | + * Returns a pointer to a radial model instance of the specified name. | |
| 208 | + * If the name has not been found in the registry, a NULL pointer is | |
| 207 | 209 | * returned. |
| 208 | 210 | ***************************************************************************/ |
| 209 | -GCTAModelRadial* GCTAModelRadialRegistry::alloc(const std::string& type) const | |
| 211 | +GCTAModelRadial* GCTAModelRadialRegistry::alloc(const std::string& name) const | |
| 210 | 212 | { |
| 211 | 213 | // Initialise radial model |
| 212 | 214 | GCTAModelRadial* model = NULL; |
| 213 | 215 | |
| 214 | 216 | // Search for model in registry |
| 215 | 217 | for (int i = 0; i < m_number; ++i) { |
| 216 | - if (m_names[i] == type) { | |
| 218 | + if (m_names[i] == name) { | |
| 217 | 219 | model = m_models[i]->clone(); |
| 218 | 220 | break; |
| 219 | 221 | } |
| ... | ... | @@ -228,6 +230,7 @@ GCTAModelRadial* GCTAModelRadialRegistry::alloc(const std::string& type) const |
| 228 | 230 | * @brief Returns model name |
| 229 | 231 | * |
| 230 | 232 | * @param[in] index Model index [0,...,size()-1]. |
| 233 | + * @return Model name. | |
| 231 | 234 | * |
| 232 | 235 | * @exception GException::out_of_range |
| 233 | 236 | * Model index is out of range. |
| ... | ... | @@ -236,8 +239,9 @@ std::string GCTAModelRadialRegistry::name(const int& index) const |
| 236 | 239 | { |
| 237 | 240 | // Compile option: raise exception if index is out of range |
| 238 | 241 | #if defined(G_RANGE_CHECK) |
| 239 | - if (index < 0 || index >= size()) | |
| 242 | + if (index < 0 || index >= size()) { | |
| 240 | 243 | throw GException::out_of_range(G_NAME, index, 0, size()-1); |
| 244 | + } | |
| 241 | 245 | #endif |
| 242 | 246 | |
| 243 | 247 | // Return name |
| ... | ... | @@ -247,6 +251,8 @@ std::string GCTAModelRadialRegistry::name(const int& index) const |
| 247 | 251 | |
| 248 | 252 | /***********************************************************************//** |
| 249 | 253 | * @brief Print registry information |
| 254 | + * | |
| 255 | + * @return Registry content. | |
| 250 | 256 | ***************************************************************************/ |
| 251 | 257 | std::string GCTAModelRadialRegistry::print(void) const |
| 252 | 258 | { |
| ... | ... | @@ -303,41 +309,3 @@ void GCTAModelRadialRegistry::free_members(void) |
| 303 | 309 | // Return |
| 304 | 310 | return; |
| 305 | 311 | } |
| 306 | - | |
| 307 | - | |
| 308 | -/*========================================================================== | |
| 309 | - = = | |
| 310 | - = Friends = | |
| 311 | - = = | |
| 312 | - ==========================================================================*/ | |
| 313 | - | |
| 314 | -/***********************************************************************//** | |
| 315 | - * @brief Output operator | |
| 316 | - * | |
| 317 | - * @param[in] os Output stream. | |
| 318 | - * @param[in] registry Radial model registry. | |
| 319 | - ***************************************************************************/ | |
| 320 | -std::ostream& operator<< (std::ostream& os, const GCTAModelRadialRegistry& registry) | |
| 321 | -{ | |
| 322 | - // Write registry in output stream | |
| 323 | - os << registry.print(); | |
| 324 | - | |
| 325 | - // Return output stream | |
| 326 | - return os; | |
| 327 | -} | |
| 328 | - | |
| 329 | - | |
| 330 | -/***********************************************************************//** | |
| 331 | - * @brief Log operator | |
| 332 | - * | |
| 333 | - * @param[in] log Logger. | |
| 334 | - * @param[in] registry Radial model registry. | |
| 335 | - ***************************************************************************/ | |
| 336 | -GLog& operator<< (GLog& log, const GCTAModelRadialRegistry& registry) | |
| 337 | -{ | |
| 338 | - // Write registry into logger | |
| 339 | - log << registry.print(); | |
| 340 | - | |
| 341 | - // Return logger | |
| 342 | - return log; | |
| 343 | -} | ... | ... |
pyext/GModelRadialRegistry.i
| 1 | 1 | /*************************************************************************** |
| 2 | - * GModelRadialRegistry.i - Radial spatial model registry class * | |
| 2 | + * GModelRadialRegistry.i - Radial model registry class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2011-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -20,8 +20,8 @@ |
| 20 | 20 | ***************************************************************************/ |
| 21 | 21 | /** |
| 22 | 22 | * @file GModelRadialRegistry.i |
| 23 | - * @brief Radial spatial model registry class Python interface definition | |
| 24 | - * @author J. Knodlseder | |
| 23 | + * @brief Radial model registry class interface definition | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | %{ |
| 27 | 27 | /* Put headers and other declarations here that are needed for compilation */ |
| ... | ... | @@ -33,9 +33,10 @@ |
| 33 | 33 | /***********************************************************************//** |
| 34 | 34 | * @class GModelRadialRegistry |
| 35 | 35 | * |
| 36 | - * @brief Radial spatial model registry class | |
| 36 | + * @brief Radial model registry class | |
| 37 | 37 | ***************************************************************************/ |
| 38 | -class GModelRadialRegistry { | |
| 38 | +class GModelRadialRegistry : public GRegistry { | |
| 39 | + | |
| 39 | 40 | public: |
| 40 | 41 | // Constructors and destructors |
| 41 | 42 | GModelRadialRegistry(void); |
| ... | ... | @@ -45,7 +46,7 @@ public: |
| 45 | 46 | |
| 46 | 47 | // Methods |
| 47 | 48 | int size(void) const; |
| 48 | - GModelRadial* alloc(const std::string& type) const; | |
| 49 | + GModelRadial* alloc(const std::string& name) const; | |
| 49 | 50 | std::string name(const int& index) const; |
| 50 | 51 | }; |
| 51 | 52 | ... | ... |
pyext/GModelRegistry.i
| 1 | 1 | /*************************************************************************** |
| 2 | - * GModelRegistry.i - Model registry class python I/F * | |
| 2 | + * GModelRegistry.i - Model registry class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2011-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -20,8 +20,8 @@ |
| 20 | 20 | ***************************************************************************/ |
| 21 | 21 | /** |
| 22 | 22 | * @file GModelRegistry.i |
| 23 | - * @brief GModelRegistry class python interface. | |
| 24 | - * @author J. Knodlseder | |
| 23 | + * @brief Model registry class definition | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | %{ |
| 27 | 27 | /* Put headers and other declarations here that are needed for compilation */ |
| ... | ... | @@ -33,9 +33,10 @@ |
| 33 | 33 | /***********************************************************************//** |
| 34 | 34 | * @class GModelRegistry |
| 35 | 35 | * |
| 36 | - * @brief Interface definition for the model registry class. | |
| 36 | + * @brief Interface definition for the model registry class | |
| 37 | 37 | ***************************************************************************/ |
| 38 | -class GModelRegistry { | |
| 38 | +class GModelRegistry : public GRegistry { | |
| 39 | + | |
| 39 | 40 | public: |
| 40 | 41 | // Constructors and destructors |
| 41 | 42 | GModelRegistry(void); |
| ... | ... | @@ -45,7 +46,7 @@ public: |
| 45 | 46 | |
| 46 | 47 | // Methods |
| 47 | 48 | int size(void) const { return m_number; } |
| 48 | - GModel* alloc(const std::string& type) const; | |
| 49 | + GModel* alloc(const std::string& name) const; | |
| 49 | 50 | std::string name(const int& index) const; |
| 50 | 51 | }; |
| 51 | 52 | ... | ... |
pyext/GModelSpatialRegistry.i
| 1 | 1 | /*************************************************************************** |
| 2 | - * GModelSpatialRegistry.i - Spatial model registry class python I/F * | |
| 2 | + * GModelSpatialRegistry.i - Spatial model registry class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2011-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -20,8 +20,8 @@ |
| 20 | 20 | ***************************************************************************/ |
| 21 | 21 | /** |
| 22 | 22 | * @file GModelSpatialRegistry.i |
| 23 | - * @brief GModelSpatialRegistry class python interface. | |
| 24 | - * @author J. Knodlseder | |
| 23 | + * @brief Spatial model registry class definition | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | %{ |
| 27 | 27 | /* Put headers and other declarations here that are needed for compilation */ |
| ... | ... | @@ -33,9 +33,10 @@ |
| 33 | 33 | /***********************************************************************//** |
| 34 | 34 | * @class GModelSpatialRegistry |
| 35 | 35 | * |
| 36 | - * @brief Interface definition for the spatial model registry class. | |
| 36 | + * @brief Interface definition for the spatial model registry class | |
| 37 | 37 | ***************************************************************************/ |
| 38 | -class GModelSpatialRegistry { | |
| 38 | +class GModelSpatialRegistry : public GRegistry { | |
| 39 | + | |
| 39 | 40 | public: |
| 40 | 41 | // Constructors and destructors |
| 41 | 42 | GModelSpatialRegistry(void); |
| ... | ... | @@ -45,7 +46,7 @@ public: |
| 45 | 46 | |
| 46 | 47 | // Methods |
| 47 | 48 | int size(void) const { return m_number; } |
| 48 | - GModelSpatial* alloc(const std::string& type) const; | |
| 49 | + GModelSpatial* alloc(const std::string& name) const; | |
| 49 | 50 | std::string name(const int& index) const; |
| 50 | 51 | }; |
| 51 | 52 | ... | ... |
pyext/GModelSpectralRegistry.i
| 1 | 1 | /*************************************************************************** |
| 2 | - * GModelSpectralRegistry.i - Spectral model registry class python I/F * | |
| 2 | + * GModelSpectralRegistry.i - Spectral model registry class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2011-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -20,7 +20,7 @@ |
| 20 | 20 | ***************************************************************************/ |
| 21 | 21 | /** |
| 22 | 22 | * @file GModelSpectralRegistry.i |
| 23 | - * @brief GModelSpectralRegistry class python interface. | |
| 23 | + * @brief Spectral model registry class definition | |
| 24 | 24 | * @author J. Knodlseder |
| 25 | 25 | */ |
| 26 | 26 | %{ |
| ... | ... | @@ -33,9 +33,10 @@ |
| 33 | 33 | /***********************************************************************//** |
| 34 | 34 | * @class GModelSpectralRegistry |
| 35 | 35 | * |
| 36 | - * @brief Interface definition for the spectral model registry class. | |
| 36 | + * @brief Interface definition for the spectral model registry class | |
| 37 | 37 | ***************************************************************************/ |
| 38 | -class GModelSpectralRegistry { | |
| 38 | +class GModelSpectralRegistry : public GRegistry { | |
| 39 | + | |
| 39 | 40 | public: |
| 40 | 41 | // Constructors and destructors |
| 41 | 42 | GModelSpectralRegistry(void); |
| ... | ... | @@ -45,7 +46,7 @@ public: |
| 45 | 46 | |
| 46 | 47 | // Methods |
| 47 | 48 | int size(void) const { return m_number; } |
| 48 | - GModelSpectral* alloc(const std::string& type) const; | |
| 49 | + GModelSpectral* alloc(const std::string& name) const; | |
| 49 | 50 | std::string name(const int& index) const; |
| 50 | 51 | }; |
| 51 | 52 | ... | ... |
pyext/GModelTemporalRegistry.i
| 1 | 1 | /*************************************************************************** |
| 2 | - * GModelTemporalRegistry.i - Temporal model registry class python I/F * | |
| 2 | + * GModelTemporalRegistry.i - Temporal model registry class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2011-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -20,8 +20,8 @@ |
| 20 | 20 | ***************************************************************************/ |
| 21 | 21 | /** |
| 22 | 22 | * @file GModelTemporalRegistry.i |
| 23 | - * @brief GModelTemporalRegistry class python interface. | |
| 24 | - * @author J. Knodlseder | |
| 23 | + * @brief Temporal model registry class definition | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | %{ |
| 27 | 27 | /* Put headers and other declarations here that are needed for compilation */ |
| ... | ... | @@ -33,9 +33,10 @@ |
| 33 | 33 | /***********************************************************************//** |
| 34 | 34 | * @class GModelTemporalRegistry |
| 35 | 35 | * |
| 36 | - * @brief Interface definition for the temporal model registry class. | |
| 36 | + * @brief Interface definition for the temporal model registry class | |
| 37 | 37 | ***************************************************************************/ |
| 38 | -class GModelTemporalRegistry { | |
| 38 | +class GModelTemporalRegistry : public GRegistry { | |
| 39 | + | |
| 39 | 40 | public: |
| 40 | 41 | // Constructors and destructors |
| 41 | 42 | GModelTemporalRegistry(void); |
| ... | ... | @@ -45,7 +46,7 @@ public: |
| 45 | 46 | |
| 46 | 47 | // Methods |
| 47 | 48 | int size(void) const { return m_number; } |
| 48 | - GModelTemporal* alloc(const std::string& type) const; | |
| 49 | + GModelTemporal* alloc(const std::string& name) const; | |
| 49 | 50 | std::string name(const int& index) const; |
| 50 | 51 | }; |
| 51 | 52 | ... | ... |
pyext/GObservationRegistry.i
| 1 | 1 | /*************************************************************************** |
| 2 | - * GObservationRegistry.i - Observation registry class python I/F * | |
| 2 | + * GObservationRegistry.i - Observation registry class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2011-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -20,8 +20,8 @@ |
| 20 | 20 | ***************************************************************************/ |
| 21 | 21 | /** |
| 22 | 22 | * @file GObservationRegistry.i |
| 23 | - * @brief GObservationRegistry class python interface. | |
| 24 | - * @author J. Knoedlseder | |
| 23 | + * @brief Observation registry class definition | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | %{ |
| 27 | 27 | /* Put headers and other declarations here that are needed for compilation */ |
| ... | ... | @@ -35,7 +35,8 @@ |
| 35 | 35 | * |
| 36 | 36 | * @brief Interface definition for the observation registry class |
| 37 | 37 | ***************************************************************************/ |
| 38 | -class GObservationRegistry { | |
| 38 | +class GObservationRegistry : public GRegistry { | |
| 39 | + | |
| 39 | 40 | public: |
| 40 | 41 | // Constructors and destructors |
| 41 | 42 | GObservationRegistry(void); |
| ... | ... | @@ -45,8 +46,8 @@ public: |
| 45 | 46 | |
| 46 | 47 | // Methods |
| 47 | 48 | int size(void) const { return m_number; } |
| 48 | - GObservation* alloc(const std::string& instrument) const; | |
| 49 | - std::string instrument(const int& index) const; | |
| 49 | + GObservation* alloc(const std::string& name) const; | |
| 50 | + std::string name(const int& index) const; | |
| 50 | 51 | }; |
| 51 | 52 | |
| 52 | 53 | ... | ... |
pyext/GWcsRegistry.i
| 1 | 1 | /*************************************************************************** |
| 2 | - * GWcsRegistry.i - Temporal model registry class python I/F * | |
| 2 | + * GWcsRegistry.i - World Coordinate Projection registry class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2011-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GWcsRegistry.i |
| 23 | 23 | * @brief World Coordinate Projection registry class interface definition |
| 24 | - * @author J. Knodlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | %{ |
| 27 | 27 | /* Put headers and other declarations here that are needed for compilation */ |
| ... | ... | @@ -35,7 +35,8 @@ |
| 35 | 35 | * |
| 36 | 36 | * @brief Interface definition for the WCS registry class |
| 37 | 37 | ***************************************************************************/ |
| 38 | -class GWcsRegistry { | |
| 38 | +class GWcsRegistry : public GRegistry { | |
| 39 | + | |
| 39 | 40 | public: |
| 40 | 41 | // Constructors and destructors |
| 41 | 42 | GWcsRegistry(void); | ... | ... |
pyext/gammalib/model.i
| ... | ... | @@ -29,6 +29,7 @@ |
| 29 | 29 | |
| 30 | 30 | /* __ Include interface classes __________________________________________ */ |
| 31 | 31 | %import(module="gammalib.base") "GBase.i"; |
| 32 | +%import(module="gammalib.base") "GRegistry.i"; | |
| 32 | 33 | |
| 33 | 34 | /* __ Make sure that exceptions are catched ______________________________ */ |
| 34 | 35 | %import(module="gammalib.support") "GException.i"; | ... | ... |
pyext/gammalib/obs.i
| ... | ... | @@ -29,6 +29,7 @@ |
| 29 | 29 | |
| 30 | 30 | /* __ Include interface classes __________________________________________ */ |
| 31 | 31 | %import(module="gammalib.base") "GBase.i"; |
| 32 | +%import(module="gammalib.base") "GRegistry.i"; | |
| 32 | 33 | |
| 33 | 34 | /* __ Make sure that exceptions are catched ______________________________ */ |
| 34 | 35 | %import(module="gammalib.support") "GException.i"; | ... | ... |
pyext/gammalib/sky.i
| ... | ... | @@ -29,6 +29,7 @@ |
| 29 | 29 | |
| 30 | 30 | /* __ Include interface classes __________________________________________ */ |
| 31 | 31 | %import(module="gammalib.base") "GBase.i"; |
| 32 | +%import(module="gammalib.base") "GRegistry.i"; | |
| 32 | 33 | |
| 33 | 34 | /* __ Make sure that exceptions are catched ______________________________ */ |
| 34 | 35 | %import(module="gammalib.support") "GException.i"; | ... | ... |
src/model/GModelRadialRegistry.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * GModelRadialRegistry.cpp - Radial spatial model registry class * | |
| 2 | + * GModelRadialRegistry.cpp - Radial model registry class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2011-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -20,8 +20,8 @@ |
| 20 | 20 | ***************************************************************************/ |
| 21 | 21 | /** |
| 22 | 22 | * @file GModelRadialRegistry.cpp |
| 23 | - * @brief Radial spatial model class interface implementation | |
| 24 | - * @author J. Knodlseder | |
| 23 | + * @brief Radial model registry class interface implementation | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | /* __ Includes ___________________________________________________________ */ |
| ... | ... | @@ -64,8 +64,9 @@ GModelRadialRegistry::GModelRadialRegistry(void) |
| 64 | 64 | // Debug option: Show actual registry |
| 65 | 65 | #if G_DEBUG_REGISTRY |
| 66 | 66 | std::cout << "GModelRadialRegistry(void): "; |
| 67 | - for (int i = 0; i < m_number; ++i) | |
| 67 | + for (int i = 0; i < m_number; ++i) { | |
| 68 | 68 | std::cout << "\"" << m_names[i] << "\" "; |
| 69 | + } | |
| 69 | 70 | std::cout << std::endl; |
| 70 | 71 | #endif |
| 71 | 72 | |
| ... | ... | @@ -77,7 +78,7 @@ GModelRadialRegistry::GModelRadialRegistry(void) |
| 77 | 78 | /***********************************************************************//** |
| 78 | 79 | * @brief Model constructor |
| 79 | 80 | * |
| 80 | - * @param[in] model Radial spatial model pointer. | |
| 81 | + * @param[in] model Radial model pointer. | |
| 81 | 82 | ***************************************************************************/ |
| 82 | 83 | GModelRadialRegistry::GModelRadialRegistry(const GModelRadial* model) |
| 83 | 84 | { |
| ... | ... | @@ -118,8 +119,9 @@ GModelRadialRegistry::GModelRadialRegistry(const GModelRadial* model) |
| 118 | 119 | // Debug option: Show actual registry |
| 119 | 120 | #if G_DEBUG_REGISTRY |
| 120 | 121 | std::cout << "GModelRadialRegistry(const GModelRadial*): "; |
| 121 | - for (int i = 0; i < m_number; ++i) | |
| 122 | + for (int i = 0; i < m_number; ++i) { | |
| 122 | 123 | std::cout << "\"" << m_names[i] << "\" "; |
| 124 | + } | |
| 123 | 125 | std::cout << std::endl; |
| 124 | 126 | #endif |
| 125 | 127 | |
| ... | ... | @@ -169,6 +171,7 @@ GModelRadialRegistry::~GModelRadialRegistry(void) |
| 169 | 171 | * @brief Assignment operator |
| 170 | 172 | * |
| 171 | 173 | * @param[in] registry Registry. |
| 174 | + * @return Reference to registry. | |
| 172 | 175 | ***************************************************************************/ |
| 173 | 176 | GModelRadialRegistry& GModelRadialRegistry::operator= (const GModelRadialRegistry& registry) |
| 174 | 177 | { |
| ... | ... | @@ -198,22 +201,23 @@ GModelRadialRegistry& GModelRadialRegistry::operator= (const GModelRadialRegistr |
| 198 | 201 | ==========================================================================*/ |
| 199 | 202 | |
| 200 | 203 | /***********************************************************************//** |
| 201 | - * @brief Allocate radial model of given type | |
| 204 | + * @brief Allocate radial model of given name | |
| 202 | 205 | * |
| 203 | - * @param[in] type Radial model type. | |
| 206 | + * @param[in] name Radial model name. | |
| 207 | + * @return Pointer to model (NULL if name is not registered). | |
| 204 | 208 | * |
| 205 | - * Returns a pointer to a void radial spatial model instance of the specified | |
| 206 | - * type. If the type has not been found in the registry, a NULL pointer is | |
| 209 | + * Returns a pointer to a void radial model instance of the specified name. | |
| 210 | + * If the name has not been found in the registry, a NULL pointer is | |
| 207 | 211 | * returned. |
| 208 | 212 | ***************************************************************************/ |
| 209 | -GModelRadial* GModelRadialRegistry::alloc(const std::string& type) const | |
| 213 | +GModelRadial* GModelRadialRegistry::alloc(const std::string& name) const | |
| 210 | 214 | { |
| 211 | 215 | // Initialise radial model |
| 212 | 216 | GModelRadial* model = NULL; |
| 213 | 217 | |
| 214 | 218 | // Search for model in registry |
| 215 | 219 | for (int i = 0; i < m_number; ++i) { |
| 216 | - if (m_names[i] == type) { | |
| 220 | + if (m_names[i] == name) { | |
| 217 | 221 | model = m_models[i]->clone(); |
| 218 | 222 | break; |
| 219 | 223 | } |
| ... | ... | @@ -228,6 +232,7 @@ GModelRadial* GModelRadialRegistry::alloc(const std::string& type) const |
| 228 | 232 | * @brief Returns model name |
| 229 | 233 | * |
| 230 | 234 | * @param[in] index Model index [0,...,size()-1]. |
| 235 | + * @return Model name. | |
| 231 | 236 | * |
| 232 | 237 | * @exception GException::out_of_range |
| 233 | 238 | * Model index is out of range. |
| ... | ... | @@ -236,8 +241,9 @@ std::string GModelRadialRegistry::name(const int& index) const |
| 236 | 241 | { |
| 237 | 242 | // Compile option: raise exception if index is out of range |
| 238 | 243 | #if defined(G_RANGE_CHECK) |
| 239 | - if (index < 0 || index >= size()) | |
| 244 | + if (index < 0 || index >= size()) { | |
| 240 | 245 | throw GException::out_of_range(G_NAME, index, 0, size()-1); |
| 246 | + } | |
| 241 | 247 | #endif |
| 242 | 248 | |
| 243 | 249 | // Return name |
| ... | ... | @@ -247,6 +253,8 @@ std::string GModelRadialRegistry::name(const int& index) const |
| 247 | 253 | |
| 248 | 254 | /***********************************************************************//** |
| 249 | 255 | * @brief Print registry information |
| 256 | + * | |
| 257 | + * @return Registry content. | |
| 250 | 258 | ***************************************************************************/ |
| 251 | 259 | std::string GModelRadialRegistry::print(void) const |
| 252 | 260 | { |
| ... | ... | @@ -303,41 +311,3 @@ void GModelRadialRegistry::free_members(void) |
| 303 | 311 | // Return |
| 304 | 312 | return; |
| 305 | 313 | } |
| 306 | - | |
| 307 | - | |
| 308 | -/*========================================================================== | |
| 309 | - = = | |
| 310 | - = Friends = | |
| 311 | - = = | |
| 312 | - ==========================================================================*/ | |
| 313 | - | |
| 314 | -/***********************************************************************//** | |
| 315 | - * @brief Output operator | |
| 316 | - * | |
| 317 | - * @param[in] os Output stream. | |
| 318 | - * @param[in] registry Radial spatial model registry. | |
| 319 | - ***************************************************************************/ | |
| 320 | -std::ostream& operator<< (std::ostream& os, const GModelRadialRegistry& registry) | |
| 321 | -{ | |
| 322 | - // Write registry in output stream | |
| 323 | - os << registry.print(); | |
| 324 | - | |
| 325 | - // Return output stream | |
| 326 | - return os; | |
| 327 | -} | |
| 328 | - | |
| 329 | - | |
| 330 | -/***********************************************************************//** | |
| 331 | - * @brief Log operator | |
| 332 | - * | |
| 333 | - * @param[in] log Logger. | |
| 334 | - * @param[in] registry Radial spatial model registry. | |
| 335 | - ***************************************************************************/ | |
| 336 | -GLog& operator<< (GLog& log, const GModelRadialRegistry& registry) | |
| 337 | -{ | |
| 338 | - // Write registry into logger | |
| 339 | - log << registry.print(); | |
| 340 | - | |
| 341 | - // Return logger | |
| 342 | - return log; | |
| 343 | -} | ... | ... |
src/model/GModelRegistry.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * GModelRegistry.cpp - Spatial model registry class * | |
| 2 | + * GModelRegistry.cpp - Model registry class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2011-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -20,8 +20,8 @@ |
| 20 | 20 | ***************************************************************************/ |
| 21 | 21 | /** |
| 22 | 22 | * @file GModelRegistry.cpp |
| 23 | - * @brief GModelRegistry class interface definition | |
| 24 | - * @author J. Knodlseder | |
| 23 | + * @brief Model registry class implementation | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | /* __ Includes ___________________________________________________________ */ |
| ... | ... | @@ -65,8 +65,9 @@ GModelRegistry::GModelRegistry(void) |
| 65 | 65 | // Debug option: Show actual registry |
| 66 | 66 | #if G_DEBUG_REGISTRY |
| 67 | 67 | std::cout << "GModelRegistry(void): "; |
| 68 | - for (int i = 0; i < m_number; ++i) | |
| 68 | + for (int i = 0; i < m_number; ++i) { | |
| 69 | 69 | std::cout << "\"" << m_names[i] << "\" "; |
| 70 | + } | |
| 70 | 71 | std::cout << std::endl; |
| 71 | 72 | #endif |
| 72 | 73 | |
| ... | ... | @@ -77,6 +78,11 @@ GModelRegistry::GModelRegistry(void) |
| 77 | 78 | |
| 78 | 79 | /***********************************************************************//** |
| 79 | 80 | * @brief Model constructor |
| 81 | + * | |
| 82 | + * @param[in] model Model. | |
| 83 | + * | |
| 84 | + * Construct registry by adding a model to the registry. This is the standard | |
| 85 | + * constructor that is used to register a new model to GammaLib. | |
| 80 | 86 | ***************************************************************************/ |
| 81 | 87 | GModelRegistry::GModelRegistry(const GModel* model) |
| 82 | 88 | { |
| ... | ... | @@ -117,8 +123,9 @@ GModelRegistry::GModelRegistry(const GModel* model) |
| 117 | 123 | // Debug option: Show actual registry |
| 118 | 124 | #if G_DEBUG_REGISTRY |
| 119 | 125 | std::cout << "GModelRegistry(const GModel*): "; |
| 120 | - for (int i = 0; i < m_number; ++i) | |
| 126 | + for (int i = 0; i < m_number; ++i) { | |
| 121 | 127 | std::cout << "\"" << m_names[i] << "\" "; |
| 128 | + } | |
| 122 | 129 | std::cout << std::endl; |
| 123 | 130 | #endif |
| 124 | 131 | |
| ... | ... | @@ -168,6 +175,7 @@ GModelRegistry::~GModelRegistry(void) |
| 168 | 175 | * @brief Assignment operator |
| 169 | 176 | * |
| 170 | 177 | * @param[in] registry Registry. |
| 178 | + * @return Reference to registry. | |
| 171 | 179 | ***************************************************************************/ |
| 172 | 180 | GModelRegistry& GModelRegistry::operator= (const GModelRegistry& registry) |
| 173 | 181 | { |
| ... | ... | @@ -197,21 +205,22 @@ GModelRegistry& GModelRegistry::operator= (const GModelRegistry& registry) |
| 197 | 205 | ==========================================================================*/ |
| 198 | 206 | |
| 199 | 207 | /***********************************************************************//** |
| 200 | - * @brief Allocate model of given type | |
| 208 | + * @brief Allocate model of given name | |
| 201 | 209 | * |
| 202 | - * @param[in] type Model type. | |
| 210 | + * @param[in] name Model name. | |
| 211 | + * @return Pointer to model (NULL if name is not registered). | |
| 203 | 212 | * |
| 204 | - * Returns a pointer to a void model instance of the specified type. If the | |
| 205 | - * type has not been found in the registry, a NULL pointer is returned. | |
| 213 | + * Returns a pointer to a void model instance of the specified name. If the | |
| 214 | + * name has not been found in the registry, a NULL pointer is returned. | |
| 206 | 215 | ***************************************************************************/ |
| 207 | -GModel* GModelRegistry::alloc(const std::string& type) const | |
| 216 | +GModel* GModelRegistry::alloc(const std::string& name) const | |
| 208 | 217 | { |
| 209 | 218 | // Initialise model |
| 210 | 219 | GModel* model = NULL; |
| 211 | 220 | |
| 212 | 221 | // Search for model in registry |
| 213 | 222 | for (int i = 0; i < m_number; ++i) { |
| 214 | - if (m_names[i] == type) { | |
| 223 | + if (m_names[i] == name) { | |
| 215 | 224 | model = m_models[i]->clone(); |
| 216 | 225 | break; |
| 217 | 226 | } |
| ... | ... | @@ -226,6 +235,7 @@ GModel* GModelRegistry::alloc(const std::string& type) const |
| 226 | 235 | * @brief Returns model name |
| 227 | 236 | * |
| 228 | 237 | * @param[in] index Model index [0,...,size()-1]. |
| 238 | + * @return Model name. | |
| 229 | 239 | * |
| 230 | 240 | * @exception GException::out_of_range |
| 231 | 241 | * Model index is out of range. |
| ... | ... | @@ -234,8 +244,9 @@ std::string GModelRegistry::name(const int& index) const |
| 234 | 244 | { |
| 235 | 245 | // Compile option: raise exception if index is out of range |
| 236 | 246 | #if defined(G_RANGE_CHECK) |
| 237 | - if (index < 0 || index >= size()) | |
| 247 | + if (index < 0 || index >= size()) { | |
| 238 | 248 | throw GException::out_of_range(G_NAME, index, 0, size()-1); |
| 249 | + } | |
| 239 | 250 | #endif |
| 240 | 251 | |
| 241 | 252 | // Return name |
| ... | ... | @@ -245,6 +256,8 @@ std::string GModelRegistry::name(const int& index) const |
| 245 | 256 | |
| 246 | 257 | /***********************************************************************//** |
| 247 | 258 | * @brief Print registry information |
| 259 | + * | |
| 260 | + * @return Registry content. | |
| 248 | 261 | ***************************************************************************/ |
| 249 | 262 | std::string GModelRegistry::print(void) const |
| 250 | 263 | { |
| ... | ... | @@ -301,41 +314,3 @@ void GModelRegistry::free_members(void) |
| 301 | 314 | // Return |
| 302 | 315 | return; |
| 303 | 316 | } |
| 304 | - | |
| 305 | - | |
| 306 | -/*========================================================================== | |
| 307 | - = = | |
| 308 | - = Friends = | |
| 309 | - = = | |
| 310 | - ==========================================================================*/ | |
| 311 | - | |
| 312 | -/***********************************************************************//** | |
| 313 | - * @brief Output operator | |
| 314 | - * | |
| 315 | - * @param[in] os Output stream. | |
| 316 | - * @param[in] registry Model registry. | |
| 317 | - ***************************************************************************/ | |
| 318 | -std::ostream& operator<< (std::ostream& os, const GModelRegistry& registry) | |
| 319 | -{ | |
| 320 | - // Write registry in output stream | |
| 321 | - os << registry.print(); | |
| 322 | - | |
| 323 | - // Return output stream | |
| 324 | - return os; | |
| 325 | -} | |
| 326 | - | |
| 327 | - | |
| 328 | -/***********************************************************************//** | |
| 329 | - * @brief Log operator | |
| 330 | - * | |
| 331 | - * @param[in] log Logger. | |
| 332 | - * @param[in] registry Model registry. | |
| 333 | - ***************************************************************************/ | |
| 334 | -GLog& operator<< (GLog& log, const GModelRegistry& registry) | |
| 335 | -{ | |
| 336 | - // Write registry into logger | |
| 337 | - log << registry.print(); | |
| 338 | - | |
| 339 | - // Return logger | |
| 340 | - return log; | |
| 341 | -} | ... | ... |
src/model/GModelSpatialRegistry.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * GModelSpatialRegistry.cpp - Spatial model registry class * | |
| 2 | + * GModelSpatialRegistry.cpp - Spatial model registry class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2011-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -20,7 +20,7 @@ |
| 20 | 20 | ***************************************************************************/ |
| 21 | 21 | /** |
| 22 | 22 | * @file GModelSpatialRegistry.cpp |
| 23 | - * @brief GModelSpatialRegistry class interface definition | |
| 23 | + * @brief Spatial model registry class implemenation | |
| 24 | 24 | * @author J. Knodlseder |
| 25 | 25 | */ |
| 26 | 26 | |
| ... | ... | @@ -64,8 +64,9 @@ GModelSpatialRegistry::GModelSpatialRegistry(void) |
| 64 | 64 | // Debug option: Show actual registry |
| 65 | 65 | #if G_DEBUG_REGISTRY |
| 66 | 66 | std::cout << "GModelSpatialRegistry(void): "; |
| 67 | - for (int i = 0; i < m_number; ++i) | |
| 67 | + for (int i = 0; i < m_number; ++i) { | |
| 68 | 68 | std::cout << "\"" << m_names[i] << "\" "; |
| 69 | + } | |
| 69 | 70 | std::cout << std::endl; |
| 70 | 71 | #endif |
| 71 | 72 | |
| ... | ... | @@ -76,6 +77,11 @@ GModelSpatialRegistry::GModelSpatialRegistry(void) |
| 76 | 77 | |
| 77 | 78 | /***********************************************************************//** |
| 78 | 79 | * @brief Model constructor |
| 80 | + * | |
| 81 | + * @param[in] model Model. | |
| 82 | + * | |
| 83 | + * Construct registry by adding a model to the registry. This is the standard | |
| 84 | + * constructor that is used to register a new model to GammaLib. | |
| 79 | 85 | ***************************************************************************/ |
| 80 | 86 | GModelSpatialRegistry::GModelSpatialRegistry(const GModelSpatial* model) |
| 81 | 87 | { |
| ... | ... | @@ -116,8 +122,9 @@ GModelSpatialRegistry::GModelSpatialRegistry(const GModelSpatial* model) |
| 116 | 122 | // Debug option: Show actual registry |
| 117 | 123 | #if G_DEBUG_REGISTRY |
| 118 | 124 | std::cout << "GModelSpatialRegistry(const GModelSpatial*): "; |
| 119 | - for (int i = 0; i < m_number; ++i) | |
| 125 | + for (int i = 0; i < m_number; ++i) { | |
| 120 | 126 | std::cout << "\"" << m_names[i] << "\" "; |
| 127 | + } | |
| 121 | 128 | std::cout << std::endl; |
| 122 | 129 | #endif |
| 123 | 130 | |
| ... | ... | @@ -167,6 +174,7 @@ GModelSpatialRegistry::~GModelSpatialRegistry(void) |
| 167 | 174 | * @brief Assignment operator |
| 168 | 175 | * |
| 169 | 176 | * @param[in] registry Registry. |
| 177 | + * @return Reference to registry. | |
| 170 | 178 | ***************************************************************************/ |
| 171 | 179 | GModelSpatialRegistry& GModelSpatialRegistry::operator= (const GModelSpatialRegistry& registry) |
| 172 | 180 | { |
| ... | ... | @@ -196,22 +204,23 @@ GModelSpatialRegistry& GModelSpatialRegistry::operator= (const GModelSpatialRegi |
| 196 | 204 | ==========================================================================*/ |
| 197 | 205 | |
| 198 | 206 | /***********************************************************************//** |
| 199 | - * @brief Allocate spatial model of given type | |
| 207 | + * @brief Allocate spatial model of given name | |
| 200 | 208 | * |
| 201 | - * @param[in] type Spatial model type. | |
| 209 | + * @param[in] name Model name. | |
| 210 | + * @return Pointer to model (NULL if name is not registered). | |
| 202 | 211 | * |
| 203 | 212 | * Returns a pointer to a void spatial model instance of the specified |
| 204 | - * type. If the type has not been found in the registry, a NULL pointer is | |
| 213 | + * name. If the name has not been found in the registry, a NULL pointer is | |
| 205 | 214 | * returned. |
| 206 | 215 | ***************************************************************************/ |
| 207 | -GModelSpatial* GModelSpatialRegistry::alloc(const std::string& type) const | |
| 216 | +GModelSpatial* GModelSpatialRegistry::alloc(const std::string& name) const | |
| 208 | 217 | { |
| 209 | 218 | // Initialise spatial model |
| 210 | 219 | GModelSpatial* model = NULL; |
| 211 | 220 | |
| 212 | 221 | // Search for model in registry |
| 213 | 222 | for (int i = 0; i < m_number; ++i) { |
| 214 | - if (m_names[i] == type) { | |
| 223 | + if (m_names[i] == name) { | |
| 215 | 224 | model = m_models[i]->clone(); |
| 216 | 225 | break; |
| 217 | 226 | } |
| ... | ... | @@ -226,6 +235,7 @@ GModelSpatial* GModelSpatialRegistry::alloc(const std::string& type) const |
| 226 | 235 | * @brief Returns model name |
| 227 | 236 | * |
| 228 | 237 | * @param[in] index Model index [0,...,size()-1]. |
| 238 | + * @return Model name. | |
| 229 | 239 | * |
| 230 | 240 | * @exception GException::out_of_range |
| 231 | 241 | * Model index is out of range. |
| ... | ... | @@ -234,8 +244,9 @@ std::string GModelSpatialRegistry::name(const int& index) const |
| 234 | 244 | { |
| 235 | 245 | // Compile option: raise exception if index is out of range |
| 236 | 246 | #if defined(G_RANGE_CHECK) |
| 237 | - if (index < 0 || index >= size()) | |
| 247 | + if (index < 0 || index >= size()) { | |
| 238 | 248 | throw GException::out_of_range(G_NAME, index, 0, size()-1); |
| 249 | + } | |
| 239 | 250 | #endif |
| 240 | 251 | |
| 241 | 252 | // Return name |
| ... | ... | @@ -245,6 +256,8 @@ std::string GModelSpatialRegistry::name(const int& index) const |
| 245 | 256 | |
| 246 | 257 | /***********************************************************************//** |
| 247 | 258 | * @brief Print registry information |
| 259 | + * | |
| 260 | + * @return Registry content. | |
| 248 | 261 | ***************************************************************************/ |
| 249 | 262 | std::string GModelSpatialRegistry::print(void) const |
| 250 | 263 | { |
| ... | ... | @@ -301,41 +314,3 @@ void GModelSpatialRegistry::free_members(void) |
| 301 | 314 | // Return |
| 302 | 315 | return; |
| 303 | 316 | } |
| 304 | - | |
| 305 | - | |
| 306 | -/*========================================================================== | |
| 307 | - = = | |
| 308 | - = Friends = | |
| 309 | - = = | |
| 310 | - ==========================================================================*/ | |
| 311 | - | |
| 312 | -/***********************************************************************//** | |
| 313 | - * @brief Output operator | |
| 314 | - * | |
| 315 | - * @param[in] os Output stream. | |
| 316 | - * @param[in] registry Spatial model registry. | |
| 317 | - ***************************************************************************/ | |
| 318 | -std::ostream& operator<< (std::ostream& os, const GModelSpatialRegistry& registry) | |
| 319 | -{ | |
| 320 | - // Write registry in output stream | |
| 321 | - os << registry.print(); | |
| 322 | - | |
| 323 | - // Return output stream | |
| 324 | - return os; | |
| 325 | -} | |
| 326 | - | |
| 327 | - | |
| 328 | -/***********************************************************************//** | |
| 329 | - * @brief Log operator | |
| 330 | - * | |
| 331 | - * @param[in] log Logger. | |
| 332 | - * @param[in] registry Spatial model registry. | |
| 333 | - ***************************************************************************/ | |
| 334 | -GLog& operator<< (GLog& log, const GModelSpatialRegistry& registry) | |
| 335 | -{ | |
| 336 | - // Write registry into logger | |
| 337 | - log << registry.print(); | |
| 338 | - | |
| 339 | - // Return logger | |
| 340 | - return log; | |
| 341 | -} | ... | ... |
src/model/GModelSpectralRegistry.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * GModelSpectralRegistry.cpp - Spectral model registry class * | |
| 2 | + * GModelSpectralRegistry.cpp - Spectral model registry class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2011-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -20,8 +20,8 @@ |
| 20 | 20 | ***************************************************************************/ |
| 21 | 21 | /** |
| 22 | 22 | * @file GModelSpectralRegistry.cpp |
| 23 | - * @brief GModelSpectralRegistry class interface definition | |
| 24 | - * @author J. Knodlseder | |
| 23 | + * @brief Spectral model registry class implementation | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | /* __ Includes ___________________________________________________________ */ |
| ... | ... | @@ -77,6 +77,8 @@ GModelSpectralRegistry::GModelSpectralRegistry(void) |
| 77 | 77 | |
| 78 | 78 | /***********************************************************************//** |
| 79 | 79 | * @brief Model constructor |
| 80 | + * | |
| 81 | + * @param[in] model Model. | |
| 80 | 82 | ***************************************************************************/ |
| 81 | 83 | GModelSpectralRegistry::GModelSpectralRegistry(const GModelSpectral* model) |
| 82 | 84 | { |
| ... | ... | @@ -117,8 +119,9 @@ GModelSpectralRegistry::GModelSpectralRegistry(const GModelSpectral* model) |
| 117 | 119 | // Debug option: Show actual registry |
| 118 | 120 | #if G_DEBUG_REGISTRY |
| 119 | 121 | std::cout << "GModelSpectralRegistry(const GModelSpatial*): "; |
| 120 | - for (int i = 0; i < m_number; ++i) | |
| 122 | + for (int i = 0; i < m_number; ++i) { | |
| 121 | 123 | std::cout << "\"" << m_names[i] << "\" "; |
| 124 | + } | |
| 122 | 125 | std::cout << std::endl; |
| 123 | 126 | #endif |
| 124 | 127 | |
| ... | ... | @@ -168,6 +171,7 @@ GModelSpectralRegistry::~GModelSpectralRegistry(void) |
| 168 | 171 | * @brief Assignment operator |
| 169 | 172 | * |
| 170 | 173 | * @param[in] registry Registry. |
| 174 | + * @return Reference to registry. | |
| 171 | 175 | ***************************************************************************/ |
| 172 | 176 | GModelSpectralRegistry& GModelSpectralRegistry::operator= (const GModelSpectralRegistry& registry) |
| 173 | 177 | { |
| ... | ... | @@ -197,22 +201,23 @@ GModelSpectralRegistry& GModelSpectralRegistry::operator= (const GModelSpectralR |
| 197 | 201 | ==========================================================================*/ |
| 198 | 202 | |
| 199 | 203 | /***********************************************************************//** |
| 200 | - * @brief Allocate spectral model of given type | |
| 204 | + * @brief Allocate spectral model of given name | |
| 201 | 205 | * |
| 202 | - * @param[in] type Spectral model type. | |
| 206 | + * @param[in] name Spectral model name. | |
| 207 | + * @return Pointer to spectral model (NULL if name is not registered). | |
| 203 | 208 | * |
| 204 | - * Returns a pointer to a void spectral model instance of the specified | |
| 205 | - * type. If the type has not been found in the registry, a NULL pointer is | |
| 209 | + * Returns a pointer to a spectral model instance of the specified name. | |
| 210 | + * If the name has not been found in the registry, a NULL pointer is | |
| 206 | 211 | * returned. |
| 207 | 212 | ***************************************************************************/ |
| 208 | -GModelSpectral* GModelSpectralRegistry::alloc(const std::string& type) const | |
| 213 | +GModelSpectral* GModelSpectralRegistry::alloc(const std::string& name) const | |
| 209 | 214 | { |
| 210 | 215 | // Initialise spectral model |
| 211 | 216 | GModelSpectral* model = NULL; |
| 212 | 217 | |
| 213 | 218 | // Search for model in registry |
| 214 | 219 | for (int i = 0; i < m_number; ++i) { |
| 215 | - if (m_names[i] == type) { | |
| 220 | + if (m_names[i] == name) { | |
| 216 | 221 | model = m_models[i]->clone(); |
| 217 | 222 | break; |
| 218 | 223 | } |
| ... | ... | @@ -227,6 +232,7 @@ GModelSpectral* GModelSpectralRegistry::alloc(const std::string& type) const |
| 227 | 232 | * @brief Returns model name |
| 228 | 233 | * |
| 229 | 234 | * @param[in] index Model index [0,...,size()-1]. |
| 235 | + * @return Model name. | |
| 230 | 236 | * |
| 231 | 237 | * @exception GException::out_of_range |
| 232 | 238 | * Model index is out of range. |
| ... | ... | @@ -235,8 +241,9 @@ std::string GModelSpectralRegistry::name(const int& index) const |
| 235 | 241 | { |
| 236 | 242 | // Compile option: raise exception if index is out of range |
| 237 | 243 | #if defined(G_RANGE_CHECK) |
| 238 | - if (index < 0 || index >= size()) | |
| 244 | + if (index < 0 || index >= size()) { | |
| 239 | 245 | throw GException::out_of_range(G_NAME, index, 0, size()-1); |
| 246 | + } | |
| 240 | 247 | #endif |
| 241 | 248 | |
| 242 | 249 | // Return name |
| ... | ... | @@ -246,6 +253,8 @@ std::string GModelSpectralRegistry::name(const int& index) const |
| 246 | 253 | |
| 247 | 254 | /***********************************************************************//** |
| 248 | 255 | * @brief Print registry information |
| 256 | + * | |
| 257 | + * @return Registry content. | |
| 249 | 258 | ***************************************************************************/ |
| 250 | 259 | std::string GModelSpectralRegistry::print(void) const |
| 251 | 260 | { |
| ... | ... | @@ -302,41 +311,3 @@ void GModelSpectralRegistry::free_members(void) |
| 302 | 311 | // Return |
| 303 | 312 | return; |
| 304 | 313 | } |
| 305 | - | |
| 306 | - | |
| 307 | -/*========================================================================== | |
| 308 | - = = | |
| 309 | - = Friends = | |
| 310 | - = = | |
| 311 | - ==========================================================================*/ | |
| 312 | - | |
| 313 | -/***********************************************************************//** | |
| 314 | - * @brief Output operator | |
| 315 | - * | |
| 316 | - * @param[in] os Output stream. | |
| 317 | - * @param[in] registry Spectral model registry. | |
| 318 | - ***************************************************************************/ | |
| 319 | -std::ostream& operator<< (std::ostream& os, const GModelSpectralRegistry& registry) | |
| 320 | -{ | |
| 321 | - // Write registry in output stream | |
| 322 | - os << registry.print(); | |
| 323 | - | |
| 324 | - // Return output stream | |
| 325 | - return os; | |
| 326 | -} | |
| 327 | - | |
| 328 | - | |
| 329 | -/***********************************************************************//** | |
| 330 | - * @brief Log operator | |
| 331 | - * | |
| 332 | - * @param[in] log Logger. | |
| 333 | - * @param[in] registry Spectral model registry. | |
| 334 | - ***************************************************************************/ | |
| 335 | -GLog& operator<< (GLog& log, const GModelSpectralRegistry& registry) | |
| 336 | -{ | |
| 337 | - // Write registry into logger | |
| 338 | - log << registry.print(); | |
| 339 | - | |
| 340 | - // Return logger | |
| 341 | - return log; | |
| 342 | -} | ... | ... |
src/model/GModelTemporalRegistry.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * GModelTemporalRegistry.cpp - Temporal model registry class * | |
| 2 | + * GModelTemporalRegistry.cpp - Temporal model registry class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2011-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -20,8 +20,8 @@ |
| 20 | 20 | ***************************************************************************/ |
| 21 | 21 | /** |
| 22 | 22 | * @file GModelTemporalRegistry.cpp |
| 23 | - * @brief GModelTemporalRegistry class interface definition | |
| 24 | - * @author J. Knodlseder | |
| 23 | + * @brief Temporal model registry class implementation | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | /* __ Includes ___________________________________________________________ */ |
| ... | ... | @@ -77,6 +77,8 @@ GModelTemporalRegistry::GModelTemporalRegistry(void) |
| 77 | 77 | |
| 78 | 78 | /***********************************************************************//** |
| 79 | 79 | * @brief Model constructor |
| 80 | + * | |
| 81 | + * @param[in] model Model. | |
| 80 | 82 | ***************************************************************************/ |
| 81 | 83 | GModelTemporalRegistry::GModelTemporalRegistry(const GModelTemporal* model) |
| 82 | 84 | { |
| ... | ... | @@ -117,8 +119,9 @@ GModelTemporalRegistry::GModelTemporalRegistry(const GModelTemporal* model) |
| 117 | 119 | // Debug option: Show actual registry |
| 118 | 120 | #if G_DEBUG_REGISTRY |
| 119 | 121 | std::cout << "GModelTemporalRegistry(const GModelTemporal*): "; |
| 120 | - for (int i = 0; i < m_number; ++i) | |
| 122 | + for (int i = 0; i < m_number; ++i) { | |
| 121 | 123 | std::cout << "\"" << m_names[i] << "\" "; |
| 124 | + } | |
| 122 | 125 | std::cout << std::endl; |
| 123 | 126 | #endif |
| 124 | 127 | |
| ... | ... | @@ -168,6 +171,7 @@ GModelTemporalRegistry::~GModelTemporalRegistry(void) |
| 168 | 171 | * @brief Assignment operator |
| 169 | 172 | * |
| 170 | 173 | * @param[in] registry Registry. |
| 174 | + * @return Reference to registry. | |
| 171 | 175 | ***************************************************************************/ |
| 172 | 176 | GModelTemporalRegistry& GModelTemporalRegistry::operator= (const GModelTemporalRegistry& registry) |
| 173 | 177 | { |
| ... | ... | @@ -197,22 +201,23 @@ GModelTemporalRegistry& GModelTemporalRegistry::operator= (const GModelTemporalR |
| 197 | 201 | ==========================================================================*/ |
| 198 | 202 | |
| 199 | 203 | /***********************************************************************//** |
| 200 | - * @brief Allocate temporal model of given type | |
| 204 | + * @brief Allocate temporal model of given name | |
| 201 | 205 | * |
| 202 | - * @param[in] type Temporal model type. | |
| 206 | + * @param[in] name Temporal model name. | |
| 207 | + * @return Pointer to temporal model (NULL if name is not registered). | |
| 203 | 208 | * |
| 204 | - * Returns a pointer to a void temporal model instance of the specified | |
| 205 | - * type. If the type has not been found in the registry, a NULL pointer is | |
| 209 | + * Returns a pointer to a temporal model instance of the specified name. | |
| 210 | + * If the name has not been found in the registry, a NULL pointer is | |
| 206 | 211 | * returned. |
| 207 | 212 | ***************************************************************************/ |
| 208 | -GModelTemporal* GModelTemporalRegistry::alloc(const std::string& type) const | |
| 213 | +GModelTemporal* GModelTemporalRegistry::alloc(const std::string& name) const | |
| 209 | 214 | { |
| 210 | 215 | // Initialise temporal model |
| 211 | 216 | GModelTemporal* model = NULL; |
| 212 | 217 | |
| 213 | 218 | // Search for model in registry |
| 214 | 219 | for (int i = 0; i < m_number; ++i) { |
| 215 | - if (m_names[i] == type) { | |
| 220 | + if (m_names[i] == name) { | |
| 216 | 221 | model = m_models[i]->clone(); |
| 217 | 222 | break; |
| 218 | 223 | } |
| ... | ... | @@ -227,6 +232,7 @@ GModelTemporal* GModelTemporalRegistry::alloc(const std::string& type) const |
| 227 | 232 | * @brief Returns model name |
| 228 | 233 | * |
| 229 | 234 | * @param[in] index Model index [0,...,size()-1]. |
| 235 | + * @return Model name. | |
| 230 | 236 | * |
| 231 | 237 | * @exception GException::out_of_range |
| 232 | 238 | * Model index is out of range. |
| ... | ... | @@ -235,8 +241,9 @@ std::string GModelTemporalRegistry::name(const int& index) const |
| 235 | 241 | { |
| 236 | 242 | // Compile option: raise exception if index is out of range |
| 237 | 243 | #if defined(G_RANGE_CHECK) |
| 238 | - if (index < 0 || index >= size()) | |
| 244 | + if (index < 0 || index >= size()) { | |
| 239 | 245 | throw GException::out_of_range(G_NAME, index, 0, size()-1); |
| 246 | + } | |
| 240 | 247 | #endif |
| 241 | 248 | |
| 242 | 249 | // Return name |
| ... | ... | @@ -246,6 +253,8 @@ std::string GModelTemporalRegistry::name(const int& index) const |
| 246 | 253 | |
| 247 | 254 | /***********************************************************************//** |
| 248 | 255 | * @brief Print registry information |
| 256 | + * | |
| 257 | + * @return Registry content. | |
| 249 | 258 | ***************************************************************************/ |
| 250 | 259 | std::string GModelTemporalRegistry::print(void) const |
| 251 | 260 | { |
| ... | ... | @@ -302,41 +311,3 @@ void GModelTemporalRegistry::free_members(void) |
| 302 | 311 | // Return |
| 303 | 312 | return; |
| 304 | 313 | } |
| 305 | - | |
| 306 | - | |
| 307 | -/*========================================================================== | |
| 308 | - = = | |
| 309 | - = Friends = | |
| 310 | - = = | |
| 311 | - ==========================================================================*/ | |
| 312 | - | |
| 313 | -/***********************************************************************//** | |
| 314 | - * @brief Output operator | |
| 315 | - * | |
| 316 | - * @param[in] os Output stream. | |
| 317 | - * @param[in] registry Temporal model registry. | |
| 318 | - ***************************************************************************/ | |
| 319 | -std::ostream& operator<< (std::ostream& os, const GModelTemporalRegistry& registry) | |
| 320 | -{ | |
| 321 | - // Write registry in output stream | |
| 322 | - os << registry.print(); | |
| 323 | - | |
| 324 | - // Return output stream | |
| 325 | - return os; | |
| 326 | -} | |
| 327 | - | |
| 328 | - | |
| 329 | -/***********************************************************************//** | |
| 330 | - * @brief Log operator | |
| 331 | - * | |
| 332 | - * @param[in] log Logger. | |
| 333 | - * @param[in] registry Temporal model registry. | |
| 334 | - ***************************************************************************/ | |
| 335 | -GLog& operator<< (GLog& log, const GModelTemporalRegistry& registry) | |
| 336 | -{ | |
| 337 | - // Write registry into logger | |
| 338 | - log << registry.print(); | |
| 339 | - | |
| 340 | - // Return logger | |
| 341 | - return log; | |
| 342 | -} | ... | ... |
src/obs/GException_obs.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GException_obs.cpp - observations exception handlers * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2011 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GException_obs.cpp |
| 23 | 23 | * @brief Observation exception handler interface implementation |
| 24 | - * @author J. Knoedlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | /* __ Includes ___________________________________________________________ */ |
| ... | ... | @@ -320,7 +320,7 @@ GException::invalid_instrument::invalid_instrument(std::string origin, |
| 320 | 320 | if (i > 0) { |
| 321 | 321 | m_message += ", "; |
| 322 | 322 | } |
| 323 | - m_message += "\"" + registry.instrument(i) + "\""; | |
| 323 | + m_message += "\"" + registry.name(i) + "\""; | |
| 324 | 324 | } |
| 325 | 325 | m_message += "."; |
| 326 | 326 | } | ... | ... |
src/obs/GObservationRegistry.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * GObservationRegistry.cpp - Observation registry class * | |
| 2 | + * GObservationRegistry.cpp - Observation registry class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2011-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -20,8 +20,8 @@ |
| 20 | 20 | ***************************************************************************/ |
| 21 | 21 | /** |
| 22 | 22 | * @file GObservationRegistry.cpp |
| 23 | - * @brief GObservationRegistry class interface implementation | |
| 24 | - * @author J. Knoedlseder | |
| 23 | + * @brief Observation registry class definition | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | /* __ Includes ___________________________________________________________ */ |
| ... | ... | @@ -77,6 +77,8 @@ GObservationRegistry::GObservationRegistry(void) |
| 77 | 77 | |
| 78 | 78 | /***********************************************************************//** |
| 79 | 79 | * @brief Observation constructor |
| 80 | + * | |
| 81 | + * @param[in] obs Observation. | |
| 80 | 82 | ***************************************************************************/ |
| 81 | 83 | GObservationRegistry::GObservationRegistry(const GObservation* obs) |
| 82 | 84 | { |
| ... | ... | @@ -169,6 +171,7 @@ GObservationRegistry::~GObservationRegistry(void) |
| 169 | 171 | * @brief Assignment operator |
| 170 | 172 | * |
| 171 | 173 | * @param[in] registry Registry. |
| 174 | + * @return Reference to registry. | |
| 172 | 175 | ***************************************************************************/ |
| 173 | 176 | GObservationRegistry& GObservationRegistry::operator= (const GObservationRegistry& registry) |
| 174 | 177 | { |
| ... | ... | @@ -198,22 +201,23 @@ GObservationRegistry& GObservationRegistry::operator= (const GObservationRegistr |
| 198 | 201 | ==========================================================================*/ |
| 199 | 202 | |
| 200 | 203 | /***********************************************************************//** |
| 201 | - * @brief Allocate observation of given type | |
| 204 | + * @brief Allocate observation of given name | |
| 202 | 205 | * |
| 203 | - * @param[in] instrument Instrument name. | |
| 206 | + * @param[in] name Instrument name. | |
| 207 | + * @return Pointer to observation (NULL if name is not registered). | |
| 204 | 208 | * |
| 205 | - * Returns a pointer to a void observation instance for a specific | |
| 206 | - * instrument. If the instrument has not been found in the registry, a NULL | |
| 209 | + * Returns a pointer to an observation instance for a specific name. | |
| 210 | + * If the instrument name has not been found in the registry, a NULL | |
| 207 | 211 | * pointer is returned. |
| 208 | 212 | ***************************************************************************/ |
| 209 | -GObservation* GObservationRegistry::alloc(const std::string& instrument) const | |
| 213 | +GObservation* GObservationRegistry::alloc(const std::string& name) const | |
| 210 | 214 | { |
| 211 | 215 | // Initialise observation |
| 212 | 216 | GObservation* obs = NULL; |
| 213 | 217 | |
| 214 | 218 | // Search for observation in registry |
| 215 | 219 | for (int i = 0; i < m_number; ++i) { |
| 216 | - if (m_names[i] == instrument) { | |
| 220 | + if (m_names[i] == name) { | |
| 217 | 221 | obs = m_obs[i]->clone(); |
| 218 | 222 | break; |
| 219 | 223 | } |
| ... | ... | @@ -228,11 +232,12 @@ GObservation* GObservationRegistry::alloc(const std::string& instrument) const |
| 228 | 232 | * @brief Returns instrument name for a specific registered observation |
| 229 | 233 | * |
| 230 | 234 | * @param[in] index Observation index [0,...,size()-1]. |
| 235 | + * @return Instrument name. | |
| 231 | 236 | * |
| 232 | 237 | * @exception GException::out_of_range |
| 233 | 238 | * Observation index is out of range. |
| 234 | 239 | ***************************************************************************/ |
| 235 | -std::string GObservationRegistry::instrument(const int& index) const | |
| 240 | +std::string GObservationRegistry::name(const int& index) const | |
| 236 | 241 | { |
| 237 | 242 | // Compile option: raise exception if index is out of range |
| 238 | 243 | #if defined(G_RANGE_CHECK) |
| ... | ... | @@ -248,6 +253,8 @@ std::string GObservationRegistry::instrument(const int& index) const |
| 248 | 253 | |
| 249 | 254 | /***********************************************************************//** |
| 250 | 255 | * @brief Print registry information |
| 256 | + * | |
| 257 | + * @return Registry content. | |
| 251 | 258 | ***************************************************************************/ |
| 252 | 259 | std::string GObservationRegistry::print(void) const |
| 253 | 260 | { |
| ... | ... | @@ -304,41 +311,3 @@ void GObservationRegistry::free_members(void) |
| 304 | 311 | // Return |
| 305 | 312 | return; |
| 306 | 313 | } |
| 307 | - | |
| 308 | - | |
| 309 | -/*========================================================================== | |
| 310 | - = = | |
| 311 | - = Friends = | |
| 312 | - = = | |
| 313 | - ==========================================================================*/ | |
| 314 | - | |
| 315 | -/***********************************************************************//** | |
| 316 | - * @brief Output operator | |
| 317 | - * | |
| 318 | - * @param[in] os Output stream. | |
| 319 | - * @param[in] registry Observation registry. | |
| 320 | - ***************************************************************************/ | |
| 321 | -std::ostream& operator<< (std::ostream& os, const GObservationRegistry& registry) | |
| 322 | -{ | |
| 323 | - // Write registry in output stream | |
| 324 | - os << registry.print(); | |
| 325 | - | |
| 326 | - // Return output stream | |
| 327 | - return os; | |
| 328 | -} | |
| 329 | - | |
| 330 | - | |
| 331 | -/***********************************************************************//** | |
| 332 | - * @brief Log operator | |
| 333 | - * | |
| 334 | - * @param[in] log Logger. | |
| 335 | - * @param[in] registry Observation registry. | |
| 336 | - ***************************************************************************/ | |
| 337 | -GLog& operator<< (GLog& log, const GObservationRegistry& registry) | |
| 338 | -{ | |
| 339 | - // Write registry into logger | |
| 340 | - log << registry.print(); | |
| 341 | - | |
| 342 | - // Return logger | |
| 343 | - return log; | |
| 344 | -} | ... | ... |
src/sky/GWcsRegistry.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | - * GWcsRegistry.cpp - World Coordinate Projection registry class * | |
| 2 | + * GWcsRegistry.cpp - World Coordinate Projection registry class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2011-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GWcsRegistry.cpp |
| 23 | 23 | * @brief World Coordinate Projection registry class interface implementation |
| 24 | - * @author J. Knodlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | /* __ Includes ___________________________________________________________ */ |
| ... | ... | @@ -125,8 +125,9 @@ GWcsRegistry::GWcsRegistry(const GWcs* prj) |
| 125 | 125 | // Debug option: Show actual registry |
| 126 | 126 | #if G_DEBUG_REGISTRY |
| 127 | 127 | std::cout << "GWcsRegistry(const GWcs*): "; |
| 128 | - for (int i = 0; i < m_number; ++i) | |
| 128 | + for (int i = 0; i < m_number; ++i) { | |
| 129 | 129 | std::cout << "\"" << m_codes[i] << "\" "; |
| 130 | + } | |
| 130 | 131 | std::cout << std::endl; |
| 131 | 132 | #endif |
| 132 | 133 | |
| ... | ... | @@ -176,6 +177,7 @@ GWcsRegistry::~GWcsRegistry(void) |
| 176 | 177 | * @brief Assignment operator |
| 177 | 178 | * |
| 178 | 179 | * @param[in] registry Registry. |
| 180 | + * @return Reference to registry. | |
| 179 | 181 | ***************************************************************************/ |
| 180 | 182 | GWcsRegistry& GWcsRegistry::operator= (const GWcsRegistry& registry) |
| 181 | 183 | { |
| ... | ... | @@ -208,9 +210,10 @@ GWcsRegistry& GWcsRegistry::operator= (const GWcsRegistry& registry) |
| 208 | 210 | * @brief Allocate World Coordinate projection of given code |
| 209 | 211 | * |
| 210 | 212 | * @param[in] code World Coordinate System code. |
| 213 | + * @return Pointer to WCS (NULL if code is not registered). | |
| 211 | 214 | * |
| 212 | - * Returns a pointer to a void WCS instance of the specified code. If the | |
| 213 | - * code has not been found in the registry, a NULL pointer is returned. | |
| 215 | + * Returns a pointer to a WCS instance of the specified code. If the code has | |
| 216 | + * not been found in the registry, a NULL pointer is returned. | |
| 214 | 217 | ***************************************************************************/ |
| 215 | 218 | GWcs* GWcsRegistry::alloc(const std::string& code) const |
| 216 | 219 | { |
| ... | ... | @@ -234,6 +237,7 @@ GWcs* GWcsRegistry::alloc(const std::string& code) const |
| 234 | 237 | * @brief Returns projection code |
| 235 | 238 | * |
| 236 | 239 | * @param[in] index Projection index [0,...,size()-1]. |
| 240 | + * @return Projection code. | |
| 237 | 241 | * |
| 238 | 242 | * @exception GException::out_of_range |
| 239 | 243 | * Projection index is out of range. |
| ... | ... | @@ -242,8 +246,9 @@ std::string GWcsRegistry::code(const int& index) const |
| 242 | 246 | { |
| 243 | 247 | // Compile option: raise exception if index is out of range |
| 244 | 248 | #if defined(G_RANGE_CHECK) |
| 245 | - if (index < 0 || index >= size()) | |
| 249 | + if (index < 0 || index >= size()) { | |
| 246 | 250 | throw GException::out_of_range(G_CODE, index, 0, size()-1); |
| 251 | + } | |
| 247 | 252 | #endif |
| 248 | 253 | |
| 249 | 254 | // Return code |
| ... | ... | @@ -255,6 +260,7 @@ std::string GWcsRegistry::code(const int& index) const |
| 255 | 260 | * @brief Returns projection name |
| 256 | 261 | * |
| 257 | 262 | * @param[in] index Projection index [0,...,size()-1]. |
| 263 | + * @return Projection name. | |
| 258 | 264 | * |
| 259 | 265 | * @exception GException::out_of_range |
| 260 | 266 | * Projection index is out of range. |
| ... | ... | @@ -263,8 +269,9 @@ std::string GWcsRegistry::name(const int& index) const |
| 263 | 269 | { |
| 264 | 270 | // Compile option: raise exception if index is out of range |
| 265 | 271 | #if defined(G_RANGE_CHECK) |
| 266 | - if (index < 0 || index >= size()) | |
| 272 | + if (index < 0 || index >= size()) { | |
| 267 | 273 | throw GException::out_of_range(G_NAME, index, 0, size()-1); |
| 274 | + } | |
| 268 | 275 | #endif |
| 269 | 276 | |
| 270 | 277 | // Return name |
| ... | ... | @@ -275,6 +282,8 @@ std::string GWcsRegistry::name(const int& index) const |
| 275 | 282 | /***********************************************************************//** |
| 276 | 283 | * @brief Return list string of projection codes |
| 277 | 284 | * |
| 285 | + * @return Projection code list. | |
| 286 | + * | |
| 278 | 287 | * Returns a list of the projection codes in the format 'xxx/yyy/zzz'. |
| 279 | 288 | ***************************************************************************/ |
| 280 | 289 | std::string GWcsRegistry::list(void) const |
| ... | ... | @@ -284,8 +293,9 @@ std::string GWcsRegistry::list(void) const |
| 284 | 293 | |
| 285 | 294 | // Append projections |
| 286 | 295 | for (int i = 0; i < m_number; ++i) { |
| 287 | - if (i > 0) | |
| 296 | + if (i > 0) { | |
| 288 | 297 | result.append("/"); |
| 298 | + } | |
| 289 | 299 | result.append(m_codes[i]); |
| 290 | 300 | } |
| 291 | 301 | |
| ... | ... | @@ -296,6 +306,8 @@ std::string GWcsRegistry::list(void) const |
| 296 | 306 | |
| 297 | 307 | /***********************************************************************//** |
| 298 | 308 | * @brief Print registry information |
| 309 | + * | |
| 310 | + * @return Registry content. | |
| 299 | 311 | ***************************************************************************/ |
| 300 | 312 | std::string GWcsRegistry::print(void) const |
| 301 | 313 | { |
| ... | ... | @@ -353,41 +365,3 @@ void GWcsRegistry::free_members(void) |
| 353 | 365 | // Return |
| 354 | 366 | return; |
| 355 | 367 | } |
| 356 | - | |
| 357 | - | |
| 358 | -/*========================================================================== | |
| 359 | - = = | |
| 360 | - = Friends = | |
| 361 | - = = | |
| 362 | - ==========================================================================*/ | |
| 363 | - | |
| 364 | -/***********************************************************************//** | |
| 365 | - * @brief Output operator | |
| 366 | - * | |
| 367 | - * @param[in] os Output stream. | |
| 368 | - * @param[in] registry WCS projection registry. | |
| 369 | - ***************************************************************************/ | |
| 370 | -std::ostream& operator<< (std::ostream& os, const GWcsRegistry& registry) | |
| 371 | -{ | |
| 372 | - // Write registry in output stream | |
| 373 | - os << registry.print(); | |
| 374 | - | |
| 375 | - // Return output stream | |
| 376 | - return os; | |
| 377 | -} | |
| 378 | - | |
| 379 | - | |
| 380 | -/***********************************************************************//** | |
| 381 | - * @brief Log operator | |
| 382 | - * | |
| 383 | - * @param[in] log Logger. | |
| 384 | - * @param[in] registry WCS projection registry. | |
| 385 | - ***************************************************************************/ | |
| 386 | -GLog& operator<< (GLog& log, const GWcsRegistry& registry) | |
| 387 | -{ | |
| 388 | - // Write registry into logger | |
| 389 | - log << registry.print(); | |
| 390 | - | |
| 391 | - // Return logger | |
| 392 | - return log; | |
| 393 | -} | ... | ... |