Initial commit

This commit is contained in:
Samsonium
2026-09-28 14:46:25 +03:00
commit 737ec46a06
13 changed files with 247 additions and 0 deletions
+54
View File
@@ -0,0 +1,54 @@
#include <cstdint>
#include <engine/core/engine.hpp>
#include <memory>
#include <stdexcept>
#include <string>
#include <unordered_map>
#include <vector>
uint16_t MscEngine::REV = 0;
MscEngine::MscEngine(std::vector<std::shared_ptr<MscEngineModule>> modules) {
std::unordered_map<std::string, uint16_t> registry;
for (const auto &module : modules) {
if (!module)
continue;
auto [it, inserted] =
registry.try_emplace(module->getName(), module->getRev());
if (!inserted) {
throw std::runtime_error("Duplicate module detected: " +
module->getName());
}
}
for (const auto &module : modules) {
if (!module)
continue;
for (const auto &[dep_name, range] : module->getDependencies()) {
auto it = registry.find(dep_name);
if (it == registry.end()) {
throw std::runtime_error("Module " + module->getName() +
" requires missing module: " + dep_name);
}
int current_rev = it->second;
if (!range.isSatisfied(current_rev)) {
throw std::runtime_error(
"Module " + module->getName() + " requires " + dep_name +
" in range [" + std::to_string(range.minRevision) + " <-> " +
std::to_string(range.maxRevision) + "], but got rev" +
std::to_string(current_rev));
}
}
}
_modules = std::move(modules);
}
UNIMPL MscEngine::getBus() const { throw std::runtime_error("Unimplemented"); }
UNIMPL MscEngine::getLoadedModules() const {
throw std::runtime_error("Unimplemented");
}