ref: format

This commit is contained in:
Samsonium
2026-09-28 16:48:42 +03:00
parent 737ec46a06
commit 433407cc9d
8 changed files with 41 additions and 19 deletions
+16 -8
View File
@@ -8,33 +8,40 @@
uint16_t MscEngine::REV = 0;
MscEngine::MscEngine(std::vector<std::shared_ptr<MscEngineModule>> modules) {
MscEngine::MscEngine(std::vector<std::shared_ptr<MscEngineModule>> modules)
{
std::unordered_map<std::string, uint16_t> registry;
for (const auto &module : modules) {
for (const auto &module : modules)
{
if (!module)
continue;
auto [it, inserted] =
registry.try_emplace(module->getName(), module->getRev());
if (!inserted) {
if (!inserted)
{
throw std::runtime_error("Duplicate module detected: " +
module->getName());
}
}
for (const auto &module : modules) {
for (const auto &module : modules)
{
if (!module)
continue;
for (const auto &[dep_name, range] : module->getDependencies()) {
for (const auto &[dep_name, range] : module->getDependencies())
{
auto it = registry.find(dep_name);
if (it == registry.end()) {
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)) {
if (!range.isSatisfied(current_rev))
{
throw std::runtime_error(
"Module " + module->getName() + " requires " + dep_name +
" in range [" + std::to_string(range.minRevision) + " <-> " +
@@ -49,6 +56,7 @@ MscEngine::MscEngine(std::vector<std::shared_ptr<MscEngineModule>> modules) {
UNIMPL MscEngine::getBus() const { throw std::runtime_error("Unimplemented"); }
UNIMPL MscEngine::getLoadedModules() const {
UNIMPL MscEngine::getLoadedModules() const
{
throw std::runtime_error("Unimplemented");
}