// SPDX-FileCopyrightText: 2024 Yury Gubich // SPDX-License-Identifier: GPL-3.0-or-later #include "jay.h" #include "module/actor.h" static const std::map< std::string, std::function< std::shared_ptr( const std::shared_ptr&, const Shared::Permissions& permissions ) > > moduleNames = { {"actor", []( const std::shared_ptr& core, const Shared::Permissions& permissions ) { return std::make_shared(core, permissions); }} }; Jay::Jay(const std::string& configPath): core(std::make_shared(configPath)), connection(std::make_shared(core)), modules() {} Jay::~Jay() { connection->deinitialize(); } bool Jay::isConfigValid() const { return core->config.isValid(); } void Jay::run() { initialize(); connection->connect(); } void Jay::initialize() { createModules(); core->initialize(connection); connection->initialize(); } void Jay::createModules() { for (const auto& pair : moduleNames) { Config::Module conf = core->config.getModuleConfig(pair.first); if (!conf.enabled) continue; core->logger.log(Logger::info, "enabling module " + pair.first, {"Jay"}); modules.emplace_back(pair.second(core, conf.permissions)); core->router.registerModule(pair.first, modules.back()); } }