From 429bacc8489f7a24efb4635afe2da645c801e4a5 Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Wed, 20 Feb 2013 09:39:52 +0100 Subject: [PATCH] Replace pop() method by remove() method. --- include/GContainer.hpp | 15 +++++++-------- include/GEbounds.hpp | 2 +- include/GGti.hpp | 2 +- include/GModels.hpp | 4 ++-- include/GOptimizerPars.hpp | 2 +- pyext/GContainer.i | 18 ++---------------- pyext/GEbounds.i | 2 +- pyext/GGti.i | 2 +- pyext/GModels.i | 4 ++-- pyext/GOptimizerPars.i | 3 +-- src/model/GModels.cpp | 14 +++++++------- src/obs/GEbounds.cpp | 6 +++--- src/obs/GGti.cpp | 6 +++--- test/test_GObservation.cpp | 4 ++-- 14 files changed, 34 insertions(+), 50 deletions(-) diff --git a/include/GContainer.hpp b/include/GContainer.hpp index 6922229..87e231c 100644 --- a/include/GContainer.hpp +++ b/include/GContainer.hpp @@ -37,16 +37,15 @@ * @brief Interface class for container classes * * This class defines the interface for container classes. The usage of the - * interface class imposes on all container classes to implement the following - * methods: + * interface class imposes on all container classes are coherent interface. + * The following methods are mandatory: * * clear - Clear container (inherited from GBase) * clone - Clones container (inherited from GBase) * print - Print container content (inherited from GBase) - * * size - Returns number of objects is container - * isempty - Signals if container is empty - * pop - Removes an object from the container + * isempty - Checks if container is empty + * remove - Removes an object from the container * reserve - Reserves space in the container ***************************************************************************/ class GContainer : public GBase { @@ -71,14 +70,14 @@ public: /// /// @param[in] index Index. /// - /// Removes the object with the specified index from the container. - virtual void pop(const int& index) = 0; + /// Removes the object with the specified @p index from the container. + virtual void remove(const int& index) = 0; /// @brief Reserves space in the container /// /// @param[in] num Number of objects. /// - /// Reserves space for num objects in the container. + /// Reserves space for @p num objects in the container. virtual void reserve(const int& num) = 0; }; diff --git a/include/GEbounds.hpp b/include/GEbounds.hpp index cb36854..1214e0a 100644 --- a/include/GEbounds.hpp +++ b/include/GEbounds.hpp @@ -71,7 +71,7 @@ public: void insert(const GEnergy& emin, const GEnergy& emax); void merge(void); void merge(const GEnergy& emin, const GEnergy& emax); - void pop(const int& index); + void remove(const int& index); void reserve(const int& num); void extend(const GEbounds& ebds); void setlin(const int& num, const GEnergy& emin, const GEnergy& emax); diff --git a/include/GGti.hpp b/include/GGti.hpp index ef6920b..f967814 100644 --- a/include/GGti.hpp +++ b/include/GGti.hpp @@ -72,7 +72,7 @@ public: void merge(void); void merge(const GTime& tstart, const GTime& tstop); void reduce(const GTime& tstart, const GTime& tstop); - void pop(const int& index); + void remove(const int& index); void reserve(const int& num); void extend(const GGti& gti); void load(const std::string& filename, diff --git a/include/GModels.hpp b/include/GModels.hpp index a2317b2..3a0ea5d 100644 --- a/include/GModels.hpp +++ b/include/GModels.hpp @@ -85,8 +85,8 @@ public: void append(const GModel& model); void insert(const int& index, const GModel& model); void insert(const std::string& name, const GModel& model); - void pop(const int& index); - void pop(const std::string& name); + void remove(const int& index); + void remove(const std::string& name); void reserve(const int& num) { return m_models.reserve(num); } void extend(const GModels& models); void set(const int& index, const GModel& model); diff --git a/include/GOptimizerPars.hpp b/include/GOptimizerPars.hpp index 3d1f1fe..ff3b3a4 100644 --- a/include/GOptimizerPars.hpp +++ b/include/GOptimizerPars.hpp @@ -70,7 +70,7 @@ public: virtual GOptimizerPars* clone(void) const = 0; virtual int size(void) const = 0; virtual bool isempty(void) const = 0; - virtual void pop(const int& index) = 0; + virtual void remove(const int& index) = 0; virtual void reserve(const int& num) = 0; virtual std::string print(void) const = 0; diff --git a/pyext/GContainer.i b/pyext/GContainer.i index 4a459fa..93da602 100644 --- a/pyext/GContainer.i +++ b/pyext/GContainer.i @@ -26,7 +26,6 @@ %{ /* Put headers and other declarations here that are needed for compilation */ #include "GContainer.hpp" -#include "GTools.hpp" %} @@ -34,28 +33,15 @@ * @class GContainer * * @brief Interface class for container classes - * - * This class defines the interface for container classes. The usage of the - * interface class imposes on all container classes to implement the following - * methods: - * - * clear - Clear container (inherited from GBase) - * clone - Clones container (inherited from GBase) - * print - Print container content (inherited from GBase) - * - * size - Returns number of objects is container - * isempty - Signals if container is empty - * pop - Removes an object from the container - * reserve - Reserves space in the container ***************************************************************************/ class GContainer : public GBase { public: // Constructors and destructors virtual ~GContainer(void) {} - // Methods + // Pure virtual methods virtual int size(void) const = 0; virtual bool isempty(void) const = 0; - virtual void pop(const int& index) = 0; + virtual void remove(const int& index) = 0; virtual void reserve(const int& num) = 0; }; diff --git a/pyext/GEbounds.i b/pyext/GEbounds.i index 424c114..d965dc1 100644 --- a/pyext/GEbounds.i +++ b/pyext/GEbounds.i @@ -54,7 +54,7 @@ public: void insert(const GEnergy& emin, const GEnergy& emax); void merge(void); void merge(const GEnergy& emin, const GEnergy& emax); - void pop(const int& index); + void remove(const int& index); void reserve(const int& num); void extend(const GEbounds& ebds); void setlin(const int& num, const GEnergy& emin, const GEnergy& emax); diff --git a/pyext/GGti.i b/pyext/GGti.i index 1bd78a2..b65572c 100644 --- a/pyext/GGti.i +++ b/pyext/GGti.i @@ -53,7 +53,7 @@ public: void merge(void); void merge(const GTime& tstart, const GTime& tstop); void reduce(const GTime& tstart, const GTime& tstop); - void pop(const int& index); + void remove(const int& index); void reserve(const int& num); void extend(const GGti& gti); void load(const std::string& filename, diff --git a/pyext/GModels.i b/pyext/GModels.i index e992e15..1dff223 100644 --- a/pyext/GModels.i +++ b/pyext/GModels.i @@ -66,8 +66,8 @@ public: void append(const GModel& model); void insert(const int& index, const GModel& model); void insert(const std::string& name, const GModel& model); - void pop(const int& index); - void pop(const std::string& name); + void remove(const int& index); + void remove(const std::string& name); void reserve(const int& num); void extend(const GModels& models); void set(const int& index, const GModel& model); diff --git a/pyext/GOptimizerPars.i b/pyext/GOptimizerPars.i index 91334f4..1a41ed9 100644 --- a/pyext/GOptimizerPars.i +++ b/pyext/GOptimizerPars.i @@ -47,9 +47,8 @@ public: virtual GOptimizerPars* clone(void) const = 0; virtual int size(void) const = 0; virtual bool isempty(void) const = 0; - virtual void pop(const int& index) = 0; + virtual void remove(const int& index) = 0; virtual void reserve(const int& num) = 0; - virtual std::string print(void) const = 0; // Methods virtual int npars(void) const; diff --git a/src/model/GModels.cpp b/src/model/GModels.cpp index 0b09b35..5c78ba9 100644 --- a/src/model/GModels.cpp +++ b/src/model/GModels.cpp @@ -41,8 +41,8 @@ #define G_ACCESS2 "GModels::operator[](std::string&)" #define G_INSERT1 "GModels::insert(int&, GModel&)" #define G_INSERT2 "GModels::insert(std::string&, GModel&)" -#define G_POP1 "GModels::pop(int&)" -#define G_POP2 "GModels::pop(std::string&)" +#define G_REMOVE1 "GModels::remove(int&)" +#define G_REMOVE2 "GModels::remove(std::string&)" #define G_SET1 "GModels::set(int&, GModel&)" #define G_SET2 "GModels::set(std::string&, GModel&)" #define G_READ "GModels::read(GXml&)" @@ -384,7 +384,7 @@ void GModels::insert(const std::string& name, const GModel& model) // Throw exception if parameter name was not found if (index >= size()) { - throw GException::model_not_found(G_POP2, name); + throw GException::model_not_found(G_INSERT2, name); } // Make deep copy of model @@ -413,12 +413,12 @@ void GModels::insert(const std::string& name, const GModel& model) * * Remove model of specified @p index from container. ***************************************************************************/ -void GModels::pop(const int& index) +void GModels::remove(const int& index) { // Compile option: raise exception if index is out of range #if defined(G_RANGE_CHECK) if (index < 0 || index >= size()) { - throw GException::out_of_range(G_POP1, index, 0, size()-1); + throw GException::out_of_range(G_REMOVE1, index, 0, size()-1); } #endif @@ -443,14 +443,14 @@ void GModels::pop(const int& index) * * Remove model of specified @p name from container. ***************************************************************************/ -void GModels::pop(const std::string& name) +void GModels::remove(const std::string& name) { // Get parameter index int index = get_index(name); // Throw exception if parameter name was not found if (index >= size()) { - throw GException::model_not_found(G_POP2, name); + throw GException::model_not_found(G_REMOVE2, name); } // Erase model component from container diff --git a/src/obs/GEbounds.cpp b/src/obs/GEbounds.cpp index fe980d6..018073c 100644 --- a/src/obs/GEbounds.cpp +++ b/src/obs/GEbounds.cpp @@ -39,7 +39,7 @@ #include "GFitsTableDoubleCol.hpp" /* __ Method name definitions ____________________________________________ */ -#define G_POP "GEbounds::pop(int&)" +#define G_REMOVE "GEbounds::remove(int&)" #define G_EMIN "GEbounds::emin(int&)" #define G_EMAX "GEbounds::emax(int&)" #define G_EMEAN "GEbounds::emean(int&)" @@ -377,12 +377,12 @@ void GEbounds::merge(const GEnergy& emin, const GEnergy& emax) * Note that the method does not actually reduce the memory size but just * updates the information on the number of elements in the array. ***************************************************************************/ -void GEbounds::pop(const int& index) +void GEbounds::remove(const int& index) { #if defined(G_RANGE_CHECK) // If index is outside boundary then throw an error if (index < 0 || index >= m_num) { - throw GException::out_of_range(G_POP, index, 0, m_num-1); + throw GException::out_of_range(G_REMOVE, index, 0, m_num-1); } #endif diff --git a/src/obs/GGti.cpp b/src/obs/GGti.cpp index 5f1cb9e..f9f8297 100644 --- a/src/obs/GGti.cpp +++ b/src/obs/GGti.cpp @@ -37,7 +37,7 @@ #include "GFitsTableDoubleCol.hpp" /* __ Method name definitions ____________________________________________ */ -#define G_POP "GGti::pop(int&)" +#define G_REMOVE "GGti::remove(int&)" #define G_TSTART "GGti::tstart(int&)" #define G_TSTOP "GGti::tstop(int&)" @@ -421,12 +421,12 @@ void GGti::reduce(const GTime& tstart, const GTime& tstop) * Note that the method does not actually reduce the memory size but just * updates the information on the number of elements in the array. ***************************************************************************/ -void GGti::pop(const int& index) +void GGti::remove(const int& index) { #if defined(G_RANGE_CHECK) // If index is outside boundary then throw an error if (index < 0 || index >= m_num) { - throw GException::out_of_range(G_POP, index, 0, m_num-1); + throw GException::out_of_range(G_REMOVE, index, 0, m_num-1); } #endif diff --git a/test/test_GObservation.cpp b/test/test_GObservation.cpp index bfcca04..853282b 100644 --- a/test/test_GObservation.cpp +++ b/test/test_GObservation.cpp @@ -295,7 +295,7 @@ void TestGObservation::test_ebounds(void) test_value(ebds.emax().MeV(), 10.0, 1.0e-10, "Maximum energy should be 10."); // Remove interval - ebds.pop(0); + ebds.remove(0); test_value(ebds.size(), 0, "GEbounds should have zero size."); test_assert(ebds.isempty(), "GEbounds should be empty."); test_value(ebds.emin().MeV(), 0.0, 1.0e-10, "Minimum energy should be 0."); @@ -442,7 +442,7 @@ GEbounds ebds; test_value(gti.tstop().secs(), 10.0, 1.0e-10, "Stop time should be 10."); // Remove interval - gti.pop(0); + gti.remove(0); test_value(gti.size(), 0, "GGti should have zero size."); test_assert(gti.isempty(), "GGti should be empty."); test_value(gti.tstart().secs(), 0.0, 1.0e-10, "Start time should be 0."); -- libgit2 0.21.4