MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / Plugin

Method Plugin

src/Core/System/Plugin.cpp:8–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6namespace obe::System
7{
8 Plugin::Plugin(const std::string& id, const std::string& path)
9 : Types::Identifiable(id)
10 {
11 m_hasOnInitFn = false;
12 m_hasOnLoadBindingsFn = false;
13 m_hasOnUpdateFn = false;
14 m_hasOnRenderFn = false;
15 m_hasOnExitFn = false;
16 Debug::Log->info("<System:Plugin> : Loading Plugin '{}' ...", id);
17 try
18 {
19 m_dl = dynamicLinker::dynamicLinker::make_new(path);
20 m_dl->open();
21 }
22 catch (const dynamicLinker::dynamicLinkerException& e)
23 {
24 Debug::Log->warn(
25 "<System:Plugin> : Unloadable Plugin : '{}' (Reason : {})", id, e.what());
26 }
27 try
28 {
29 m_onInitFn = getPluginFunction<void()>(m_dl, "OnInit");
30 m_onInitFn->init();
31 Debug::Log->debug(
32 "<System:Plugins> : (Plugin '{}') > Found function OnInit", id);
33 m_hasOnInitFn = true;
34 m_onInitFn->operator()();
35 }
36 catch (const dynamicLinker::dynamicLinkerException& e)
37 {
38 }
39 try
40 {
41 m_onLoadBindingsFn
42 = getPluginFunction<void(sol::state_view)>(m_dl, "OnLoadBindings");
43 m_onLoadBindingsFn->init();
44 m_hasOnLoadBindingsFn = true;
45 Debug::Log->debug("<System:Plugins> : (Plugin '{}') > Found "
46 "function OnLoadBindings",
47 id);
48 }
49 catch (const dynamicLinker::dynamicLinkerException& e)
50 {
51 }
52 try
53 {
54 m_onUpdateFn = getPluginFunction<void(double)>(m_dl, "OnUpdate");
55 m_onUpdateFn->init();
56 m_hasOnUpdateFn = true;
57 Debug::Log->debug(
58 "<System:Plugins> : (Plugin '{}') > Found function OnUpdate", id);
59 }
60 catch (const dynamicLinker::dynamicLinkerException& e)
61 {
62 }
63 try
64 {
65 m_onRenderFn = getPluginFunction<void()>(m_dl, "OnRender");

Callers

nothing calls this directly

Calls 7

infoMethod · 0.80
warnMethod · 0.80
debugMethod · 0.80
openMethod · 0.45
whatMethod · 0.45
initMethod · 0.45
operator()Method · 0.45

Tested by

no test coverage detected