Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
CreditsDB Class Reference

The credits/attribution database – and the canonical example of the "DB singleton" pattern every database in this layer follows. More...

#include <creditsdb.h>

Inheritance diagram for CreditsDB:
Collaboration diagram for CreditsDB:

Public Member Functions

const QVector< CreditDBEntry * > getStore () const
 The full entry vector.
int getStoreSize () const
 Entry count (backs getStoreSize).
CreditDBEntrygetStoreAt (const int ind) const
 Entry at ind (for QML).
void load ()
 Load entries from the JSON assets.
void qmlProtect (const QQmlEngine *const engine) const
 Pin to C++ ownership (anti-GC).

Static Public Member Functions

static CreditsDBinst ()
 < Number of credit entries.

Friends

struct CreditDBEntry
 Lets entries populate the store during load.

Detailed Description

The credits/attribution database – and the canonical example of the "DB singleton" pattern every database in this layer follows.

The DB-singleton convention (shared by every *DB class here)
  • A static T* inst() singleton with a private constructor – never new one.
  • A QVector<XxxDBEntry*> store of entries, loaded from JSON in load() (called centrally by DB::loadAll(), never from the constructor – see db.h).
  • QML-facing access: a getStore() / getStoreSize pair plus an invokable getStoreAt(ind) (arguments can't be a property or slot, hence Q_INVOKABLE).
  • qmlProtect()/qmlRegister() for QML ownership + type registration.
  • The entry struct is a friend so it can populate the store during load.

Read this one, and the other databases (PokemonDB, MovesDB, ItemsDB, ...) read the same way – they just carry richer entries and lookup indexes.

See also
CreditDBEntry (its entry type), DB (the aggregate), the db system map.

Definition at line 48 of file creditsdb.h.

Member Function Documentation

◆ getStore()

const QVector< CreditDBEntry * > CreditsDB::getStore ( ) const

The full entry vector.

Definition at line 39 of file creditsdb.cpp.

◆ getStoreAt()

CreditDBEntry * CreditsDB::getStoreAt ( const int ind) const

Entry at ind (for QML).

Definition at line 49 of file creditsdb.cpp.

References CreditDBEntry.

◆ getStoreSize()

int CreditsDB::getStoreSize ( ) const

Entry count (backs getStoreSize).

Definition at line 44 of file creditsdb.cpp.

◆ inst()

CreditsDB * CreditsDB::inst ( )
static

< Number of credit entries.

Returns the process-wide CreditsDB singleton.

Definition at line 33 of file creditsdb.cpp.

Referenced by DB::credits(), CreditDBEntry::process(), and DB::qmlProtect().

◆ load()

void CreditsDB::load ( )

Load entries from the JSON assets.

Definition at line 60 of file creditsdb.cpp.

References GameData::inst(), GameData::json(), and CreditDBEntry::process().

◆ qmlProtect()

void CreditsDB::qmlProtect ( const QQmlEngine *const engine) const

Pin to C++ ownership (anti-GC).

Definition at line 78 of file creditsdb.cpp.

References Utility::qmlProtectUtil().

Referenced by DB::qmlProtect().

◆ CreditDBEntry

friend struct CreditDBEntry
friend

Lets entries populate the store during load.

Definition at line 80 of file creditsdb.h.

References CreditDBEntry.

Referenced by CreditDBEntry, and getStoreAt().


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