2017-06-13 21:13:58 +02:00
|
|
|
#pragma once
|
|
|
|
|
2018-08-02 14:23:27 +02:00
|
|
|
#include "common/Singleton.hpp"
|
2018-06-28 19:46:45 +02:00
|
|
|
#include "singletons/Resources.hpp"
|
2017-06-13 21:13:58 +02:00
|
|
|
|
|
|
|
#include <QApplication>
|
2018-08-02 14:23:27 +02:00
|
|
|
#include <memory>
|
2017-06-13 21:13:58 +02:00
|
|
|
|
|
|
|
namespace chatterino {
|
|
|
|
|
2018-04-28 15:20:18 +02:00
|
|
|
class TwitchServer;
|
2018-04-28 15:48:40 +02:00
|
|
|
class PubSub;
|
2018-04-28 15:20:18 +02:00
|
|
|
|
2018-04-30 23:30:05 +02:00
|
|
|
class CommandController;
|
2018-05-06 00:32:45 +02:00
|
|
|
class HighlightController;
|
2018-05-13 19:24:32 +02:00
|
|
|
class IgnoreController;
|
2018-05-26 20:25:00 +02:00
|
|
|
class TaggedUsersController;
|
|
|
|
class AccountController;
|
2018-06-28 19:38:57 +02:00
|
|
|
class ModerationActions;
|
2018-04-27 22:11:19 +02:00
|
|
|
|
2018-06-28 20:03:04 +02:00
|
|
|
class Theme;
|
2018-04-27 22:11:19 +02:00
|
|
|
class WindowManager;
|
2018-06-28 19:51:07 +02:00
|
|
|
class Logging;
|
|
|
|
class Paths;
|
2018-04-27 22:11:19 +02:00
|
|
|
class AccountManager;
|
2018-06-28 19:51:07 +02:00
|
|
|
class Emotes;
|
|
|
|
class Settings;
|
|
|
|
class Fonts;
|
|
|
|
class Resources;
|
2018-04-27 22:11:19 +02:00
|
|
|
|
2017-06-13 21:13:58 +02:00
|
|
|
class Application
|
|
|
|
{
|
2018-08-02 14:23:27 +02:00
|
|
|
std::vector<std::unique_ptr<Singleton>> singletons_;
|
|
|
|
int argc_;
|
|
|
|
char **argv_;
|
2018-04-27 22:11:19 +02:00
|
|
|
|
2017-06-13 21:13:58 +02:00
|
|
|
public:
|
2018-08-02 14:23:27 +02:00
|
|
|
static Application *instance;
|
2018-04-27 22:11:19 +02:00
|
|
|
|
2018-08-02 14:23:27 +02:00
|
|
|
Application(Settings &settings, Paths &paths);
|
2018-04-27 22:11:19 +02:00
|
|
|
|
2018-08-02 14:23:27 +02:00
|
|
|
void initialize(Settings &settings, Paths &paths);
|
2018-04-27 22:11:19 +02:00
|
|
|
void load();
|
2018-08-02 14:23:27 +02:00
|
|
|
void save();
|
2017-06-13 21:13:58 +02:00
|
|
|
|
|
|
|
int run(QApplication &qtApp);
|
|
|
|
|
2018-04-28 15:20:18 +02:00
|
|
|
friend void test();
|
|
|
|
|
2018-08-02 14:23:27 +02:00
|
|
|
Settings *const settings = nullptr;
|
|
|
|
Paths *const paths = nullptr;
|
|
|
|
Resources2 *const resources;
|
|
|
|
|
|
|
|
Theme *const themes = nullptr;
|
|
|
|
Fonts *const fonts = nullptr;
|
|
|
|
Emotes *const emotes = nullptr;
|
|
|
|
WindowManager *const windows = nullptr;
|
|
|
|
|
|
|
|
AccountController *const accounts = nullptr;
|
|
|
|
CommandController *const commands = nullptr;
|
|
|
|
HighlightController *const highlights = nullptr;
|
|
|
|
IgnoreController *const ignores = nullptr;
|
|
|
|
TaggedUsersController *const taggedUsers = nullptr;
|
|
|
|
ModerationActions *const moderationActions = nullptr;
|
|
|
|
TwitchServer *const twitch2 = nullptr;
|
|
|
|
|
|
|
|
[[deprecated]] Logging *const logging = nullptr;
|
2018-04-28 15:20:18 +02:00
|
|
|
|
|
|
|
/// Provider-specific
|
|
|
|
struct {
|
2018-07-07 11:41:01 +02:00
|
|
|
[[deprecated("use twitch2 instead")]] TwitchServer *server = nullptr;
|
|
|
|
[[deprecated("use twitch2->pubsub instead")]] PubSub *pubsub = nullptr;
|
2018-04-28 15:20:18 +02:00
|
|
|
} twitch;
|
2018-04-27 22:11:19 +02:00
|
|
|
|
|
|
|
private:
|
2018-07-07 11:41:01 +02:00
|
|
|
void addSingleton(Singleton *singleton);
|
2018-08-02 14:23:27 +02:00
|
|
|
void initPubsub();
|
|
|
|
void initNm();
|
|
|
|
|
2018-08-06 21:17:03 +02:00
|
|
|
template <typename T,
|
|
|
|
typename = std::enable_if_t<std::is_base_of<Singleton, T>::value>>
|
2018-08-02 14:23:27 +02:00
|
|
|
T &emplace()
|
|
|
|
{
|
|
|
|
auto t = new T;
|
|
|
|
this->singletons_.push_back(std::unique_ptr<T>(t));
|
|
|
|
return *t;
|
|
|
|
}
|
2017-06-13 21:13:58 +02:00
|
|
|
};
|
|
|
|
|
2018-04-27 22:11:19 +02:00
|
|
|
Application *getApp();
|
|
|
|
|
2017-06-13 21:13:58 +02:00
|
|
|
} // namespace chatterino
|