diff --git a/src/CommandListOWN.cpp b/src/CommandListOWN.cpp index c26dd023673aa1acccf24e6e0b286f4e3d46ec81..7b6d8c12337a319c9ca95393f7b8be7c9296abbb 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 43bf8f0d1a6353100290a0833f9f3349e3e28222..a462ec2ead8a7bbefb38c49a5097ce5249b972cf 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();