Permalink
Browse files

Implementation of release-list on track level.

  • Loading branch information...
1 parent 091a83a commit 1588ceb5eea3ad968a244fca236c66ddbe995533 @lalinsky lalinsky committed Jan 18, 2007
Showing with 161 additions and 3 deletions.
  1. +10 −2 ChangeLog
  2. +85 −0 include/musicbrainz3/track.h
  3. +5 −0 src/mbxmlparser.cpp
  4. +49 −0 src/track.cpp
  5. +12 −1 test/test_parser_track.cpp
View
12 ChangeLog
@@ -1,10 +1,18 @@
-Changes for libmusicbrainz 3.0.0
+Changes for libmusicbrainz 3.0.0beta2
+-------------------------------------
+
+ - Fixed MusicBrainz::extractUuid for non-artist IDs.
+ - Implementation of release types.
+ - Implementation of release lists on track level.
+ - New cdlookup.cpp example.
+
+Changes for libmusicbrainz 3.0.0beta1
-------------------------------------
- Rewritten from scratch, libmusicbrainz now uses the new XML web service.
- New object oriented API in C++ based on python-musicbrainz2, with
GLib-style C bindings.
-
+
Changes for libmusicbrainz 2.1.2
-------------------------------------
View
85 include/musicbrainz3/track.h
@@ -116,6 +116,91 @@ namespace MusicBrainz
*/
void setDuration(const int duration);
+ /**
+ * Returns a list of releases from this artist.
+ *
+ * This may also include releases where this artist isn't the
+ * \e main artist but has just contributed one or more tracks
+ * (aka VA-Releases).
+ *
+ * @return: a list of pointers to Release objects
+ */
+ ReleaseList &getReleases();
+
+ /**
+ * Returns number of releases.
+ *
+ * This is equivalent to \c getReleases().size()
+ *
+ * @return an int containing number of releases
+ *
+ * @see getReleases
+ */
+ int getNumReleases() const;
+
+ /**
+ * Returns an release specified by index.
+ *
+ * This is equivalent to \c getReleases()[index]
+ *
+ * @return a pointer to Release instance
+ *
+ * @see getReleases
+ */
+ Release *getRelease(int index);
+
+ /**
+ * Adds a release to this artist's list of releases.
+ *
+ * @param release a pointer to Release object
+ */
+ void addRelease(Release *release);
+
+ /**
+ * Returns the offset of the release list.
+ *
+ * This is used if the track list is incomplete (ie. the web
+ * service only returned part of the tracks on this release).
+ * Note that the offset value is zero-based, which means track
+ * \a 0 is the first track.
+ *
+ * @return an integer containing the offset
+ *
+ * @see getReleases
+ */
+ int getReleasesOffset() const;
+
+ /**
+ * Sets the offset of the release list.
+ *
+ * @param offset an integer containing the offset
+ *
+ * @see getReleasesOffset
+ */
+ void setReleasesOffset(const int offset);
+
+ /**
+ * Returns the number of existing releases.
+ *
+ * This may or may not match with the number of elements that
+ * getReleases and getNumReleases returns. If the count is higher than
+ * the list, it indicates that the list is incomplete.
+ *
+ * @return an integer containing the count
+ *
+ * @see getReleases
+ */
+ int getReleasesCount() const;
+
+ /**
+ * Sets the count of the release list.
+ *
+ * @param count an integer containing the count
+ *
+ * @see getReleasesCount
+ */
+ void setReleasesCount(const int count);
+
private:
class TrackPrivate;
View
5 src/mbxmlparser.cpp
@@ -323,6 +323,11 @@ MbXmlParser::MbXmlParserPrivate::createTrack(XMLNode trackNode)
else if (name == "duration") {
track->setDuration(getInt(node));
}
+ else if (name == "release-list") {
+ track->setReleasesOffset(getIntAttr(node, "offset"));
+ track->setReleasesCount(getIntAttr(node, "count"));
+ addReleasesToList(node, track->getReleases());
+ }
else if (name == "relation-list") {
addRelationsToEntity(node, track);
}
View
49 src/track.cpp
@@ -37,6 +37,9 @@ class Track::TrackPrivate
std::string title;
Artist *artist;
int duration;
+ ReleaseList releases;
+ int releasesCount;
+ int releasesOffset;
};
Track::Track(const string &id, const string &title)
@@ -93,4 +96,50 @@ Track::setDuration(const int value)
d->duration = value;
}
+ReleaseList &
+Track::getReleases()
+{
+ return d->releases;
+}
+
+void
+Track::addRelease(Release *release)
+{
+ d->releases.push_back(release);
+}
+
+int
+Track::getNumReleases() const
+{
+ return d->releases.size();
+}
+
+Release *
+Track::getRelease(int i)
+{
+ return d->releases[i];
+}
+
+int
+Track::getReleasesOffset() const
+{
+ return d->releasesOffset;
+}
+
+void
+Track::setReleasesOffset(const int releasesOffset)
+{
+ d->releasesOffset = releasesOffset;
+}
+int
+Track::getReleasesCount() const
+{
+ return d->releasesCount;
+}
+
+void
+Track::setReleasesCount(const int releasesCount)
+{
+ d->releasesCount = releasesCount;
+}
View
13 test/test_parser_track.cpp
@@ -15,6 +15,7 @@ class ParseTrackTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(ParseTrackTest);
CPPUNIT_TEST(testTrackBasic);
+ CPPUNIT_TEST(testTrackReleases);
CPPUNIT_TEST(testTrackSearch);
CPPUNIT_TEST_SUITE_END();
@@ -30,7 +31,17 @@ class ParseTrackTest : public CppUnit::TestFixture
CPPUNIT_ASSERT_EQUAL(string("Silent All These Years"), track->getTitle());
CPPUNIT_ASSERT_EQUAL(253466, track->getDuration());
}
-
+
+ void testTrackReleases()
+ {
+ Metadata *md = MbXmlParser().parse(get_file_contents("../test-data/valid/track/Silent_All_These_Years_4.xml"));
+ Track *track = md->getTrack();
+ CPPUNIT_ASSERT(track);
+ CPPUNIT_ASSERT_EQUAL(1, int(track->getReleases().size()));
+ CPPUNIT_ASSERT_EQUAL(1, track->getNumReleases());
+ CPPUNIT_ASSERT_EQUAL(string("Little Earthquakes"), track->getReleases()[0]->getTitle());
+ }
+
void testTrackSearch()
{
Metadata *md = MbXmlParser().parse(get_file_contents("../test-data/valid/track/search_result_1.xml"));

0 comments on commit 1588ceb

Please sign in to comment.