From 1b455efb63f9967eaed394c7e9053f9235570dbc Mon Sep 17 00:00:00 2001 From: Matthias Puchner <github@mpuchner.de> Date: Sat, 24 Apr 2021 09:14:59 +0200 Subject: [PATCH] rm obsolete method treeToString/nodeToString --- Param/Node/INode.cpp | 5 - Param/Node/INode.h | 3 - Param/Node/NodeUtils.cpp | 58 ----------- Param/Node/NodeUtils.h | 3 - .../Core/Sample/SampleProviderTest.cpp | 4 - auto/Wrap/doxygenParam.i | 5 - auto/Wrap/libBornAgainParam_wrap.cpp | 74 -------------- auto/Wrap/libBornAgainParam_wrap.h | 1 - auto/Wrap/libBornAgainSample_wrap.cpp | 96 ------------------- auto/Wrap/libBornAgainSample_wrap.h | 3 - 10 files changed, 252 deletions(-) diff --git a/Param/Node/INode.cpp b/Param/Node/INode.cpp index 1116ec43c93..8cef0ae3b79 100644 --- a/Param/Node/INode.cpp +++ b/Param/Node/INode.cpp @@ -48,11 +48,6 @@ INode::INode(const NodeMeta& meta, const std::vector<double>& PValues) } } -std::string INode::treeToString() const -{ - return NodeUtils::nodeToString(this); -} - void INode::registerChild(INode* node) { ASSERT(node); diff --git a/Param/Node/INode.h b/Param/Node/INode.h index ad20ba3065b..c65a322b72d 100644 --- a/Param/Node/INode.h +++ b/Param/Node/INode.h @@ -56,9 +56,6 @@ public: //! Calls the INodeVisitor's visit method virtual void accept(INodeVisitor* visitor) const = 0; - //! Returns multiline string representing tree structure below the node. - virtual std::string treeToString() const; - void registerChild(INode* node); //! Returns a vector of children diff --git a/Param/Node/NodeUtils.cpp b/Param/Node/NodeUtils.cpp index f52a154cde9..f1860415d5d 100644 --- a/Param/Node/NodeUtils.cpp +++ b/Param/Node/NodeUtils.cpp @@ -13,57 +13,7 @@ // ************************************************************************************************ #include "Param/Node/NodeUtils.h" -#include "Base/Utils/Assert.h" -#include "Param/Base/RealParameter.h" #include "Param/Node/INode.h" -#include <algorithm> -#include <functional> -#include <iterator> -#include <sstream> - -namespace { - -// Returns string filled with '.' -std::string s_indent(int depth) -{ - const int multiplier = 4; - return std::string(multiplier * depth, '.'); -} - -// Returns single line string representing registered parameters of given node. -std::string registeredParametersToString(const INode& node) -{ - std::ostringstream result; - - const std::vector<RealParameter*> pars = node.registeredParameters(); - if (pars.empty()) - return {}; - - result << " ("; - size_t index(0); - for (auto par : pars) { - result << "'" << par->getName() << "':" << par->value(); - ++index; - if (index != pars.size()) - result << " "; - } - result << ")"; - - return result.str(); -} - -// Returns a string representing given node. -std::string nodeString(const INode& node, int depth) -{ - std::ostringstream result; - result << s_indent(depth) << node.displayName() << registeredParametersToString(node) << "\n"; - return result.str(); -} -} // namespace - -// ************************************************************************************************ -// namespace NodeUtils -// ************************************************************************************************ std::vector<std::tuple<const INode*, int, const INode*>> NodeUtils::progenyPlus(const INode* node, int level) @@ -77,14 +27,6 @@ std::vector<std::tuple<const INode*, int, const INode*>> NodeUtils::progenyPlus( return result; } -std::string NodeUtils::nodeToString(const INode* node) -{ - std::ostringstream result; - for (const auto& [child, depth, parent] : progenyPlus(node)) - result << nodeString(*child, depth); - return result.str(); -} - std::string NodeUtils::nodePath(const INode* node, const INode* root) { std::vector<std::string> pathElements; diff --git a/Param/Node/NodeUtils.h b/Param/Node/NodeUtils.h index 8d641083d16..64e6bceaab1 100644 --- a/Param/Node/NodeUtils.h +++ b/Param/Node/NodeUtils.h @@ -31,9 +31,6 @@ namespace NodeUtils { std::vector<std::tuple<const INode*, int, const INode*>> progenyPlus(const INode* node, int level = 0); -//! Returns multiline string representing tree structure starting from given node. -std::string nodeToString(const INode* node); - //! Returns path composed of node's displayName, with respect to root node std::string nodePath(const INode* node, const INode* root = nullptr); diff --git a/Tests/UnitTests/Core/Sample/SampleProviderTest.cpp b/Tests/UnitTests/Core/Sample/SampleProviderTest.cpp index 4fe141644b7..5311b700e1a 100644 --- a/Tests/UnitTests/Core/Sample/SampleProviderTest.cpp +++ b/Tests/UnitTests/Core/Sample/SampleProviderTest.cpp @@ -125,8 +125,6 @@ TEST_F(SampleProviderTest, sampleInSimulationContext) ASSERT_EQ(provider.getChildren().size(), 1u); EXPECT_EQ(provider.getChildren()[0], provider.sample()); - EXPECT_FALSE(sim.treeToString().empty()); - // creating second simulation via copy-construction SampleProviderTest::TestSimulation sim2(sim); SampleProvider& provider2 = sim2.m_provider; @@ -158,8 +156,6 @@ TEST_F(SampleProviderTest, builderInSimulationContext) EXPECT_EQ(provider.sample()->parent(), nullptr); ASSERT_EQ(provider.getChildren().size(), 1u); - EXPECT_FALSE(sim.treeToString().empty()); - // creating second simulation via copy-construction SampleProviderTest::TestSimulation sim2(sim); diff --git a/auto/Wrap/doxygenParam.i b/auto/Wrap/doxygenParam.i index 7962d8b4502..e1a1f5700a7 100644 --- a/auto/Wrap/doxygenParam.i +++ b/auto/Wrap/doxygenParam.i @@ -442,11 +442,6 @@ C++ includes: INode.h Calls the INodeVisitor's visit method. "; -%feature("docstring") INode::treeToString "std::string INode::treeToString() const - -Returns multiline string representing tree structure below the node. -"; - %feature("docstring") INode::registerChild "void INode::registerChild(INode *node) "; diff --git a/auto/Wrap/libBornAgainParam_wrap.cpp b/auto/Wrap/libBornAgainParam_wrap.cpp index c6b53f915de..968a67d3bfa 100644 --- a/auto/Wrap/libBornAgainParam_wrap.cpp +++ b/auto/Wrap/libBornAgainParam_wrap.cpp @@ -7525,38 +7525,6 @@ void SwigDirector_INode::accept(INodeVisitor *visitor) const { } -std::string SwigDirector_INode::treeToString() const { - std::string c_result; - if (!swig_get_self()) { - Swig::DirectorException::raise("'self' uninitialized, maybe you forgot to call INode.__init__."); - } -#if defined(SWIG_PYTHON_DIRECTOR_VTABLE) - const size_t swig_method_index = 3; - const char *const swig_method_name = "treeToString"; - PyObject *method = swig_get_method(swig_method_index, swig_method_name); - swig::SwigVar_PyObject args = PyTuple_New(0); - swig::SwigVar_PyObject result = PyObject_Call(method, (PyObject *) args, NULL); -#else - swig::SwigVar_PyObject swig_method_name = SWIG_Python_str_FromChar("treeToString"); - swig::SwigVar_PyObject result = PyObject_CallMethodObjArgs(swig_get_self(), (PyObject *) swig_method_name, NULL); -#endif - if (!result) { - PyObject *error = PyErr_Occurred(); - if (error) { - Swig::DirectorMethodException::raise("Error detected when calling 'INode.treeToString'"); - } - } - std::string *swig_optr = 0; - int swig_ores = SWIG_AsPtr_std_string(result, &swig_optr); - if (!SWIG_IsOK(swig_ores) || !swig_optr) { - Swig::DirectorTypeMismatchException::raise(SWIG_ErrorType(SWIG_ArgError((swig_optr ? swig_ores : SWIG_TypeError))), "in output value of type '""std::string""'"); - } - c_result = *swig_optr; - if (SWIG_IsNewObj(swig_ores)) delete swig_optr; - return (std::string) c_result; -} - - std::vector< INode const *, std::allocator< INode const * > > SwigDirector_INode::getChildren() const { std::vector< INode const *,std::allocator< INode const * > > c_result; if (!swig_get_self()) { @@ -35440,41 +35408,6 @@ fail: } -SWIGINTERN PyObject *_wrap_INode_treeToString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - INode *arg1 = (INode *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - Swig::Director *director = 0; - bool upcall = false; - std::string result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_INode, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "INode_treeToString" "', argument " "1"" of type '" "INode const *""'"); - } - arg1 = reinterpret_cast< INode * >(argp1); - director = SWIG_DIRECTOR_CAST(arg1); - upcall = (director && (director->swig_get_self()==swig_obj[0])); - try { - if (upcall) { - result = ((INode const *)arg1)->INode::treeToString(); - } else { - result = ((INode const *)arg1)->treeToString(); - } - } catch (Swig::DirectorException&) { - SWIG_fail; - } - resultobj = SWIG_From_std_string(static_cast< std::string >(result)); - return resultobj; -fail: - return NULL; -} - - SWIGINTERN PyObject *_wrap_INode_registerChild(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; INode *arg1 = (INode *) 0 ; @@ -49934,13 +49867,6 @@ static PyMethodDef SwigMethods[] = { "Calls the INodeVisitor's visit method. \n" "\n" ""}, - { "INode_treeToString", _wrap_INode_treeToString, METH_O, "\n" - "INode_treeToString(INode self) -> std::string\n" - "std::string INode::treeToString() const\n" - "\n" - "Returns multiline string representing tree structure below the node. \n" - "\n" - ""}, { "INode_registerChild", _wrap_INode_registerChild, METH_VARARGS, "\n" "INode_registerChild(INode self, INode node)\n" "void INode::registerChild(INode *node)\n" diff --git a/auto/Wrap/libBornAgainParam_wrap.h b/auto/Wrap/libBornAgainParam_wrap.h index 3e533126972..51690475118 100644 --- a/auto/Wrap/libBornAgainParam_wrap.h +++ b/auto/Wrap/libBornAgainParam_wrap.h @@ -94,7 +94,6 @@ public: return INode::fullQualifiedParameters(); } virtual void accept(INodeVisitor *visitor) const; - virtual std::string treeToString() const; virtual std::vector< INode const *, std::allocator< INode const * > > getChildren() const; virtual void setParent(INode const *newParent); diff --git a/auto/Wrap/libBornAgainSample_wrap.cpp b/auto/Wrap/libBornAgainSample_wrap.cpp index b2767673aa1..e45e94969e4 100644 --- a/auto/Wrap/libBornAgainSample_wrap.cpp +++ b/auto/Wrap/libBornAgainSample_wrap.cpp @@ -7633,38 +7633,6 @@ void SwigDirector_ISampleNode::accept(INodeVisitor *visitor) const { } -std::string SwigDirector_ISampleNode::treeToString() const { - std::string c_result; - if (!swig_get_self()) { - Swig::DirectorException::raise("'self' uninitialized, maybe you forgot to call ISampleNode.__init__."); - } -#if defined(SWIG_PYTHON_DIRECTOR_VTABLE) - const size_t swig_method_index = 5; - const char *const swig_method_name = "treeToString"; - PyObject *method = swig_get_method(swig_method_index, swig_method_name); - swig::SwigVar_PyObject args = PyTuple_New(0); - swig::SwigVar_PyObject result = PyObject_Call(method, (PyObject *) args, NULL); -#else - swig::SwigVar_PyObject swig_method_name = SWIG_Python_str_FromChar("treeToString"); - swig::SwigVar_PyObject result = PyObject_CallMethodObjArgs(swig_get_self(), (PyObject *) swig_method_name, NULL); -#endif - if (!result) { - PyObject *error = PyErr_Occurred(); - if (error) { - Swig::DirectorMethodException::raise("Error detected when calling 'ISampleNode.treeToString'"); - } - } - std::string *swig_optr = 0; - int swig_ores = SWIG_AsPtr_std_string(result, &swig_optr); - if (!SWIG_IsOK(swig_ores) || !swig_optr) { - Swig::DirectorTypeMismatchException::raise(SWIG_ErrorType(SWIG_ArgError((swig_optr ? swig_ores : SWIG_TypeError))), "in output value of type '""std::string""'"); - } - c_result = *swig_optr; - if (SWIG_IsNewObj(swig_ores)) delete swig_optr; - return (std::string) c_result; -} - - std::vector< INode const *, std::allocator< INode const * > > SwigDirector_ISampleNode::getChildren() const { std::vector< INode const *,std::allocator< INode const * > > c_result; if (!swig_get_self()) { @@ -7913,38 +7881,6 @@ void SwigDirector_IFormFactor::accept(INodeVisitor *visitor) const { } -std::string SwigDirector_IFormFactor::treeToString() const { - std::string c_result; - if (!swig_get_self()) { - Swig::DirectorException::raise("'self' uninitialized, maybe you forgot to call IFormFactor.__init__."); - } -#if defined(SWIG_PYTHON_DIRECTOR_VTABLE) - const size_t swig_method_index = 5; - const char *const swig_method_name = "treeToString"; - PyObject *method = swig_get_method(swig_method_index, swig_method_name); - swig::SwigVar_PyObject args = PyTuple_New(0); - swig::SwigVar_PyObject result = PyObject_Call(method, (PyObject *) args, NULL); -#else - swig::SwigVar_PyObject swig_method_name = SWIG_Python_str_FromChar("treeToString"); - swig::SwigVar_PyObject result = PyObject_CallMethodObjArgs(swig_get_self(), (PyObject *) swig_method_name, NULL); -#endif - if (!result) { - PyObject *error = PyErr_Occurred(); - if (error) { - Swig::DirectorMethodException::raise("Error detected when calling 'IFormFactor.treeToString'"); - } - } - std::string *swig_optr = 0; - int swig_ores = SWIG_AsPtr_std_string(result, &swig_optr); - if (!SWIG_IsOK(swig_ores) || !swig_optr) { - Swig::DirectorTypeMismatchException::raise(SWIG_ErrorType(SWIG_ArgError((swig_optr ? swig_ores : SWIG_TypeError))), "in output value of type '""std::string""'"); - } - c_result = *swig_optr; - if (SWIG_IsNewObj(swig_ores)) delete swig_optr; - return (std::string) c_result; -} - - std::vector< INode const *, std::allocator< INode const * > > SwigDirector_IFormFactor::getChildren() const { std::vector< INode const *,std::allocator< INode const * > > c_result; if (!swig_get_self()) { @@ -8456,38 +8392,6 @@ void SwigDirector_IBornFF::accept(INodeVisitor *visitor) const { } -std::string SwigDirector_IBornFF::treeToString() const { - std::string c_result; - if (!swig_get_self()) { - Swig::DirectorException::raise("'self' uninitialized, maybe you forgot to call IBornFF.__init__."); - } -#if defined(SWIG_PYTHON_DIRECTOR_VTABLE) - const size_t swig_method_index = 5; - const char *const swig_method_name = "treeToString"; - PyObject *method = swig_get_method(swig_method_index, swig_method_name); - swig::SwigVar_PyObject args = PyTuple_New(0); - swig::SwigVar_PyObject result = PyObject_Call(method, (PyObject *) args, NULL); -#else - swig::SwigVar_PyObject swig_method_name = SWIG_Python_str_FromChar("treeToString"); - swig::SwigVar_PyObject result = PyObject_CallMethodObjArgs(swig_get_self(), (PyObject *) swig_method_name, NULL); -#endif - if (!result) { - PyObject *error = PyErr_Occurred(); - if (error) { - Swig::DirectorMethodException::raise("Error detected when calling 'IBornFF.treeToString'"); - } - } - std::string *swig_optr = 0; - int swig_ores = SWIG_AsPtr_std_string(result, &swig_optr); - if (!SWIG_IsOK(swig_ores) || !swig_optr) { - Swig::DirectorTypeMismatchException::raise(SWIG_ErrorType(SWIG_ArgError((swig_optr ? swig_ores : SWIG_TypeError))), "in output value of type '""std::string""'"); - } - c_result = *swig_optr; - if (SWIG_IsNewObj(swig_ores)) delete swig_optr; - return (std::string) c_result; -} - - std::vector< INode const *, std::allocator< INode const * > > SwigDirector_IBornFF::getChildren() const { std::vector< INode const *,std::allocator< INode const * > > c_result; if (!swig_get_self()) { diff --git a/auto/Wrap/libBornAgainSample_wrap.h b/auto/Wrap/libBornAgainSample_wrap.h index 7b33da0fc83..32e1b8a36f7 100644 --- a/auto/Wrap/libBornAgainSample_wrap.h +++ b/auto/Wrap/libBornAgainSample_wrap.h @@ -29,7 +29,6 @@ public: return INode::fullQualifiedParameters(); } virtual void accept(INodeVisitor *visitor) const; - virtual std::string treeToString() const; virtual std::vector< INode const *, std::allocator< INode const * > > getChildren() const; virtual void setParent(INode const *newParent); virtual Material const *material() const; @@ -83,7 +82,6 @@ public: return INode::fullQualifiedParameters(); } virtual void accept(INodeVisitor *visitor) const; - virtual std::string treeToString() const; virtual std::vector< INode const *, std::allocator< INode const * > > getChildren() const; virtual void setParent(INode const *newParent); virtual Material const *material() const; @@ -151,7 +149,6 @@ public: return INode::fullQualifiedParameters(); } virtual void accept(INodeVisitor *visitor) const; - virtual std::string treeToString() const; virtual std::vector< INode const *, std::allocator< INode const * > > getChildren() const; virtual void setParent(INode const *newParent); virtual Material const *material() const; -- GitLab