-
Notifications
You must be signed in to change notification settings - Fork 0
/
music_db.h
81 lines (62 loc) · 1.8 KB
/
music_db.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
* Music DB ADTs external interface defined here
*/
const int MAX_INPUT_LENGTH = 100;
const int MAX_TRACKS_IN_PLAYLIST = 30;
const int MAX_TRACKS_IN_DB = 100;
const int MAX_PLAYLISTS_IN_DB = 10;
class Track
{
public:
Track(const String268 &in_title,
const String268 &in_artist,
const String268 &in_album,
const String268 &in_comment);
bool matches(String268 &trac_title, String268 &track_artist);
friend std::ostream& operator<<(std::ostream &os, Track &in_track);
void print_title(std::ostream &os);
private:
String268 title;
String268 artist;
String268 album;
String268 comment;
};
class Playlist
{
public:
Playlist(const String268 &in_title);
bool add_track(Track *in_track);
bool matches(String268 &pl_title);
friend std::ostream& operator<<(std::ostream &os, Playlist &in_playlist);
void print_title(std::ostream &os);
private:
String268 title;
Track *tracks[MAX_TRACKS_IN_PLAYLIST];
int next_open_track_slot;
};
class Collection
{
public:
Collection();
bool add_track(Track *in_track);
bool add_playlist(Playlist *in_playlist);
Track *find_track(String268 &track_title,
String268 &track_artist);
Playlist *find_playlist(String268 &pl_title);
void print_track_titles(std::ostream &os);
void print_playlist_titles(std::ostream &os);
friend std::ostream& operator<<(std::ostream &os, Collection &in_collection);
private:
Track *tracks[MAX_TRACKS_IN_DB];
Playlist *playlists[MAX_PLAYLISTS_IN_DB];
int next_track_slot;
int next_playlist_slot;
};
/*
* Utility routine to process the music DB definition and command
* files
*/
extern Collection *process_db_definition_file(ifstream &in_port);
extern void process_db_cmd_file(ifstream &in_port,
Collection in_collection,
ostream &out_port);