Data Model: Mp3File

Figure 25.3 shows a UML diagram of the data model for our MP3 player application, at the lowest level.

Figure 25.3. Initial data model

Mp3Song is an abstract class (which is why it is italicized in the UML diagram). This interface is meant to describe a common set of features for different implementations of the Mp3Song interface.

Example 25.1. ../src/libs/filetagger/mp3song.h

#ifndef _MP3SONG_H #define _MP3SONG_H #include #include #include class Mp3Song { public: static QStringList fields(); virtual ~Mp3Song(); virtual QString getGenre() const =0; virtual QString getArtist() const =0; virtual QString getAlbumTitle() const =0; virtual QString getTrackTitle() const =0; virtual QString getTrackNumber() const =0; virtual int getTrackTime() const =0; virtual QString getComment() const =0; virtual QString getPreference() const =0 ; virtual QString toString() const =0; virtual QString getUrl() const =0; virtual QString getFilename() const = 0; virtual void setPreference(const QString & newPref) = 0; virtual void setGenre (const QString& newGenre) =0; virtual void setArtist (const QString& newArtist) =0; virtual void setTrackNumber (const QString& trackNum) = 0; virtual void setTrackTitle (const QString& newTitle) = 0; virtual void setAlbumTitle (const QString& newAlbumTitle) = 0; virtual void setComment (const QString& newComment) = 0; virtual void setFilename (const QString& newFilename) =0 ; }; #endif

Note also that there is a getTRackTime() function but no setTrackTime() method. This is because m_trackTime is a calculated value, a read-only property. Derived classes will override this method and return the actual time of the song.

The Assignment

Категории

© amp.flylib.com,