6 Commits
d65336ccd4
...
cdc9546de9
Author | SHA1 | Message | Date |
---|---|---|---|
leo | cdc9546de9 |
remove remaining this references + fix shared_ptr bug in WarenStorage + remove some unneccessary spaces
|
3 years ago |
leo | 30fd226169 |
remove unneccessary this-> prefixes
|
3 years ago |
leo | 56462a851b |
fix memory copying issues
|
3 years ago |
leo | 7b702aa1f7 |
make input manager use shared_pointer of storage editor instead of copy
|
3 years ago |
leo | 1ac6fcacbd |
Change enum to enum class
|
3 years ago |
leo | b1fdcec0c8 |
add cmake files to git ignore & change directory structure to module based approach
|
3 years ago |
14 changed files with 111 additions and 109 deletions
-
6.gitignore
-
8CMakeLists.txt
-
47src/InputManager/InputManager.cpp
-
17src/InputManager/InputManager.h
-
31src/StorageEditor/StorageEditor.cpp
-
27src/StorageEditor/StorageEditor.h
-
8src/Ware/Ware.cpp
-
2src/Ware/Ware.h
-
4src/WarenStorage/WarenStorage.cpp
-
8src/WarenStorage/WarenStorage.h
-
26src/header-files/StorageEditor.h
-
6src/main.cpp
-
0src/pch.h
-
30src/source-files/StorageEditor.cpp
@ -1 +1,7 @@ |
|||
.vimspector.json |
|||
CMakeFiles |
|||
CMakeCache.txt |
|||
cmake_install.cmake |
|||
CMakeLists.txt |
|||
kaufland |
|||
Makefile |
@ -0,0 +1,31 @@ |
|||
#include "StorageEditor.h"
|
|||
|
|||
StorageEditor::StorageEditor() { } |
|||
|
|||
StorageEditor::StorageEditor(std::shared_ptr<WarenStorage> storage) { |
|||
this->storage = storage; |
|||
} |
|||
|
|||
std::shared_ptr<WarenStorage> StorageEditor::getWarenStorage() const { |
|||
return storage; |
|||
} |
|||
|
|||
void StorageEditor::setWarenStorage(const WarenStorage storage) { |
|||
//move might be unnecessary here
|
|||
this->storage = std::make_shared<WarenStorage>(std::move(storage)); |
|||
} |
|||
|
|||
|
|||
void StorageEditor::addWaren(const Ware ware, int amount) { |
|||
for(auto i = 0; i < amount; i++) { |
|||
storage->addWareAndGenerateId(ware); |
|||
} |
|||
} |
|||
|
|||
|
|||
void StorageEditor::removeWaren(const std::string& name, const int amount) { |
|||
for(auto i = 0; i < amount; i++) { |
|||
storage->removeWare(name); |
|||
} |
|||
} |
|||
|
@ -0,0 +1,27 @@ |
|||
#include "../pch.h" |
|||
#include <memory> |
|||
#include "../WarenStorage/WarenStorage.h" |
|||
|
|||
class StorageEditor { |
|||
private: |
|||
|
|||
std::shared_ptr<WarenStorage> storage; |
|||
|
|||
public: |
|||
|
|||
StorageEditor(); |
|||
|
|||
StorageEditor(std::shared_ptr<WarenStorage> storage); |
|||
|
|||
std::shared_ptr<WarenStorage> getWarenStorage() const; |
|||
|
|||
void setWarenStorage(const WarenStorage storage); |
|||
|
|||
void addWareAndGenerateId(Ware ware); |
|||
|
|||
void addWaren(const Ware ware, int amount); |
|||
|
|||
void removeWare(const std::string& name); |
|||
|
|||
void removeWaren(const std::string& name, int amount); |
|||
}; |
@ -1,26 +0,0 @@ |
|||
#include "pch.h" |
|||
#include "data-classes/WarenStorage.h" |
|||
|
|||
class StorageEditor { |
|||
private: |
|||
|
|||
WarenStorage storage; |
|||
|
|||
public: |
|||
|
|||
StorageEditor(); |
|||
|
|||
StorageEditor(WarenStorage storage); |
|||
|
|||
WarenStorage getWarenStorage() const; |
|||
|
|||
void setWarenStorage(const WarenStorage storage); |
|||
|
|||
void addWareAndGenerateId(Ware ware); |
|||
|
|||
void addWaren(const Ware ware, int amount); |
|||
|
|||
void removeWare(std::string name); |
|||
|
|||
void removeWaren(std::string name, int amount); |
|||
}; |
@ -1,30 +0,0 @@ |
|||
#include "../header-files/StorageEditor.h"
|
|||
|
|||
StorageEditor::StorageEditor() { } |
|||
|
|||
StorageEditor::StorageEditor(const WarenStorage storage) { |
|||
this->storage = storage; |
|||
} |
|||
|
|||
WarenStorage StorageEditor::getWarenStorage() const { |
|||
return storage; |
|||
} |
|||
|
|||
void StorageEditor::setWarenStorage(const WarenStorage storage) { |
|||
this->storage = storage; |
|||
} |
|||
|
|||
|
|||
void StorageEditor::addWaren(const Ware ware, int amount) { |
|||
for(auto i = 0; i < amount; i++) { |
|||
storage.addWareAndGenerateId(ware); |
|||
} |
|||
} |
|||
|
|||
|
|||
void StorageEditor::removeWaren(std::string name, const int amount) { |
|||
for(auto i = 0; i < amount; i++) { |
|||
storage.removeWare(name); |
|||
} |
|||
} |
|||
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue