Skip to content

Commit

Permalink
add engine and program context, stop assertion of startup errors
Browse files Browse the repository at this point in the history
  • Loading branch information
GlynLeine committed Dec 11, 2024
1 parent b3ec839 commit 64574ff
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
10 changes: 7 additions & 3 deletions src/core/entry/entry_point.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,15 @@ int main(int argc, char** argv)
rsl::log::setup();
rythe::core::Program program;

if (auto errorCode = init_program(program).report_errors(); errorCode != rsl::no_error_code)
{
return static_cast<int>(errorCode);
}
auto result = init_program(program);
rsl::scoped_assert_on_error saoe(false);

if (auto errorCode = result.report_errors(); errorCode != rsl::no_error_code)
{
return static_cast<int>(errorCode);
}
}
program.initialize();

while (program.isRunning())
Expand Down
4 changes: 2 additions & 2 deletions src/core/program/program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace rythe::core
{
void Engine::setup(Program* ptr)
{
rsl::log::debug("Engine[{}] Instance initialized", engineId);
programPtr = ptr;
rsl::log::debug("Engine[{}] Instance initialized", m_engineId);
m_programPtr = ptr;
}
} // namespace rythe::core
20 changes: 15 additions & 5 deletions src/core/program/program.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

#include <rsl/logging>
#include <rsl/primitives>
#include <rsl/type_traits>
#include <rsl/type_map>

namespace rythe::core
{
Expand All @@ -13,26 +15,31 @@ namespace rythe::core
class Engine
{
private:
Program* programPtr = nullptr;
rsl::id_type engineId = 0;
Program* m_programPtr = nullptr;
rsl::id_type m_engineId = 0;
rsl::type_map m_context;

public:
Engine(rsl::id_type id)
: engineId(id)
: m_engineId(id)
{
}

void setup(Program* ptr);

void update() { rsl::log::debug("Engine[{}] Update", engineId); }
void update() { rsl::log::debug("Engine[{}] Update", m_engineId); }

void shutdown() { rsl::log::debug("Engine[{}] Shutdown", engineId); }
void shutdown() { rsl::log::debug("Engine[{}] Shutdown", m_engineId); }

rsl::type_map& get_context() noexcept { return m_context; }
const rsl::type_map& get_context() const noexcept { return m_context; }
};

class Program
{
private:
std::unordered_map<rsl::id_type, std::unique_ptr<Engine>> m_engines;
rsl::type_map m_context;
rsl::id_type m_lastIdx = 0;
bool m_running = false;

Expand Down Expand Up @@ -66,6 +73,9 @@ namespace rythe::core
}
}

rsl::type_map& get_context() noexcept { return m_context; }
const rsl::type_map& get_context() const noexcept { return m_context; }

[[rythe_always_inline]] bool isRunning() { return m_running; }

[[rythe_always_inline]] void stop() { m_running = false; }
Expand Down

0 comments on commit 64574ff

Please sign in to comment.