fix load function

This commit is contained in:
2025-04-03 00:31:01 -05:00
parent 494085cdc1
commit 7cce8f6d8e
5 changed files with 36 additions and 26 deletions

View File

@@ -117,14 +117,21 @@ namespace Archimedes {
//insert temporarily to avoid circular dependencies //insert temporarily to avoid circular dependencies
runOrder.insert(roInsert, m->getName()); runOrder.insert(roInsert, m->getName());
for(auto it = runOrder.begin(); it != runOrder.end(); it++) { bool skip = false;
for(auto it : m->deps) {
if(m->deps.find(*it) == m->deps.end()) { for(auto s : runOrder) {
if(std::holds_alternative<std::string>(m->deps[*it])) if(s == it.first) {
m->depsInstances[*it] = load(std::get<std::string>(m->deps[*it])); skip = true;
else }
m->depsInstances[*it] = load(std::get<Module*>(m->deps[*it]));
} }
if(skip)
continue;
if(std::holds_alternative<std::string>(it.second))
m->depsInstances[it.first] = load(std::get<std::string>(it.second));
else
m->depsInstances[it.first] = load(std::get<Module*>(it.second));
} }
//reinsert once final order has been reached //reinsert once final order has been reached
@@ -132,6 +139,9 @@ namespace Archimedes {
runOrder.insert(roInsert, m->getName()); runOrder.insert(roInsert, m->getName());
for(auto s : runOrder)
std::cout << s << std::endl;
return m; return m;
} }

View File

@@ -2,30 +2,26 @@
void ImguiEmbed::run() { void ImguiEmbed::run() {
for(auto* m : modules) { for(auto m : runOrder)
std::cout << "Loading Module: " << m->getName() << std::endl; modules[m]->onLoad();
//if(m->getName() != "WindowModule")
m->onLoad();
}
// Main loop // Main loop
while (!done && !modules.empty()) { while (!done && !runOrder.empty()) {
for(auto* m : modules) { for(auto m : runOrder) {
//std::cout << "Running Module: " << m->getName() << std::endl; modules[m]->run();
//if(m->getName() != "WindowModule")
m->run();
} }
for(auto it = toClose.begin(); it != toClose.end(); it++) { for(auto m : toClose) {
unload(it); unload(m);
} }
toClose.clear(); toClose.clear();
for(std::string s : toOpen) { for(std::string m : toOpen) {
load(s, modules.begin()); load(m);
} }
toOpen.clear(); toOpen.clear();
} }
} }

View File

@@ -13,7 +13,7 @@ class ImguiEmbed : public Archimedes::App {
ImguiEmbed() { ImguiEmbed() {
Archimedes::Module* m = (Archimedes::Module*) new TestImgui(nullptr, Get()); Archimedes::Module* m = (Archimedes::Module*) new TestImgui(nullptr, Get());
load(m, {}); load(m);
}; };
~ImguiEmbed() {}; ~ImguiEmbed() {};

View File

@@ -2,17 +2,19 @@
void MinimalApp::run() { void MinimalApp::run() {
for(auto m : runOrder) for(std::string m : runOrder) {
std::cout << "onLoad module: " << m << std::endl;
modules[m]->onLoad(); modules[m]->onLoad();
}
// Main loop // Main loop
while (!done && !runOrder.empty()) { while (!done && !runOrder.empty()) {
for(auto m : runOrder) { for(std::string m : runOrder) {
modules[m]->run(); modules[m]->run();
} }
for(auto m : toClose) { for(std::string m : toClose) {
unload(m); unload(m);
} }
toClose.clear(); toClose.clear();

View File

@@ -13,8 +13,10 @@ class MinimalApp : public Archimedes::App {
void handleArgs(const int& argc, char* argv[]) { void handleArgs(const int& argc, char* argv[]) {
if(argc > 1) { if(argc > 1) {
for(int i = 1; i < argc; i++) for(int i = 1; i < argc; i++) {
std::cout << "Attempting to load: " << argv[i] << std::endl;
load(dynamicLoad(argv[i])); load(dynamicLoad(argv[i]));
}
} else { } else {
std::cout << "No modules to load\n"; std::cout << "No modules to load\n";
end(); end();