File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -11,8 +11,11 @@ constexpr auto context_ci = le::Context::CreateInfo{
11
11
} // namespace
12
12
13
13
App::App () : m_context(context_ci), m_data_loader(le::FileDataLoader::upfind(" assets" )) {
14
+ bind_services ();
15
+
14
16
// test code, remove later.
15
- if (auto json = dj::Json{}; m_data_loader.load_json (json, " test_file.json" )) { log.info (" loaded JSON: {}" , json); }
17
+ auto json = dj::Json{};
18
+ if (m_services.get <le::IDataLoader>().load_json (json, " test_file.json" )) { log.info (" loaded JSON: {}" , json); }
16
19
}
17
20
18
21
void App::run () {
@@ -24,4 +27,11 @@ void App::run() {
24
27
m_context.present ();
25
28
}
26
29
}
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
+ }
27
37
} // namespace miracle
Original file line number Diff line number Diff line change 1
1
#pragma once
2
2
#include < le2d/context.hpp>
3
3
#include < le2d/file_data_loader.hpp>
4
+ #include < le2d/service_locator.hpp>
4
5
5
6
namespace miracle {
6
7
class App {
@@ -10,7 +11,11 @@ class App {
10
11
void run ();
11
12
12
13
private:
14
+ void bind_services ();
15
+
13
16
le::Context m_context;
14
17
le::FileDataLoader m_data_loader{};
18
+
19
+ le::ServiceLocator m_services{};
15
20
};
16
21
} // namespace miracle
You can’t perform that action at this time.
0 commit comments