Cockatrice 2025-11-30-Development-2.11.0-beta.38
A cross-platform virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
CardDatabase Class Reference

Core in-memory container for card and set data. More...

#include <card_database.h>

Inheritance diagram for CardDatabase:
[legend]
Collaboration diagram for CardDatabase:
[legend]

Public Slots

void addCard (CardInfoPtr card)
 Adds a card to the database.
void addSet (CardSetPtr set)
 Adds a set to the database.
void loadCardDatabases ()
 Loads card databases from configured paths.
bool saveCustomTokensToFile ()
 Saves custom tokens to file.

Signals

void cardDatabaseLoadingFinished ()
 Emitted when the card database has finished loading successfully.
void cardDatabaseLoadingFailed ()
 Emitted when the card database fails to load.
void cardDatabaseNewSetsFound (int numUnknownSets, QStringList unknownSetsNames)
 Emitted when new sets are found.
void cardDatabaseAllNewSetsEnabled ()
 Emitted when all new sets have been enabled.
void cardDatabaseEnabledSetsChanged ()
 Emitted when enabled sets have changed.
void cardAdded (CardInfoPtr card)
 Emitted when a new card is added.
void cardRemoved (CardInfoPtr card)
 Emitted when a card is removed.

Public Member Functions

 CardDatabase (QObject *parent=nullptr, ICardPreferenceProvider *prefs=nullptr, ICardDatabasePathProvider *pathProvider=nullptr, ICardSetPriorityController *setPriorityController=nullptr)
 Constructs a new CardDatabase instance.
 ~CardDatabase () override
 Destructor clears all internal data.
void removeCard (CardInfoPtr card)
 Removes a card from the database.
void clear ()
 Clears all cards, sets, and internal state.
const CardNameMapgetCardList () const
 Returns the map of cards by name.
CardSetPtr getSet (const QString &setName)
 Retrieves a set by short name, creating a new one if missing.
CardSetList getSetList () const
 Returns a list of all sets in the database.
LoadStatus getLoadStatus () const
 Returns the current load status.
CardDatabaseQuerierquery () const
 Returns the querier for performing card lookups.
void enableAllUnknownSets ()
 Enables all unknown sets in the database.
void markAllSetsAsKnown ()
 Marks all sets as known.
void notifyEnabledSetsChanged ()
 Notifies listeners that enabled sets changed.

Protected Attributes

ICardSetPriorityControllersetPriorityController
 Controller to determine set priority when choosing preferred printings.
CardNameMap cards
 Cards indexed by exact name.
CardNameMap simpleNameCards
 Cards indexed by simplified name (normalized)
SetNameMap sets
 Sets indexed by short name.
CardDatabaseLoaderloader
 Loader responsible for file discovery and parsing.
LoadStatus loadStatus
 Current load status of the database.
CardDatabaseQuerierquerier
 Querier for higher-level card lookups.

Private Member Functions

void checkUnknownSets ()
 Check for sets that are unknown and emit signals if needed.
void refreshCachedReverseRelatedCards ()
 Refreshes the cached reverse-related cards for all cards.

Private Attributes

QBasicMutex * clearDatabaseMutex = new QBasicMutex()
 Mutexes for thread safety.
QBasicMutex * addCardMutex = new QBasicMutex()
QBasicMutex * removeCardMutex = new QBasicMutex()

Friends

class CardDatabaseLoader
class CardDatabaseQuerier

Detailed Description

Core in-memory container for card and set data.

Responsible for maintaining CardInfo objects, CardSet objects, and providing access to CardDatabaseQuerier for query operations. Handles addition, removal, and clearing of cards and sets.

Constructor & Destructor Documentation

◆ CardDatabase()

CardDatabase::CardDatabase ( QObject * parent = nullptr,
ICardPreferenceProvider * prefs = nullptr,
ICardDatabasePathProvider * pathProvider = nullptr,
ICardSetPriorityController * setPriorityController = nullptr )
explicit

Constructs a new CardDatabase instance.

Parameters
parentQObject parent.
prefsOptional card preference provider.
pathProviderOptional database path provider.
setPriorityControllerOptional controller for set priority.
Here is the call graph for this function:

◆ ~CardDatabase()

CardDatabase::~CardDatabase ( )
override

Destructor clears all internal data.

Here is the call graph for this function:

Member Function Documentation

◆ addCard

void CardDatabase::addCard ( CardInfoPtr card)
slot

Adds a card to the database.

Parameters
cardCardInfoPtr to add.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ addSet

void CardDatabase::addSet ( CardSetPtr set)
slot

Adds a set to the database.

Parameters
setPointer to CardSet to add.
Here is the caller graph for this function:

◆ cardAdded

void CardDatabase::cardAdded ( CardInfoPtr card)
signal

Emitted when a new card is added.

Here is the caller graph for this function:

