File tree Expand file tree Collapse file tree 3 files changed +24
-1
lines changed Expand file tree Collapse file tree 3 files changed +24
-1
lines changed Original file line number Diff line number Diff line change 1+ " hello world"
Original file line number Diff line number Diff line change 11#include < imgui.h>
22#include < app.hpp>
3+ #include < djson/json.hpp>
4+ #include < log.hpp>
35
46namespace miracle {
57namespace {
@@ -8,7 +10,13 @@ constexpr auto context_ci = le::Context::CreateInfo{
810};
911} // namespace
1012
11- App::App () : m_context(context_ci) {}
13+ App::App () : m_context(context_ci), m_data_loader(le::FileDataLoader::upfind(" assets" )) {
14+ bind_services ();
15+
16+ // test code, remove later.
17+ auto json = dj::Json{};
18+ if (m_services.get <le::IDataLoader>().load_json (json, " test_file.json" )) { log.info (" loaded JSON: {}" , json); }
19+ }
1220
1321void App::run () {
1422 while (m_context.is_running ()) {
@@ -19,4 +27,11 @@ void App::run() {
1927 m_context.present ();
2028 }
2129}
30+
31+ void App::bind_services () {
32+ m_services.bind (&m_context);
33+ // m_data_loader is bound to both the interface and the concrete class for use through either type.
34+ m_services.bind <le::IDataLoader>(&m_data_loader);
35+ m_services.bind <le::FileDataLoader>(&m_data_loader);
36+ }
2237} // namespace miracle
Original file line number Diff line number Diff line change 11#pragma once
22#include < le2d/context.hpp>
3+ #include < le2d/file_data_loader.hpp>
4+ #include < le2d/service_locator.hpp>
35
46namespace miracle {
57class App {
@@ -9,6 +11,11 @@ class App {
911 void run ();
1012
1113 private:
14+ void bind_services ();
15+
1216 le::Context m_context;
17+ le::FileDataLoader m_data_loader{};
18+
19+ le::ServiceLocator m_services{};
1320};
1421} // namespace miracle
You can’t perform that action at this time.
0 commit comments