Commits

Ivan Andrianov committed 004552a

TagBlock implicit sharing.

  • Participants
  • Parent commits 7b9f0d2

Comments (0)

Files changed (3)

File src/codecs/tagblock.cpp

  */
 
 #include "tagblock.h"
-#include "tagblock_p.h"
 
 namespace FFTranscoder
 {
 namespace Codecs
 {
 
+class TagBlock::Data : public QSharedData
+{
+public:
+    QString artistName;
+    QString albumName;
+    uint year;
+    QString trackName;
+    uint trackNumber;
+};
+
 TagBlock::TagBlock() :
-        d(new TagBlockPrivate())
+        d(new Data())
 {
-    d->trackNumber = 0;
-    d->year = 0;
+    setTrackNumber(0);
+    setYear(0);
 }
 
 TagBlock::TagBlock(const QString & artistName, const QString & albumName,
         const QString & trackName, uint trackNumber, uint year) :
-        d(new TagBlockPrivate())
+        d(new Data())
 {
-    d->artistName = artistName;
-    d->albumName = albumName;
-    d->trackName = trackName;
-    d->trackNumber = trackNumber;
-    d->year = year;
+    setArtistName(artistName);
+    setAlbumName(albumName);
+    setTrackName(trackName);
+    setTrackNumber(trackNumber);
+    setYear(year);
 }
 
 TagBlock::TagBlock(const TagBlock & other) :
-        d(new TagBlockPrivate(*other.d.data()))
+        d(other.d)
 {
 }
 
 TagBlock & TagBlock::operator=(const TagBlock & other)
 {
-    d.reset(new TagBlockPrivate(*other.d.data()));
+    d = other.d;
     return *this;
 }
 
     d->year = year;
 }
 
-TagBlockPrivate::TagBlockPrivate()
-{
 }
-
-TagBlockPrivate::~TagBlockPrivate()
-{
 }
-
-}
-}

File src/codecs/tagblock.h

 #ifndef FFTRANSCODER_CODECS_TAGBLOCK_H
 #define FFTRANSCODER_CODECS_TAGBLOCK_H
 
-#include <QScopedPointer>
+#include <QtCore/qshareddata.h>
+#include <QtCore/qstring.h>
 
 #include "global.h"
 
 namespace Codecs
 {
 
-class TagBlockPrivate;
-
 /**
  * Meta data block of tags containing different tags, e.g. artist name.
  */
     void setTrackNumber(uint trackNumber);
 
 private:
-    QScopedPointer<TagBlockPrivate> d;
+    class Data;
+    QSharedDataPointer<Data> d;
 };
 
 }
 }
 
-#endif /* FFTRANSCODER_CODECS_TAGBLOCK_H */
+#endif

File src/codecs/tagblock_p.h

-/*
- * Copyright (C) 2012 by Ivan Andrianov
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-#ifndef FFTRANSCODER_CODECS_TAGBLOCK_P_H
-#define FFTRANSCODER_CODECS_TAGBLOCK_P_H
-
-#include <QString>
-
-namespace FFTranscoder
-{
-namespace Codecs
-{
-
-class TagBlockPrivate
-{
-public:
-    TagBlockPrivate();
-    ~TagBlockPrivate();
-
-    QString artistName;
-    QString albumName;
-    uint year;
-    QString trackName;
-    uint trackNumber;
-};
-
-}
-}
-
-#endif /* FFTRANSCODER_CODECS_TAGBLOCK_P_H */