Browse Source

make input manager use shared_pointer of storage editor instead of copy

master
leo 3 years ago
parent
commit
7b702aa1f7
  1. 8
      src/InputManager/InputManager.cpp
  2. 5
      src/InputManager/InputManager.h

8
src/InputManager/InputManager.cpp

@ -2,7 +2,7 @@
#include <exception>
#include <sstream>
InputManager::InputManager(StorageEditor storageEditor) {
InputManager::InputManager(std::shared_ptr<StorageEditor> storageEditor) {
this->editor = storageEditor;
}
@ -91,16 +91,16 @@ void InputManager::displayMainMenu() {
switch(selectedOption) {
case 1: {
InputManager::WareAndAmount x = displayAddWareDialog();
editor.addWaren(x.ware, x.amount);
editor->addWaren(x.ware, x.amount);
break;
}
case 2: {
InputManager::WareAndAmount x = displayRemoveWareDialog();
editor.removeWaren(x.ware.getName(), x.amount);
editor->removeWaren(x.ware.getName(), x.amount);
break;
}
case 3: {
std::vector<Ware> waren = this->editor.getWarenStorage().getAllWaren();
std::vector<Ware> waren = this->editor->getWarenStorage().getAllWaren();
displayWaren(waren);
break;
}

5
src/InputManager/InputManager.h

@ -1,5 +1,6 @@
#include "../pch.h"
#include "../StorageEditor/StorageEditor.h"
#include <memory>
class InputManager {
@ -7,7 +8,7 @@ class InputManager {
typedef int MenuOption;
private:
StorageEditor editor;
std::shared_ptr<StorageEditor> editor;
MenuOption selectedOption;
@ -22,7 +23,7 @@ class InputManager {
public:
InputManager(StorageEditor storageEditor);
InputManager(std::shared_ptr<StorageEditor> storageEditor);
void displayMainMenu();

Loading…
Cancel
Save