Database

Maintain a database of CompactDiscs. More...

Publicly inherits QObject.

Public Methods

Database( );
CompactDisc*search( const CompactDiscID& id );
voidupdate( CompactDisc& cd );

Private Methods

QStringgetToEOL( FILE* fp );
QStringgetToken( FILE* fp );
CompactDisc*nextEntry( FILE* fptr );
voidwriteEntry( FILE* fptr, CompactDisc& cd );

Detailed Documentation

Maintain a database of CompactDiscs.

Maintain a collection of CompactDiscs that can be searched and updated by their CompactDiscIDs. The Database is stored in a file, and it is not loaded into memory (except for updating).

Public Methods Documentation

Database ( );

Create the Database from the path to the data file.

"There can be only one."

CompactDisc* search ( const CompactDiscID& id );

Search for a CompactDisc by CompactDiscID.

If the disc is not found in the database file, then a default CompactDisc will be created and returned.

void update ( CompactDisc& cd );

Add/update the CompactDisc to the Database.

Write the CompactDisc to the database file. The entire database is read in. Then, all entries are rewritten, with the new entry for the given disc replacing any existing entry for it.

Private Methods Documentation

CompactDisc* nextEntry ( FILE* fptr );

Read the next CompactDisc entry from the Database file.

void writeEntry ( FILE* fptr, CompactDisc& cd );

Write a CompactDisc entry to the Database file.


Return to Index.
Automatically generated on Dec 29 18:17