[Added] Headerfiles

This commit is contained in:
Ninjaws
2024-12-07 00:28:25 +01:00
parent 5d2251c0f4
commit 8d1c3bc429
61 changed files with 270 additions and 1 deletions
+81
View File
@@ -0,0 +1,81 @@
#ifndef STATE_SERVICE_H
#define STATE_SERVICE_H
#include "Screen.h"
#include "ScreenState.h"
#include <iostream>
#include <memory>
#if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h>
#endif
class StateService
{
private:
std::unique_ptr<Screen> currentScreen;
static StateService* instance;
// StateService() {}
// StateService() = default;
// friend StateService* StateService::getInstance();
StateService()
{
std::cout << "Singleton instance created."
<< std::endl;
}
// Private destructor to prevent external deletion
~StateService()
{
std::cout << "Singleton instance destroyed."
<< std::endl;
}
public:
StateService(const StateService&) = delete;
StateService& operator=(const StateService&) = delete;
// ~StateService() = default;
// StateService(const StateService &) = delete;
// StateService &operator=(const StateService &) = delete;
// StateService& myStateService = StateService::instance();
// StateService(const StateService&) = delete;
// StateService& operator=(const StateService&) = delete;
// static StateService* getInstance();
// static std::shared_ptr<StateService> getInstance() {
// static std::shared_ptr<StateService> instance = std::make_shared<StateService>();
// return instance;
// }
static StateService& getInstance()
{
if (instance == nullptr) {
instance = new StateService();
}
return *instance;
}
// static StateService* getInstance();
// {
// if (!instance)
// {
// instance = std::make_unique<StateService>(); // This works because of the friend declaration
// }
// return instance.get(); // Return the raw pointer of the unique_ptr
// }
void setScreen(ScreenState screen);
Screen *getScreen();
void gameloop();
};
// StateService* StateService::instance = nullptr;
// std::unique_ptr<StateService> StateService::instance = nullptr;
#endif