1 /*************************************************************************** 2 copyright : (C) 2002 - 2008 by Scott Wheeler 3 email : wheeler@kde.org 4 ***************************************************************************/ 5 6 /*************************************************************************** 7 * This library is free software; you can redistribute it and/or modify * 8 * it under the terms of the GNU Lesser General Public License version * 9 * 2.1 as published by the Free Software Foundation. * 10 * * 11 * This library is distributed in the hope that it will be useful, but * 12 * WITHOUT ANY WARRANTY; without even the implied warranty of * 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 14 * Lesser General Public License for more details. * 15 * * 16 * You should have received a copy of the GNU Lesser General Public * 17 * License along with this library; if not, write to the Free Software * 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 19 * 02110-1301 USA * 20 * * 21 * Alternatively, this file is available under the Mozilla Public * 22 * License Version 1.1. You may obtain a copy of the License at * 23 * http://www.mozilla.org/MPL/ * 24 ***************************************************************************/ 25 26 #ifndef TAGLIB_TAGUNION_H 27 #define TAGLIB_TAGUNION_H 28 29 #include "tag.h" 30 31 #ifndef DO_NOT_DOCUMENT 32 33 namespace TagLib { 34 35 /*! 36 * \internal 37 */ 38 39 class TagUnion : public Tag 40 { 41 public: 42 43 enum AccessType { Read, Write }; 44 45 /*! 46 * Creates a TagLib::Tag that is the union of \a first, \a second, and 47 * \a third. The TagUnion takes ownership of these tags and will handle 48 * their deletion. 49 */ 50 TagUnion(Tag *first = 0, Tag *second = 0, Tag *third = 0); 51 52 virtual ~TagUnion(); 53 54 Tag *operator[](int index) const; 55 Tag *tag(int index) const; 56 57 void set(int index, Tag *tag); 58 59 PropertyMap properties() const; 60 void removeUnsupportedProperties(const StringList &unsupported); 61 62 virtual String title() const; 63 virtual String artist() const; 64 virtual String album() const; 65 virtual String comment() const; 66 virtual String genre() const; 67 virtual unsigned int year() const; 68 virtual unsigned int track() const; 69 70 virtual void setTitle(const String &s); 71 virtual void setArtist(const String &s); 72 virtual void setAlbum(const String &s); 73 virtual void setComment(const String &s); 74 virtual void setGenre(const String &s); 75 virtual void setYear(unsigned int i); 76 virtual void setTrack(unsigned int i); 77 virtual bool isEmpty() const; 78 access(int index,bool create)79 template <class T> T *access(int index, bool create) 80 { 81 if(!create || tag(index)) 82 return static_cast<T *>(tag(index)); 83 84 set(index, new T); 85 return static_cast<T *>(tag(index)); 86 } 87 88 private: 89 TagUnion(const Tag &); 90 TagUnion &operator=(const Tag &); 91 92 class TagUnionPrivate; 93 TagUnionPrivate *d; 94 }; 95 } 96 97 #endif 98 #endif 99