This repository has been archived by the owner on Oct 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Release.h
67 lines (61 loc) · 1.61 KB
/
Release.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
#pragma once
#include "foo_musicbrainz.h"
#include "CoreEntity.h"
#include "ArtistCredit.h"
#include "LabelInfo.h"
#include "Medium.h"
#include "Date.h"
#include "ReleaseGroup.h"
namespace foo_musicbrainz {
class Release : public CoreEntity {
STRING_MEMBER(title)
STRING_MEMBER(barcode)
STRING_MEMBER(country)
STRING_MEMBER(asin)
STRING_MEMBER(language)
STRING_MEMBER(script)
MEMBER(int, medium_total_count)
MEMBER_BY_REFERENCE(Date, date)
POINTER_MEMBER(ArtistCredit, artist_credit)
POINTER_MEMBER(ReleaseGroup, release_group)
STRING_LIST(status, statuses, 4)
COLLECTION(Medium, medium)
COLLECTION(LabelInfo, label_info)
public:
bool is_various() const {
auto name = get_artist_credit()->get_name();
for (size_t i = 0; i < medium_count(); i++) {
auto medium = get_medium(i);
for (size_t j = 0; j < medium->track_count(); j++) {
auto track = medium->get_track(j);
if (track->get_artist_credit()->get_name() != name) {
return true;
}
}
}
return false;
}
bool is_multidisc() const {
return get_medium_total_count() > 1;
}
size_t track_count() {
size_t tmp = 0;
for (size_t i = 0; i < medium_count(); i++) {
tmp+= get_medium(i)->track_count();
}
return tmp;
}
Release() :
CoreEntity(),
status(0),
medium_total_count(0),
artist_credit(nullptr),
release_group(nullptr) {};
~Release() {
POINTER_MEMBER_DESTRUCTOR(artist_credit)
POINTER_MEMBER_DESTRUCTOR(release_group)
COLLECTION_DESTRUCTOR(medium)
COLLECTION_DESTRUCTOR(label_info)
}
};
}