From 79396c613a149174dde047f0f6977b35e67dd1da Mon Sep 17 00:00:00 2001 From: Matthias Puchner <github@mpuchner.de> Date: Sat, 24 Apr 2021 07:16:04 +0200 Subject: [PATCH] minor changes (rename, public->protected, unit test) --- Param/Base/IParametricComponent.h | 6 +-- Param/Node/NodeUtils.cpp | 6 +-- .../Core/Parameters/IParameterizedTest.cpp | 4 ++ auto/Wrap/libBornAgainParam_wrap.cpp | 38 ------------------- 4 files changed, 10 insertions(+), 44 deletions(-) diff --git a/Param/Base/IParametricComponent.h b/Param/Base/IParametricComponent.h index 59216b662a8..220737505fd 100644 --- a/Param/Base/IParametricComponent.h +++ b/Param/Base/IParametricComponent.h @@ -40,9 +40,6 @@ public: //! parents/children) const std::vector<RealParameter*> registeredParameters() const; - // #baPool + docu - RealParameter* parameter(const double* p) const; - //! Action to be taken in inherited class when a parameter has changed. virtual void onChange() {} @@ -55,6 +52,9 @@ public: // #baPool ++ add unit tests for this protected: + // #baPool + docu + RealParameter* parameter(const double* p) const; + RealParameter& registerParameter(const std::string& name, double* parpointer); void registerVector(const std::string& base_name, kvector_t* p_vec, diff --git a/Param/Node/NodeUtils.cpp b/Param/Node/NodeUtils.cpp index 4a94abedc3d..f52a154cde9 100644 --- a/Param/Node/NodeUtils.cpp +++ b/Param/Node/NodeUtils.cpp @@ -30,8 +30,8 @@ std::string s_indent(int depth) return std::string(multiplier * depth, '.'); } -// Returns single line string representing pool parameters of given node. -std::string poolToString(const INode& node) +// Returns single line string representing registered parameters of given node. +std::string registeredParametersToString(const INode& node) { std::ostringstream result; @@ -56,7 +56,7 @@ std::string poolToString(const INode& node) std::string nodeString(const INode& node, int depth) { std::ostringstream result; - result << s_indent(depth) << node.displayName() << poolToString(node) << "\n"; + result << s_indent(depth) << node.displayName() << registeredParametersToString(node) << "\n"; return result.str(); } } // namespace diff --git a/Tests/UnitTests/Core/Parameters/IParameterizedTest.cpp b/Tests/UnitTests/Core/Parameters/IParameterizedTest.cpp index 65b2eab1f23..6ca50f94138 100644 --- a/Tests/UnitTests/Core/Parameters/IParameterizedTest.cpp +++ b/Tests/UnitTests/Core/Parameters/IParameterizedTest.cpp @@ -9,6 +9,10 @@ protected: public: using IParametricComponent::fullQualifiedParameters; // make it public for test cases using IParametricComponent::registerParameter; // make it public for test cases + RealParameter* parameter(const double* p) // make it public for test cases + { + return IParametricComponent::parameter(p); + } }; TestClass m_initial_object; diff --git a/auto/Wrap/libBornAgainParam_wrap.cpp b/auto/Wrap/libBornAgainParam_wrap.cpp index f8af1fabf7e..bc067733266 100644 --- a/auto/Wrap/libBornAgainParam_wrap.cpp +++ b/auto/Wrap/libBornAgainParam_wrap.cpp @@ -34451,37 +34451,6 @@ fail: return NULL; } - -SWIGINTERN PyObject *_wrap_IParametricComponent_parameter(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - IParametricComponent *arg1 = (IParametricComponent *) 0 ; - double *arg2 = (double *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - RealParameter *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "IParametricComponent_parameter", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_IParametricComponent, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IParametricComponent_parameter" "', argument " "1"" of type '" "IParametricComponent const *""'"); - } - arg1 = reinterpret_cast< IParametricComponent * >(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_double, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "IParametricComponent_parameter" "', argument " "2"" of type '" "double const *""'"); - } - arg2 = reinterpret_cast< double * >(argp2); - result = (RealParameter *)((IParametricComponent const *)arg1)->parameter((double const *)arg2); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_RealParameter, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - SWIGINTERN PyObject *_wrap_IParametricComponent_onChange(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; IParametricComponent *arg1 = (IParametricComponent *) 0 ; @@ -50011,13 +49980,6 @@ static PyMethodDef SwigMethods[] = { "\n" ""}, { "IParametricComponent_registeredParameters", _wrap_IParametricComponent_registeredParameters, METH_O, "IParametricComponent_registeredParameters(IParametricComponent self) -> std::vector< RealParameter *,std::allocator< RealParameter * > > const"}, - { "IParametricComponent_parameter", _wrap_IParametricComponent_parameter, METH_VARARGS, "\n" - "IParametricComponent_parameter(IParametricComponent self, double const * p) -> RealParameter\n" - "RealParameter * IParametricComponent::parameter(const std::string &name) const\n" - "\n" - "Returns parameter with given 'name'. \n" - "\n" - ""}, { "IParametricComponent_onChange", _wrap_IParametricComponent_onChange, METH_O, "\n" "IParametricComponent_onChange(IParametricComponent self)\n" "virtual void IParametricComponent::onChange()\n" -- GitLab