From 8985561d2f66a5dcfc0f6b8a549f1bd631c9002d Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de>
Date: Fri, 23 Jul 2021 08:15:45 +0200
Subject: [PATCH] ComponentKeyHandler now using INode instead of IComponent

---
 Core/Export/ComponentKeyHandler.cpp             |  6 +++---
 Core/Export/ComponentKeyHandler.h               | 12 ++++++------
 Resample/{Processed => Slice}/ProfileHelper.cpp |  7 +++----
 Resample/{Processed => Slice}/ProfileHelper.h   | 10 +++++-----
 Resample/Swig/MultiLayerFuncs.cpp               |  6 +++---
 auto/Wrap/doxygenCore.i                         |  6 +++---
 auto/Wrap/doxygenResample.i                     | 10 +++++-----
 7 files changed, 28 insertions(+), 29 deletions(-)
 rename Resample/{Processed => Slice}/ProfileHelper.cpp (92%)
 rename Resample/{Processed => Slice}/ProfileHelper.h (82%)

diff --git a/Core/Export/ComponentKeyHandler.cpp b/Core/Export/ComponentKeyHandler.cpp
index 2506b1a1e53..c1df3b35514 100644
--- a/Core/Export/ComponentKeyHandler.cpp
+++ b/Core/Export/ComponentKeyHandler.cpp
@@ -17,15 +17,15 @@
 #include <set>
 #include <stdexcept>
 
-void ComponentKeyHandler::insertModel(const std::string& tag, const IComponent* s)
+void ComponentKeyHandler::insertModel(const std::string& tag, const INode* s)
 {
     m_objects[tag].emplace_back(s);
 }
 
