#pragma once #include "common/Singleton.hpp" #include "singletons/NativeMessaging.hpp" #include #include #include #include namespace chatterino { class TwitchIrcServer; class ITwitchIrcServer; class PubSub; class CommandController; class AccountController; class NotificationController; class HighlightController; class HotkeyController; class IUserDataController; class UserDataController; class SoundController; class ITwitchLiveController; class TwitchLiveController; #ifdef CHATTERINO_HAVE_PLUGINS class PluginController; #endif class Theme; class WindowManager; class Logging; class Paths; class Emotes; class IEmotes; class Settings; class Fonts; class Toasts; class ChatterinoBadges; class FfzBadges; class SeventvBadges; class ImageUploader; class SeventvAPI; class IApplication { public: IApplication(); virtual ~IApplication() = default; static IApplication *instance; virtual Theme *getThemes() = 0; virtual Fonts *getFonts() = 0; virtual IEmotes *getEmotes() = 0; virtual AccountController *getAccounts() = 0; virtual HotkeyController *getHotkeys() = 0; virtual WindowManager *getWindows() = 0; virtual Toasts *getToasts() = 0; virtual CommandController *getCommands() = 0; virtual HighlightController *getHighlights() = 0; virtual NotificationController *getNotifications() = 0; virtual ITwitchIrcServer *getTwitch() = 0; virtual ChatterinoBadges *getChatterinoBadges() = 0; virtual FfzBadges *getFfzBadges() = 0; virtual SeventvBadges *getSeventvBadges() = 0; virtual IUserDataController *getUserData() = 0; virtual ITwitchLiveController *getTwitchLiveController() = 0; virtual ImageUploader *getImageUploader() = 0; virtual SeventvAPI *getSeventvAPI() = 0; }; class Application : public IApplication { std::vector> singletons_; int argc_{}; char **argv_{}; public: static Application *instance; Application(Settings &settings, Paths &paths); void initialize(Settings &settings, Paths &paths); void load(); void save(); int run(QApplication &qtApp); friend void test(); Theme *const themes{}; Fonts *const fonts{}; Emotes *const emotes{}; AccountController *const accounts{}; HotkeyController *const hotkeys{}; WindowManager *const windows{}; Toasts *const toasts{}; ImageUploader *const imageUploader{}; SeventvAPI *const seventvAPI{}; CommandController *const commands{}; NotificationController *const notifications{}; HighlightController *const highlights{}; TwitchIrcServer *const twitch{}; ChatterinoBadges *const chatterinoBadges{}; FfzBadges *const ffzBadges{}; SeventvBadges *const seventvBadges{}; UserDataController *const userData{}; SoundController *const sound{}; private: TwitchLiveController *const twitchLiveController{}; public: #ifdef CHATTERINO_HAVE_PLUGINS PluginController *const plugins{}; #endif /*[[deprecated]]*/ Logging *const logging{}; Theme *getThemes() override { return this->themes; } Fonts *getFonts() override { return this->fonts; } IEmotes *getEmotes() override; AccountController *getAccounts() override { return this->accounts; } HotkeyController *getHotkeys() override { return this->hotkeys; } WindowManager *getWindows() override { return this->windows; } Toasts *getToasts() override { return this->toasts; } CommandController *getCommands() override { return this->commands; } NotificationController *getNotifications() override { return this->notifications; } HighlightController *getHighlights() override { return this->highlights; } ITwitchIrcServer *getTwitch() override; ChatterinoBadges *getChatterinoBadges() override { return this->chatterinoBadges; } FfzBadges *getFfzBadges() override { return this->ffzBadges; } SeventvBadges *getSeventvBadges() override { return this->seventvBadges; } IUserDataController *getUserData() override; ITwitchLiveController *getTwitchLiveController() override; ImageUploader *getImageUploader() override { return this->imageUploader; } SeventvAPI *getSeventvAPI() override { return this->seventvAPI; } pajlada::Signals::NoArgSignal streamerModeChanged; private: void addSingleton(Singleton *singleton); void initPubSub(); void initBttvLiveUpdates(); void initSeventvEventAPI(); void initNm(Paths &paths); template ::value>> T &emplace() { auto t = new T; this->singletons_.push_back(std::unique_ptr(t)); return *t; } NativeMessagingServer nmServer{}; }; Application *getApp(); // Get an interface version of the Application class - should be preferred when possible for new code IApplication *getIApp(); } // namespace chatterino