mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-19 08:52:15 -07:00
create new singleton class
This commit is contained in:
parent
77a3515470
commit
e9f8f4ef20
3 changed files with 41 additions and 0 deletions
|
|
@ -31,6 +31,7 @@ set(cockatrice_SOURCES
|
||||||
src/server/chat_view/chat_view.cpp
|
src/server/chat_view/chat_view.cpp
|
||||||
src/game/board/counter_general.cpp
|
src/game/board/counter_general.cpp
|
||||||
src/deck/custom_line_edit.cpp
|
src/deck/custom_line_edit.cpp
|
||||||
|
src/deck/deck_edit_event_bus.cpp
|
||||||
src/deck/deck_loader.cpp
|
src/deck/deck_loader.cpp
|
||||||
src/deck/deck_list_model.cpp
|
src/deck/deck_list_model.cpp
|
||||||
src/deck/deck_stats_interface.cpp
|
src/deck/deck_stats_interface.cpp
|
||||||
|
|
|
||||||
14
cockatrice/src/deck/deck_edit_event_bus.cpp
Normal file
14
cockatrice/src/deck/deck_edit_event_bus.cpp
Normal file
|
|
@ -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;
|
||||||
|
}
|
||||||
26
cockatrice/src/deck/deck_edit_event_bus.h
Normal file
26
cockatrice/src/deck/deck_edit_event_bus.h
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
#ifndef DECK_EDIT_EVENT_BUS_H
|
||||||
|
#define DECK_EDIT_EVENT_BUS_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
Loading…
Add table
Add a link
Reference in a new issue