-std::string ComponentKeyHandler::obj2key(const IComponent* s) const
+std::string ComponentKeyHandler::obj2key(const INode* s) const
 {
     for (auto it : m_objects) {
-        const std::vector<const IComponent*>& v = it.second;
+        const std::vector<const INode*>& v = it.second;
         const auto vpos = std::find(v.begin(), v.end(), s);
         if (vpos == std::end(v))
             continue;
diff --git a/Core/Export/ComponentKeyHandler.h b/Core/Export/ComponentKeyHandler.h
index 88c43712e5e..165f508fa98 100644
--- a/Core/Export/ComponentKeyHandler.h
+++ b/Core/Export/ComponentKeyHandler.h
@@ -24,26 +24,26 @@
 #include <string>
 #include <vector>
 
-class IComponent;
+class INode;
 
-//! Stores IComponent instances, associates them with given tag, and provides unique keys.
+//! Stores INode instances, associates them with given tag, and provides unique keys.
 
 class ComponentKeyHandler {
 public:
-    void insertModel(const std::string& tag, const IComponent* s);
+    void insertModel(const std::string& tag, const INode* s);
 
     template <class T> std::vector<const T*> objectsOfType() const;
-    std::string obj2key(const IComponent* s) const;
+    std::string obj2key(const INode* s) const;
 
 private:
-    std::map<std::string, std::vector<const IComponent*>> m_objects;
+    std::map<std::string, std::vector<const INode*>> m_objects;
 };
 
 template <class T> std::vector<const T*> ComponentKeyHandler::objectsOfType() const
 {
     std::vector<const T*> ret;
     for (auto it : m_objects)
-        for (const IComponent* s : it.second)
+        for (const INode* s : it.second)
             if (const auto* c = dynamic_cast<const T*>(s); c)
                 ret.emplace_back(c);
     return ret;
diff --git a/Resample/Processed/ProfileHelper.cpp b/Resample/Slice/ProfileHelper.cpp
similarity index 92%
rename from Resample/Processed/ProfileHelper.cpp
rename to Resample/Slice/ProfileHelper.cpp
index 6ea87801673..54162775f4c 100644
--- a/Resample/Processed/ProfileHelper.cpp
+++ b/Resample/Slice/ProfileHelper.cpp
@@ -2,7 +2,7 @@
 //
 //  BornAgain: simulate and fit reflection and scattering
 //
-//! @file      Resample/Processed/ProfileHelper.cpp
+//! @file      Resample/Slice/ProfileHelper.cpp
 //! @brief     Implements class ProfileHelper.
 //!
 //! @homepage  http://www.bornagainproject.org
@@ -12,8 +12,7 @@
 //
 //  ************************************************************************************************
 
-#include "Resample/Processed/ProfileHelper.h"
-#include "Resample/Processed/ProcessedSample.h"
+#include "Resample/Slice/ProfileHelper.h"
 #include "Resample/Slice/Slice.h"
 #include "Resample/Slice/SliceStack.h"
 #include "Sample/Interface/LayerRoughness.h"
@@ -37,7 +36,7 @@ double Transition(double x, double sigma)
 } // namespace
 
 
-ProfileHelper::ProfileHelper(const ProcessedSample& sample) : m_stack(sample.averageSlices()) {}
+ProfileHelper::ProfileHelper(const SliceStack& stack) : m_stack(stack) {}
 
 ProfileHelper::~ProfileHelper() = default;
 
diff --git a/Resample/Processed/ProfileHelper.h b/Resample/Slice/ProfileHelper.h
similarity index 82%
rename from Resample/Processed/ProfileHelper.h
rename to Resample/Slice/ProfileHelper.h
index 00eb3df96a3..6f0b6178a89 100644
--- a/Resample/Processed/ProfileHelper.h
+++ b/Resample/Slice/ProfileHelper.h
@@ -2,7 +2,7 @@
 //
 //  BornAgain: simulate and fit reflection and scattering
 //
-//! @file      Resample/Processed/ProfileHelper.h
+//! @file      Resample/Slice/ProfileHelper.h
 //! @brief     Defines class ProfileHelper.
 //!
 //! @homepage  http://www.bornagainproject.org
@@ -17,8 +17,8 @@
 #endif
 
 #ifndef USER_API
-#ifndef BORNAGAIN_RESAMPLE_PROCESSED_PROFILEHELPER_H
-#define BORNAGAIN_RESAMPLE_PROCESSED_PROFILEHELPER_H
+#ifndef BORNAGAIN_RESAMPLE_SLICE_PROFILEHELPER_H
+#define BORNAGAIN_RESAMPLE_SLICE_PROFILEHELPER_H
 
 #include "Sample/Material/Material.h"
 #include <utility>
@@ -34,7 +34,7 @@ class SliceStack;
 
 class ProfileHelper {
 public:
-    ProfileHelper(const ProcessedSample& sample);
+    ProfileHelper(const SliceStack& stack);
     ~ProfileHelper();
 
     std::vector<complex_t> calculateProfile(const std::vector<double>& z_values) const;
@@ -44,5 +44,5 @@ private:
     const SliceStack& m_stack; // from Fresnel map
 };
 
-#endif // BORNAGAIN_RESAMPLE_PROCESSED_PROFILEHELPER_H
+#endif // BORNAGAIN_RESAMPLE_SLICE_PROFILEHELPER_H
 #endif // USER_API
diff --git a/Resample/Swig/MultiLayerFuncs.cpp b/Resample/Swig/MultiLayerFuncs.cpp
index a81d85834cb..63688cd0346 100644
--- a/Resample/Swig/MultiLayerFuncs.cpp
+++ b/Resample/Swig/MultiLayerFuncs.cpp
@@ -15,7 +15,7 @@
 #include "Resample/Swig/MultiLayerFuncs.h"
 #include "Resample/Options/SimulationOptions.h"
 #include "Resample/Processed/ProcessedSample.h"
-#include "Resample/Processed/ProfileHelper.h"
+#include "Resample/Slice/ProfileHelper.h"
 
 std::vector<double> swigAPI::generateZValues(int n_points, double z_min, double z_max)
 {
@@ -35,7 +35,7 @@ std::vector<complex_t> swigAPI::materialProfileSLD(const MultiLayer& multilayer,
     SimulationOptions options;
     options.setUseAvgMaterials(true);
     const ProcessedSample sample = ProcessedSample::make(multilayer, options);
-    ProfileHelper helper(sample);
+    ProfileHelper helper(sample.averageSlices());
     std::vector<double> z_values = generateZValues(n_points, z_min, z_max);
     return helper.calculateProfile(z_values);
 }
@@ -45,6 +45,6 @@ std::pair<double, double> swigAPI::defaultMaterialProfileLimits(const MultiLayer
     SimulationOptions options;
     options.setUseAvgMaterials(true);
     const ProcessedSample sample = ProcessedSample::make(multilayer, options);
-    ProfileHelper helper(sample);
+    ProfileHelper helper(sample.averageSlices());
     return helper.defaultLimits();
 }
diff --git a/auto/Wrap/doxygenCore.i b/auto/Wrap/doxygenCore.i
index b1c66681175..58cc71a4074 100644
--- a/auto/Wrap/doxygenCore.i
+++ b/auto/Wrap/doxygenCore.i
@@ -210,18 +210,18 @@ clone method
 // File: classComponentKeyHandler.xml
 %feature("docstring") ComponentKeyHandler "
 
-Stores IComponent instances, associates them with given tag, and provides unique keys.
+Stores INode instances, associates them with given tag, and provides unique keys.
 
 C++ includes: ComponentKeyHandler.h
 ";
 
-%feature("docstring")  ComponentKeyHandler::insertModel "void ComponentKeyHandler::insertModel(const std::string &tag, const IComponent *s)
+%feature("docstring")  ComponentKeyHandler::insertModel "void ComponentKeyHandler::insertModel(const std::string &tag, const INode *s)
 ";
 
 %feature("docstring")  ComponentKeyHandler::objectsOfType "std::vector< const T * > ComponentKeyHandler::objectsOfType() const
 ";
 
-%feature("docstring")  ComponentKeyHandler::obj2key "std::string ComponentKeyHandler::obj2key(const IComponent *s) const
+%feature("docstring")  ComponentKeyHandler::obj2key "std::string ComponentKeyHandler::obj2key(const INode *s) const
 ";
 
 
diff --git a/auto/Wrap/doxygenResample.i b/auto/Wrap/doxygenResample.i
index 67def255217..367d812e5ed 100644
--- a/auto/Wrap/doxygenResample.i
+++ b/auto/Wrap/doxygenResample.i
@@ -455,7 +455,7 @@ The generated profile contains the complex SLD for SLD materials and the paramet
 C++ includes: ProfileHelper.h
 ";
 
-%feature("docstring")  ProfileHelper::ProfileHelper "ProfileHelper::ProfileHelper(const ProcessedSample &sample)
+%feature("docstring")  ProfileHelper::ProfileHelper "ProfileHelper::ProfileHelper(const SliceStack &stack)
 ";
 
 %feature("docstring")  ProfileHelper::~ProfileHelper "ProfileHelper::~ProfileHelper()
@@ -915,16 +915,16 @@ Get default z limits for generating a material profile.
 // File: ProcessedSample_8h.xml
 
 
-// File: ProfileHelper_8cpp.xml
+// File: KzComputation_8cpp.xml
 
 
-// File: ProfileHelper_8h.xml
+// File: KzComputation_8h.xml
 
 
-// File: KzComputation_8cpp.xml
+// File: ProfileHelper_8cpp.xml
 
 
-// File: KzComputation_8h.xml
+// File: ProfileHelper_8h.xml
 
 
 // File: Slice_8cpp.xml
-- 
GitLab