generated from Rythe-Interactive/Rythe-Module-Template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
63 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,8 +16,8 @@ | |
namespace rythe | ||
{ | ||
namespace core | ||
{ | ||
} | ||
} | ||
{ | ||
} | ||
} // namespace rythe | ||
|
||
namespace rte = rythe; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,85 +1,78 @@ | ||
#pragma once | ||
#include <memory> | ||
#include <unordered_map> | ||
#include <vector> | ||
#include <memory> | ||
|
||
#include <rsl/primitives> | ||
#include <rsl/logging> | ||
#include <rsl/primitives> | ||
|
||
namespace rythe::core | ||
{ | ||
class Program; | ||
class Program; | ||
|
||
class Engine | ||
{ | ||
private: | ||
Program* programPtr = nullptr; | ||
rsl::id_type engineId = 0; | ||
|
||
public: | ||
Engine(rsl::id_type id) | ||
: engineId(id) | ||
{ | ||
} | ||
|
||
class Engine | ||
{ | ||
private: | ||
Program* programPtr = nullptr; | ||
rsl::id_type engineId = 0; | ||
public: | ||
Engine(rsl::id_type id) : engineId(id) {} | ||
void setup(Program* ptr); | ||
|
||
void setup(Program* ptr); | ||
void update() { rsl::log::debug("Engine[{}] Update", engineId); } | ||
|
||
void update() | ||
{ | ||
rsl::log::debug("Engine[{}] Update", engineId); | ||
} | ||
void shutdown() { rsl::log::debug("Engine[{}] Shutdown", engineId); } | ||
}; | ||
|
||
void shutdown() | ||
{ | ||
rsl::log::debug("Engine[{}] Shutdown", engineId); | ||
} | ||
}; | ||
class Program | ||
{ | ||
private: | ||
std::unordered_map<rsl::id_type, std::unique_ptr<Engine>> m_engines; | ||
rsl::id_type m_lastIdx = 0; | ||
bool m_running = false; | ||
|
||
class Program | ||
{ | ||
private: | ||
std::unordered_map<rsl::id_type, std::unique_ptr<Engine>> m_engines; | ||
rsl::id_type m_lastIdx = 0; | ||
bool m_running = false; | ||
public: | ||
void initialize() | ||
{ | ||
rsl::log::debug("Initializing Program Instance"); | ||
for (auto& [id, engine] : m_engines) | ||
{ | ||
engine->setup(this); | ||
} | ||
m_running = true; | ||
} | ||
public: | ||
void initialize() | ||
{ | ||
rsl::log::debug("Initializing Program Instance"); | ||
for (auto& [id, engine] : m_engines) | ||
{ | ||
engine->setup(this); | ||
} | ||
m_running = true; | ||
} | ||
|
||
void update() | ||
{ | ||
//In the final version the updates will be handled by a process chain | ||
rsl::log::debug("Program Update"); | ||
for (auto& [id, engine] : m_engines) | ||
{ | ||
engine->update(); | ||
} | ||
} | ||
void update() | ||
{ | ||
// In the final version the updates will be handled by a process chain | ||
rsl::log::debug("Program Update"); | ||
for (auto& [id, engine] : m_engines) | ||
{ | ||
engine->update(); | ||
} | ||
} | ||
|
||
void shutdown() | ||
{ | ||
rsl::log::debug("Program Shutdown"); | ||
for (auto& [id, engine] : m_engines) | ||
{ | ||
engine->shutdown(); | ||
} | ||
} | ||
void shutdown() | ||
{ | ||
rsl::log::debug("Program Shutdown"); | ||
for (auto& [id, engine] : m_engines) | ||
{ | ||
engine->shutdown(); | ||
} | ||
} | ||
|
||
bool isRunning() | ||
{ | ||
return m_running; | ||
} | ||
bool isRunning() { return m_running; } | ||
|
||
void stop() | ||
{ | ||
m_running = false; | ||
} | ||
void stop() { m_running = false; } | ||
|
||
Engine& addEngineInstance() | ||
{ | ||
return *(m_engines.emplace(m_lastIdx, std::make_unique<Engine>(Engine{ m_lastIdx++})).first->second); | ||
} | ||
}; | ||
} | ||
Engine& addEngineInstance() | ||
{ | ||
return *(m_engines.emplace(m_lastIdx, std::make_unique<Engine>(Engine{m_lastIdx++})).first->second); | ||
} | ||
}; | ||
} // namespace rythe::core |