// 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 std::shared_ptr& ) > > moduleNames = { {"actor", [](const std::shared_ptr& core, const std::shared_ptr& connection) { return std::make_shared(core, connection); }} }; 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() { connection->initiialize(); createModules(); createActors(); } void Jay::createActors() { for (const std::pair& pair : core->config.getActors()) core->router.registerActor(pair.first, pair.second); } void Jay::createModules() { for (const auto& pair : moduleNames) { Config::Module conf = core->config.getModuleConfig(pair.first); if (!conf.enabled) continue; modules.emplace_back(pair.second(core, connection)); core->router.registerModule(pair.first, modules.back()); } }