From bfb48911877a4f90b2d85c1e064c87fde97c42bd Mon Sep 17 00:00:00 2001
From: Christoph Lehmann <christoph.lehmann@ufz.de>
Date: Tue, 5 Jul 2016 12:36:07 +0200
Subject: [PATCH] [PL] added extrapolator data class

---
 ProcessLib/ExtrapolatorData.h | 76 +++++++++++++++++++++++++++++++++++
 1 file changed, 76 insertions(+)
 create mode 100644 ProcessLib/ExtrapolatorData.h

diff --git a/ProcessLib/ExtrapolatorData.h b/ProcessLib/ExtrapolatorData.h
new file mode 100644
index 00000000000..bab990e1fdf
--- /dev/null
+++ b/ProcessLib/ExtrapolatorData.h
@@ -0,0 +1,76 @@
+/**
+ * \copyright
+ * Copyright (c) 2012-2016, OpenGeoSys Community (http://www.opengeosys.org)
+ *            Distributed under a Modified BSD License.
+ *              See accompanying file LICENSE.txt or
+ *              http://www.opengeosys.org/project/license
+ *
+ */
+
+#ifndef PROCESSLIB_EXTRAPOLATORDATA_H
+#define PROCESSLIB_EXTRAPOLATORDATA_H
+
+#include <memory>
+#include "NumLib/DOF/LocalToGlobalIndexMap.h"
+#include "NumLib/Extrapolation/Extrapolator.h"
+
+namespace ProcessLib
+{
+/*! Helper struct containing an extrapolator and a single component DOF table.
+ *
+ * Storage for the DOF table is managed optionally.
+ *
+ * \todo Later on this struct shall be moved, e.g., be merged with the process
+ * output class.
+ */
+struct ExtrapolatorData
+{
+    ExtrapolatorData() = default;
+
+    ExtrapolatorData(
+        std::unique_ptr<NumLib::Extrapolator>&& extrapolator_,
+        NumLib::LocalToGlobalIndexMap const* const dof_table_single_component,
+        bool const manage_storage)
+        : extrapolator(std::move(extrapolator_))
+        , _dof_table_single_component(dof_table_single_component)
+        , _manage_storage(manage_storage)
+    {
+    }
+
+    ExtrapolatorData(ExtrapolatorData&& other)
+        : extrapolator(std::move(other.extrapolator))
+        , _dof_table_single_component(other._dof_table_single_component)
+        , _manage_storage(other._manage_storage)
+    {
+        other._manage_storage = false;
+        other._dof_table_single_component = nullptr;
+    }
+
+    ExtrapolatorData& operator=(ExtrapolatorData&& other)
+    {
+        cleanup();
+        _manage_storage = other._manage_storage;
+        _dof_table_single_component = other._dof_table_single_component;
+        extrapolator = std::move(other.extrapolator);
+        return *this;
+    }
+
+    ~ExtrapolatorData() { cleanup(); }
+    std::unique_ptr<NumLib::Extrapolator> extrapolator;
+
+private:
+    void cleanup()
+    {
+        if (_manage_storage) {
+            delete _dof_table_single_component;
+        }
+    }
+
+    NumLib::LocalToGlobalIndexMap const* _dof_table_single_component = nullptr;
+    bool _manage_storage = false;
+};
+
+} // namespace ProcessLib
+
+
+#endif // PROCESSLIB_EXTRAPOLATORDATA_H
-- 
GitLab