Archive / / / / Track.h
2008-10-21 13:57:27 UTC
previous next
/* Echo Media Player * Copyright (C) 2008 Shane O'Connell * * [ The original file includes a copyright header in this location describing * the file as being released under the terms of the GNU General Public * License. It has been removed in order to display the file as part of the * archive. ] */ #ifndef TRACK_H_ #define TRACK_H_ #include <gtkmm.h> #include <boost/intrusive_ptr.hpp> #include <boost/shared_ptr.hpp> #include <boost/noncopyable.hpp> class Track; typedef boost::intrusive_ptr<Track> TrackRef; typedef boost::shared_ptr<std::vector<TrackRef> > TrackListRef; typedef boost::shared_ptr<const Glib::ustring> StringRef; class Track : private boost::noncopyable { public: const std::string& get_uri() const { return _uri; } const Glib::ustring& get_title() const { return _title; } const Glib::ustring& get_artist() const { return *_artist; } const Glib::ustring& get_album() const { return *_album; } int get_track_number() const { return _track_number; } private: friend class PlaySource; friend class ModPlaySource; friend class DbPlaySource; friend class Playlist; friend class Library; Track() : m_ref_count(0) {} static TrackRef create() { return TrackRef(new Track()); } Track(const std::string& uri, const Glib::ustring& title, const Glib::ustring& artist, const Glib::ustring& album, int track_number) : _uri(uri), _title(title), _artist(StringRef(new Glib::ustring(artist))), _album(StringRef(new Glib::ustring(album))), _track_number(track_number), m_ref_count(0) {} Track(const std::string& uri, const Glib::ustring& title, StringRef artist, StringRef album, int track_number) : _uri(uri), _title(title), _artist(artist), _album(album), _track_number(track_number), m_ref_count(0) {} std::string _uri; Glib::ustring _title; StringRef _artist; StringRef _album; int _track_number; int m_ref_count; friend void intrusive_ptr_add_ref(Track* p) { p->m_ref_count++; } friend void intrusive_ptr_release(Track* p) { if (!(--p->m_ref_count)) delete p; } }; #endif /* TRACK_H_ */