diff --git a/src/CommandListOWN.h b/src/CommandListOWN.h index 750cbdfd0c23792615a86e41e96617b114593dbd..b709c5b863b722be79e2e83ffe66b109819d5f15 100644 --- a/src/CommandListOWN.h +++ b/src/CommandListOWN.h @@ -11,20 +11,20 @@ class CommandList { private: std::shared_ptr<Element> root = std::make_shared<Element>(Command("root")); - std::shared_ptr<Element> getElement(uint _pos); + std::shared_ptr<Element> getElement(unsigned int _pos); public: int getSize(); void clear(); int getPos(std::shared_ptr<Command> _cmd); - std::shared_ptr<Command> getCommand(uint _pos); + std::shared_ptr<Command> getCommand(unsigned int _pos); - Command add(Command _cmd); - std::shared_ptr<Command> remove(uint _pos); + std::shared_ptr<Command> add(Command _cmd); + std::shared_ptr<Command> remove(unsigned int _pos); - std::shared_ptr<Command> moveUp(uint _pos); - std::shared_ptr<Command> moveDown(uint _pos); + std::shared_ptr<Command> moveUp(unsigned int _pos); + std::shared_ptr<Command> moveDown(unsigned int _pos); void printCommands(); }; @@ -47,20 +47,20 @@ void CommandList::clear() while (next) { - current->setPrev(NULL); - current->setNext(NULL); + current->setPrev(nullptr); + current->setNext(nullptr); current = next; next = next->getNext(); } } -Command CommandList::add(Command _cmd) +std::shared_ptr<Command> CommandList::add(Command _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 _cmd; + return newElement->getCommand(); } void CommandList::printCommands() @@ -74,12 +74,12 @@ void CommandList::printCommands() } } -std::shared_ptr<Command> CommandList::remove(uint _pos) +std::shared_ptr<Command> CommandList::remove(unsigned int _pos) { std::shared_ptr<Element> toRemove = getElement(_pos); - if (toRemove == NULL | toRemove == root) + if (toRemove == nullptr | toRemove == root) { - return NULL; + return nullptr; } std::cout << "removing: " << toRemove->getCommand()->getName() << '\n'; std::shared_ptr<Element> prev = toRemove->getPrev(); @@ -91,11 +91,11 @@ std::shared_ptr<Command> CommandList::remove(uint _pos) return toRemove->getCommand(); } -std::shared_ptr<Element> CommandList::getElement(uint _pos) +std::shared_ptr<Element> CommandList::getElement(unsigned int _pos) { if (_pos > getSize()) { - return NULL; + return nullptr; } std::shared_ptr<Element> elem = root; for (int i = 0; elem->getNext() && i < _pos; ++i) @@ -105,12 +105,12 @@ std::shared_ptr<Element> CommandList::getElement(uint _pos) return elem; } -std::shared_ptr<Command> CommandList::getCommand(uint _pos) +std::shared_ptr<Command> CommandList::getCommand(unsigned int _pos) { std::shared_ptr<Element> elem = getElement(_pos); - if (elem == NULL) + if (elem == nullptr) { - return NULL; + return nullptr; } else { @@ -135,17 +135,17 @@ int CommandList::getPos(std::shared_ptr<Command> _cmd) return i; } -std::shared_ptr<Command> CommandList::moveUp(uint _pos) +std::shared_ptr<Command> CommandList::moveUp(unsigned int _pos) { if (_pos <= 1) { - return NULL; + return nullptr; } std::shared_ptr<Element> ptr = getElement(_pos); std::shared_ptr<Element> prevPtr = getElement(_pos -1); - if (ptr == NULL | prevPtr == NULL) + if (ptr == nullptr | prevPtr == nullptr) { - return NULL; + return nullptr; } std::shared_ptr<Command> toReturn = ptr->getCommand(); @@ -161,13 +161,13 @@ std::shared_ptr<Command> CommandList::moveUp(uint _pos) return toReturn; } -std::shared_ptr<Command> CommandList::moveDown(uint _pos) +std::shared_ptr<Command> CommandList::moveDown(unsigned int _pos) { std::shared_ptr<Element> ptr = getElement(_pos); std::shared_ptr<Element> nextPtr = getElement(_pos +1); - if (ptr == NULL | nextPtr == NULL | ptr == root) + if (ptr == nullptr | nextPtr == nullptr | ptr == root) { - return NULL; + return nullptr; } std::shared_ptr<Command> toReturn = ptr->getCommand();