mirror-chatterino2/src/Application.hpp

90 lines
1.9 KiB
C++
Raw Normal View History

#pragma once
2018-08-02 14:23:27 +02:00
#include "common/Singleton.hpp"
#include <QApplication>
2018-08-02 14:23:27 +02:00
#include <memory>
namespace chatterino {
class TwitchServer;
class PubSub;
class CommandController;
class HighlightController;
2018-05-13 19:24:32 +02:00
class IgnoreController;
class TaggedUsersController;
class AccountController;
class ModerationActions;
2018-06-28 20:03:04 +02:00
class Theme;
class WindowManager;
2018-06-28 19:51:07 +02:00
class Logging;
class Paths;
class AccountManager;
2018-06-28 19:51:07 +02:00
class Emotes;
class Settings;
class Fonts;
class Resources2;
class Application
{
2018-08-02 14:23:27 +02:00
std::vector<std::unique_ptr<Singleton>> singletons_;
int argc_;
char **argv_;
public:
2018-08-02 14:23:27 +02:00
static Application *instance;
2018-08-02 14:23:27 +02:00
Application(Settings &settings, Paths &paths);
2018-08-02 14:23:27 +02:00
void initialize(Settings &settings, Paths &paths);
void load();
2018-08-02 14:23:27 +02:00
void save();
int run(QApplication &qtApp);
friend void test();
2018-08-02 14:23:27 +02:00
Resources2 *const resources;
2018-08-07 01:35:24 +02:00
Theme *const themes{};
Fonts *const fonts{};
Emotes *const emotes{};
WindowManager *const windows{};
2018-08-02 14:23:27 +02:00
2018-08-07 01:35:24 +02:00
AccountController *const accounts{};
CommandController *const commands{};
HighlightController *const highlights{};
IgnoreController *const ignores{};
TaggedUsersController *const taggedUsers{};
ModerationActions *const moderationActions{};
TwitchServer *const twitch2{};
2018-08-02 14:23:27 +02:00
2018-08-07 01:35:24 +02:00
/*[[deprecated]]*/ Logging *const logging{};
/// Provider-specific
struct {
2018-08-07 01:35:24 +02:00
/*[[deprecated("use twitch2 instead")]]*/ TwitchServer *server{};
/*[[deprecated("use twitch2->pubsub instead")]]*/ PubSub *pubsub{};
} twitch;
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;
}
};
Application *getApp();
} // namespace chatterino