diff --git a/cockatrice/CMakeLists.txt b/cockatrice/CMakeLists.txt index b047b0ca6..40a3639e0 100644 --- a/cockatrice/CMakeLists.txt +++ b/cockatrice/CMakeLists.txt @@ -31,6 +31,7 @@ set(cockatrice_SOURCES src/server/chat_view/chat_view.cpp src/game/board/counter_general.cpp src/deck/custom_line_edit.cpp + src/deck/deck_edit_event_bus.cpp src/deck/deck_loader.cpp src/deck/deck_list_model.cpp src/deck/deck_stats_interface.cpp diff --git a/cockatrice/src/deck/deck_edit_event_bus.cpp b/cockatrice/src/deck/deck_edit_event_bus.cpp new file mode 100644 index 000000000..c220461cd --- /dev/null +++ b/cockatrice/src/deck/deck_edit_event_bus.cpp @@ -0,0 +1,14 @@ +#include "deck_edit_event_bus.h" + +DeckEditEventBus::DeckEditEventBus() +{ +} + +/** + * Gets the singleton instance of the event bus + */ +DeckEditEventBus *DeckEditEventBus::instance() +{ + static DeckEditEventBus deckEditEventBus; // Created only once, on first access + return &deckEditEventBus; +} \ No newline at end of file diff --git a/cockatrice/src/deck/deck_edit_event_bus.h b/cockatrice/src/deck/deck_edit_event_bus.h new file mode 100644 index 000000000..c1073b19f --- /dev/null +++ b/cockatrice/src/deck/deck_edit_event_bus.h @@ -0,0 +1,26 @@ +#ifndef DECK_EDIT_EVENT_BUS_H +#define DECK_EDIT_EVENT_BUS_H + +#include + +/** + * A singleton object that can be used to pass signals between objects that are far apart in the object tree. + * Contains signals that are related to deck editor and deck storage. + */ +class DeckEditEventBus : public QObject +{ + Q_OBJECT + +private: + // hide constructor + explicit DeckEditEventBus(); + + // Delete copy constructor and assignment operator to enforce singleton + DeckEditEventBus(const DeckEditEventBus &) = delete; + DeckEditEventBus &operator=(const DeckEditEventBus &) = delete; + +public: + static DeckEditEventBus *instance(); +}; + +#endif // DECK_EDIT_EVENT_BUS_H