From 80f27f528930397da2bf7e293e6c5d760bc619d6 Mon Sep 17 00:00:00 2001
From: tobiglaser <76131623+tobiglaser@users.noreply.github.com>
Date: Tue, 9 Aug 2022 23:00:31 +0200
Subject: [PATCH] Correction: move function to source file

---
 src/CommandListOWN.cpp | 15 +++++++++++++++
 src/CommandListOWN.h   |  9 +--------
 2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/src/CommandListOWN.cpp b/src/CommandListOWN.cpp
index c26dd02..7b6d8c1 100644
--- a/src/CommandListOWN.cpp
+++ b/src/CommandListOWN.cpp
@@ -51,6 +51,21 @@ std::shared_ptr<ICommand> CommandList::add(const Type _cmd)
     return newElement->getCommand();
 }
 
+/**
+ * @brief Adds an existing std::shared_ptr<ICommand> to the list.
+ *  Used for Commands created by CommandType
+ * @param _cmd The std::shared_ptr<ICommand> to add.
+ * @return std::shared_ptr<ICommand> that was added.
+ */
+std::shared_ptr<ICommand> CommandList::add(std::shared_ptr<ICommand> _cmd)
+{
+    std::shared_ptr<Element> newElement = std::make_shared<Element>(_cmd);
+    std::shared_ptr<Element> end = getElement(getSize());
+    newElement->setPrev(end);
+    end->setNext(newElement);
+    return newElement->getCommand();
+}
+
 /**
  * @brief Clears list before adding 5 Commands to the list.
  * 
diff --git a/src/CommandListOWN.h b/src/CommandListOWN.h
index 43bf8f0..a462ec2 100644
--- a/src/CommandListOWN.h
+++ b/src/CommandListOWN.h
@@ -33,14 +33,7 @@ public:
     std::shared_ptr<ICommand> moveUp(unsigned int _pos);
     std::shared_ptr<ICommand> moveDown(unsigned int _pos);
 
-    std::shared_ptr<ICommand> add(std::shared_ptr<ICommand> _cmd)
-    {
-    std::shared_ptr<Element> newElement = std::make_shared<Element>(_cmd);
-    std::shared_ptr<Element> end = getElement(getSize());
-    newElement->setPrev(end);
-    end->setNext(newElement);
-    return newElement->getCommand();
-    }
+    std::shared_ptr<ICommand> add(std::shared_ptr<ICommand> _cmd);
 
     void createCommands();
     void printCommands();
-- 
GitLab