jay/jay.h

48 lines
1.0 KiB
C
Raw Normal View History

2024-03-30 22:44:52 -03:00
// SPDX-FileCopyrightText: 2024 Yury Gubich <blue@macaw.me>
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
#include <string>
#include <iostream>
#include <vector>
#include <memory>
2025-02-22 21:03:21 +02:00
#include <mutex>
2024-03-30 22:44:52 -03:00
#include <gloox/client.h>
2025-02-22 21:03:21 +02:00
#include <gloox/disco.h>
2025-02-21 23:01:11 +02:00
#include <gloox/connectionlistener.h>
2024-03-30 22:44:52 -03:00
2025-03-02 21:33:22 +02:00
#include "component/logger.h"
#include "component/config.h"
#include "component/actor.h"
#include "handler/message.h"
#include "handler/connection.h"
2024-03-30 22:44:52 -03:00
2025-02-22 21:03:21 +02:00
class Jay {
2024-03-30 22:44:52 -03:00
public:
2025-02-22 21:03:21 +02:00
Jay(const std::string& configPath);
2024-03-30 22:44:52 -03:00
~Jay();
2025-02-22 21:03:21 +02:00
bool isConfigValid() const;
2024-03-30 22:44:52 -03:00
void run();
2025-02-22 21:03:21 +02:00
private:
void addLogger(gloox::LogLevel level);
void initialize();
void createClient();
2025-03-02 21:33:22 +02:00
void createActors();
2024-03-30 22:44:52 -03:00
private:
2025-03-02 21:33:22 +02:00
typedef std::map<std::string, std::unique_ptr<Actor>> Actors;
2025-02-22 21:03:21 +02:00
std::mutex runMutex;
std::shared_ptr<Config> config;
std::shared_ptr<gloox::Client> client;
std::unique_ptr<Message> messageHandler;
std::unique_ptr<Connection> connectionHandler;
2024-03-30 22:44:52 -03:00
std::vector<std::unique_ptr<Logger>> loggers;
2025-03-02 21:33:22 +02:00
Actors actors;
2024-03-30 22:44:52 -03:00
};