◆ cardDatabaseAllNewSetsEnabled

void CardDatabase::cardDatabaseAllNewSetsEnabled ( )
signal

Emitted when all new sets have been enabled.

Here is the caller graph for this function:

◆ cardDatabaseEnabledSetsChanged

void CardDatabase::cardDatabaseEnabledSetsChanged ( )
signal

Emitted when enabled sets have changed.

Here is the caller graph for this function:

◆ cardDatabaseLoadingFailed

void CardDatabase::cardDatabaseLoadingFailed ( )
signal

Emitted when the card database fails to load.

Here is the caller graph for this function:

◆ cardDatabaseLoadingFinished

void CardDatabase::cardDatabaseLoadingFinished ( )
signal

Emitted when the card database has finished loading successfully.

Here is the caller graph for this function:

◆ cardDatabaseNewSetsFound

void CardDatabase::cardDatabaseNewSetsFound ( int numUnknownSets,
QStringList unknownSetsNames )
signal

Emitted when new sets are found.

Parameters
numUnknownSetsNumber of unknown sets.
unknownSetsNamesNames of unknown sets.
Here is the caller graph for this function:

◆ cardRemoved

void CardDatabase::cardRemoved ( CardInfoPtr card)
signal

Emitted when a card is removed.

Here is the caller graph for this function:

◆ checkUnknownSets()

void CardDatabase::checkUnknownSets ( )
private

Check for sets that are unknown and emit signals if needed.

Here is the call graph for this function:

◆ clear()

void CardDatabase::clear ( )

Clears all cards, sets, and internal state.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ enableAllUnknownSets()

void CardDatabase::enableAllUnknownSets ( )

Enables all unknown sets in the database.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getCardList()

const CardNameMap & CardDatabase::getCardList ( ) const
inlinenodiscard

Returns the map of cards by name.

◆ getLoadStatus()

LoadStatus CardDatabase::getLoadStatus ( ) const
inlinenodiscard

Returns the current load status.

Here is the caller graph for this function:

◆ getSet()

CardSetPtr CardDatabase::getSet ( const QString & setName)

Retrieves a set by short name, creating a new one if missing.

Parameters
setNameShort name of the set.
Returns
Pointer to the CardSet.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getSetList()

CardSetList CardDatabase::getSetList ( ) const
nodiscard

Returns a list of all sets in the database.

Here is the caller graph for this function:

◆ loadCardDatabases

void CardDatabase::loadCardDatabases ( )
slot

Loads card databases from configured paths.

Here is the caller graph for this function:

◆ markAllSetsAsKnown()

void CardDatabase::markAllSetsAsKnown ( )

Marks all sets as known.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ notifyEnabledSetsChanged()

void CardDatabase::notifyEnabledSetsChanged ( )

Notifies listeners that enabled sets changed.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ query()

CardDatabaseQuerier * CardDatabase::query ( ) const
inlinenodiscard

Returns the querier for performing card lookups.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ refreshCachedReverseRelatedCards()

void CardDatabase::refreshCachedReverseRelatedCards ( )
private

Refreshes the cached reverse-related cards for all cards.

◆ removeCard()

void CardDatabase::removeCard ( CardInfoPtr card)

Removes a card from the database.

Parameters
cardPointer to the card to remove.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ saveCustomTokensToFile

bool CardDatabase::saveCustomTokensToFile ( )
slot

Saves custom tokens to file.

Returns
True if successful.
Here is the caller graph for this function:

◆ CardDatabaseLoader

friend class CardDatabaseLoader
friend

◆ CardDatabaseQuerier

friend class CardDatabaseQuerier
friend

Member Data Documentation

◆ addCardMutex

QBasicMutex * CardDatabase::addCardMutex = new QBasicMutex()
private

◆ cards

CardNameMap CardDatabase::cards
protected

Cards indexed by exact name.

◆ clearDatabaseMutex

QBasicMutex* CardDatabase::clearDatabaseMutex = new QBasicMutex()
private

Mutexes for thread safety.

◆ loader

CardDatabaseLoader* CardDatabase::loader
protected

Loader responsible for file discovery and parsing.

◆ loadStatus

LoadStatus CardDatabase::loadStatus
protected

Current load status of the database.

◆ querier

CardDatabaseQuerier* CardDatabase::querier
protected

Querier for higher-level card lookups.

◆ removeCardMutex

QBasicMutex * CardDatabase::removeCardMutex = new QBasicMutex()
private

◆ setPriorityController

ICardSetPriorityController* CardDatabase::setPriorityController
protected

Controller to determine set priority when choosing preferred printings.

◆ sets

SetNameMap CardDatabase::sets
protected

Sets indexed by short name.

◆ simpleNameCards

CardNameMap CardDatabase::simpleNameCards
protected

Cards indexed by simplified name (normalized)


The documentation for this class was generated from the following files: