Skip to content
Snippets Groups Projects
Commit 80f27f52 authored by tobiglaser's avatar tobiglaser
Browse files

Correction: move function to source file

parent 7565da8b
No related branches found
No related tags found
No related merge requests found
...@@ -51,6 +51,21 @@ std::shared_ptr<ICommand> CommandList::add(const Type _cmd) ...@@ -51,6 +51,21 @@ std::shared_ptr<ICommand> CommandList::add(const Type _cmd)
return newElement->getCommand(); 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. * @brief Clears list before adding 5 Commands to the list.
* *
......
...@@ -33,14 +33,7 @@ public: ...@@ -33,14 +33,7 @@ public:
std::shared_ptr<ICommand> moveUp(unsigned int _pos); std::shared_ptr<ICommand> moveUp(unsigned int _pos);
std::shared_ptr<ICommand> moveDown(unsigned int _pos); std::shared_ptr<ICommand> moveDown(unsigned int _pos);
std::shared_ptr<ICommand> add(std::shared_ptr<ICommand> _cmd) 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();
}
void createCommands(); void createCommands();
void printCommands(); void printCommands();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment