]> granicus.if.org Git - taglib/commitdiff
Removed RefCounter implementation from a public header
authorTsuda Kageyu <tsuda.kageyu@gmail.com>
Fri, 3 May 2013 04:53:32 +0000 (13:53 +0900)
committerTsuda Kageyu <tsuda.kageyu@gmail.com>
Fri, 3 May 2013 04:53:32 +0000 (13:53 +0900)
16 files changed:
config.h.cmake
taglib/CMakeLists.txt
taglib/asf/asfattribute.cpp
taglib/asf/asfpicture.cpp
taglib/fileref.cpp
taglib/mp4/mp4coverart.cpp
taglib/mp4/mp4item.cpp
taglib/mpeg/mpegheader.cpp
taglib/taglib_config.h.cmake
taglib/toolkit/taglib.h
taglib/toolkit/tbytevector.cpp
taglib/toolkit/tlist.tcc
taglib/toolkit/tmap.tcc
taglib/toolkit/trefcounter.cpp [new file with mode: 0644]
taglib/toolkit/trefcounter.h [new file with mode: 0644]
taglib/toolkit/tstring.cpp

index 155fea66e597fef7942f38e7f489939507daa83e..0a5c70152553f7784fb39298d816cefd9f2d01ac 100644 (file)
 /* Defined if your compiler supports codecvt */
 #cmakedefine   HAVE_STD_CODECVT 1
 
+/* Defined if your compiler supports some atomic operations */
+#cmakedefine   HAVE_STD_ATOMIC 1
+#cmakedefine   HAVE_BOOST_ATOMIC 1
+#cmakedefine   HAVE_GCC_ATOMIC 1
+#cmakedefine   HAVE_MAC_ATOMIC 1
+#cmakedefine   HAVE_WIN_ATOMIC 1
+#cmakedefine   HAVE_IA64_ATOMIC 1
+
 /* Defined if you have libz */
 #cmakedefine   HAVE_ZLIB 1
 
index 72712ca2ad915bdf8d90534ea3c06102b01fa4a7..352f7e2ed59c061d044903f805a445371b6296a8 100644 (file)
@@ -50,6 +50,7 @@ set(tag_HDRS
   toolkit/tmap.h
   toolkit/tmap.tcc
   toolkit/tpropertymap.h
+  toolkit/trefcounter.h
   mpeg/mpegfile.h
   mpeg/mpegproperties.h
   mpeg/mpegheader.h
@@ -289,6 +290,7 @@ set(toolkit_SRCS
   toolkit/tfilestream.cpp
   toolkit/tdebug.cpp
   toolkit/tpropertymap.cpp
+  toolkit/trefcounter.cpp
   toolkit/unicode.cpp
 )
 
index 937a8816d748de7666f3f4128340fa0a484fc129..4ee2d0a1851c0564ac17e041356d8239d852d26c 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <taglib.h>
 #include <tdebug.h>
+#include "trefcounter.h"
 #include "asfattribute.h"
 #include "asffile.h"
 
index 3db695a4e9e38cfb05a16d21afccbc333dcb58d3..999f920438c58f1836e9e613b0176cfd7a929b86 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <taglib.h>
 #include <tdebug.h>
+#include "trefcounter.h"
 #include "asfattribute.h"
 #include "asffile.h"
 #include "asfpicture.h"
index 508fc0c5fef8307c406e048a5617c402df4cfc4a..157ba2ee5dda18707b5fde7eb2bfc582fe663478 100644 (file)
@@ -36,6 +36,7 @@
 #include <tfile.h>
 #include <tstring.h>
 #include <tdebug.h>
+#include "trefcounter.h"
 
 #include "fileref.h"
 #include "asffile.h"
index 5ccc76d678337ea21d4ee6c0548985767641d670..2746469d3fe677872ac9039b0ba189e1b71b28ee 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <taglib.h>
 #include <tdebug.h>
+#include "trefcounter.h"
 #include "mp4coverart.h"
 
 using namespace TagLib;
index fdb9645174edaa05f149cb2b4421aeffec644d61..671f26b4d6cac6a2c6ffaf7991aaa8a49e6177ba 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <taglib.h>
 #include <tdebug.h>
+#include "trefcounter.h"
 #include "mp4item.h"
 
 using namespace TagLib;
index c715dbc1435bf7884ab8fbb8e221c454c666a05a..a582f7589fe51141bfdc6fd6b5df0953da0c432c 100644 (file)
@@ -28,6 +28,7 @@
 #include <tbytevector.h>
 #include <tstring.h>
 #include <tdebug.h>
+#include "trefcounter.h"
 
 #include "mpegheader.h"
 
index 633fad28ac680ed70e1cef54b4ac28a374b00018..2eb67b06d1cd24c30d4f847b939986d36b3085e3 100644 (file)
@@ -3,14 +3,6 @@
 /* Defined if your compiler supports std::wstring */
 #cmakedefine   TAGLIB_HAVE_STD_WSTRING 1
 
-/* Defined if your compiler supports some atomic operations */
-#cmakedefine   TAGLIB_HAVE_STD_ATOMIC 1
-#cmakedefine   TAGLIB_HAVE_BOOST_ATOMIC 1
-#cmakedefine   TAGLIB_HAVE_GCC_ATOMIC 1
-#cmakedefine   TAGLIB_HAVE_MAC_ATOMIC 1
-#cmakedefine   TAGLIB_HAVE_WIN_ATOMIC 1
-#cmakedefine   TAGLIB_HAVE_IA64_ATOMIC 1
-
 #define   TAGLIB_WITH_ASF 1
 #define   TAGLIB_WITH_MP4 1
 
index a80c02e497c31817c0649d475b7a894ba79c4d8c..80233db3adcb9f639aa9258421d997d3c0bf3c45 100755 (executable)
 
 #include <string>
 
-// Atomic increment/decrement operations
-
-#if defined(TAGLIB_HAVE_STD_ATOMIC)
-# include <atomic>
-# define TAGLIB_ATOMIC_INT std::atomic<unsigned int>
-# define TAGLIB_ATOMIC_INC(x) x.fetch_add(1)
-# define TAGLIB_ATOMIC_DEC(x) (x.fetch_sub(1) - 1)
-#elif defined(TAGLIB_HAVE_BOOST_ATOMIC)
-# include <boost/atomic.hpp>
-# define TAGLIB_ATOMIC_INT boost::atomic<unsigned int>
-# define TAGLIB_ATOMIC_INC(x) x.fetch_add(1)
-# define TAGLIB_ATOMIC_DEC(x) (x.fetch_sub(1) - 1)
-#elif defined(TAGLIB_HAVE_GCC_ATOMIC)
-# define TAGLIB_ATOMIC_INT int
-# define TAGLIB_ATOMIC_INC(x) __sync_add_and_fetch(&x, 1)
-# define TAGLIB_ATOMIC_DEC(x) __sync_sub_and_fetch(&x, 1)
-#elif defined(TAGLIB_HAVE_WIN_ATOMIC)
-# if !defined(NOMINMAX)
-#   define NOMINMAX
-# endif
-# include <windows.h>
-# define TAGLIB_ATOMIC_INT long
-# define TAGLIB_ATOMIC_INC(x) InterlockedIncrement(&x)
-# define TAGLIB_ATOMIC_DEC(x) InterlockedDecrement(&x)
-#elif defined(TAGLIB_HAVE_MAC_ATOMIC)
-# include <libkern/OSAtomic.h>
-# define TAGLIB_ATOMIC_INT int32_t
-# define TAGLIB_ATOMIC_INC(x) OSAtomicIncrement32Barrier(&x)
-# define TAGLIB_ATOMIC_DEC(x) OSAtomicDecrement32Barrier(&x)
-#elif defined(TAGLIB_HAVE_IA64_ATOMIC)
-# include <ia64intrin.h>
-# define TAGLIB_ATOMIC_INT int
-# define TAGLIB_ATOMIC_INC(x) __sync_add_and_fetch(&x, 1)
-# define TAGLIB_ATOMIC_DEC(x) __sync_sub_and_fetch(&x, 1)
-#else
-# define TAGLIB_ATOMIC_INT int
-# define TAGLIB_ATOMIC_INC(x) (++x)
-# define TAGLIB_ATOMIC_DEC(x) (--x)
-#endif
-
 //! A namespace for all TagLib related classes and functions
 
 /*!
@@ -118,30 +78,6 @@ namespace TagLib {
 #else
   typedef std::basic_string<wchar> wstring;
 #endif
-
-#ifndef DO_NOT_DOCUMENT // Tell Doxygen to skip this class.
-  /*!
-   * \internal
-   * This is just used as a base class for shared classes in TagLib.
-   *
-   * \warning This <b>is not</b> part of the TagLib public API!
-   */
-
-  class RefCounter
-  {
-  public:
-    RefCounter() : refCount(1) {}
-
-    void ref() { TAGLIB_ATOMIC_INC(refCount); }
-    bool deref() { return (TAGLIB_ATOMIC_DEC(refCount) == 0); }
-    int count() { return refCount; }
-
-  private:
-    volatile TAGLIB_ATOMIC_INT refCount;
-  };
-
-#endif // DO_NOT_DOCUMENT
-
 }
 
 /*!
index adada716354533605fe6f535440be5b4ea4d9cbc..471af477590f6d02a917774cd9c803ef11e7d79f 100644 (file)
@@ -41,6 +41,7 @@
 
 #include <tstring.h>
 #include <tdebug.h>
+#include "trefcounter.h"
 
 #include "tbytevector.h"
 
index 37817f0592cf72ed3ba7f8627d43d99e397dea8e..81e2915331cdbfb1b9bf56e5ac49cbc4b255a9e0 100644 (file)
@@ -24,6 +24,7 @@
  ***************************************************************************/
 
 #include <algorithm>
+#include "trefcounter.h"
 
 namespace TagLib {
 
index 0f2b99332e55bc5a48b4a44753784965f10d66d4..d6f51c071cc44262ac3067b89da1a9a0795cda1c 100644 (file)
@@ -23,6 +23,8 @@
  *   http://www.mozilla.org/MPL/                                           *
  ***************************************************************************/
 
+#include "trefcounter.h"
+
 namespace TagLib {
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/taglib/toolkit/trefcounter.cpp b/taglib/toolkit/trefcounter.cpp
new file mode 100644 (file)
index 0000000..b971c93
--- /dev/null
@@ -0,0 +1,105 @@
+/***************************************************************************
+    copyright            : (C) 2013 by Tsuda Kageyu
+    email                : tsuda.kageyu@gmail.com
+ ***************************************************************************/
+
+/***************************************************************************
+ *   This library is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU Lesser General Public License version   *
+ *   2.1 as published by the Free Software Foundation.                     *
+ *                                                                         *
+ *   This library is distributed in the hope that it will be useful, but   *
+ *   WITHOUT ANY WARRANTY; without even the implied warranty of            *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
+ *   Lesser General Public License for more details.                       *
+ *                                                                         *
+ *   You should have received a copy of the GNU Lesser General Public      *
+ *   License along with this library; if not, write to the Free Software   *
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA         *
+ *   02110-1301  USA                                                       *
+ *                                                                         *
+ *   Alternatively, this file is available under the Mozilla Public        *
+ *   License Version 1.1.  You may obtain a copy of the License at         *
+ *   http://www.mozilla.org/MPL/                                           *
+ ***************************************************************************/
+
+#include "config.h"
+#include "trefcounter.h"
+
+#if defined(HAVE_STD_ATOMIC)
+# include <atomic>
+# define ATOMIC_INT std::atomic<unsigned int>
+# define ATOMIC_INC(x) x.fetch_add(1)
+# define ATOMIC_DEC(x) (x.fetch_sub(1) - 1)
+#elif defined(HAVE_BOOST_ATOMIC)
+# include <boost/atomic.hpp>
+# define ATOMIC_INT boost::atomic<unsigned int>
+# define ATOMIC_INC(x) x.fetch_add(1)
+# define ATOMIC_DEC(x) (x.fetch_sub(1) - 1)
+#elif defined(HAVE_GCC_ATOMIC)
+# define ATOMIC_INT int
+# define ATOMIC_INC(x) __sync_add_and_fetch(&x, 1)
+# define ATOMIC_DEC(x) __sync_sub_and_fetch(&x, 1)
+#elif defined(HAVE_WIN_ATOMIC)
+# if !defined(NOMINMAX)
+#   define NOMINMAX
+# endif
+# include <windows.h>
+# define ATOMIC_INT long
+# define ATOMIC_INC(x) InterlockedIncrement(&x)
+# define ATOMIC_DEC(x) InterlockedDecrement(&x)
+#elif defined(HAVE_MAC_ATOMIC)
+# include <libkern/OSAtomic.h>
+# define ATOMIC_INT int32_t
+# define ATOMIC_INC(x) OSAtomicIncrement32Barrier(&x)
+# define ATOMIC_DEC(x) OSAtomicDecrement32Barrier(&x)
+#elif defined(HAVE_IA64_ATOMIC)
+# include <ia64intrin.h>
+# define ATOMIC_INT int
+# define ATOMIC_INC(x) __sync_add_and_fetch(&x, 1)
+# define ATOMIC_DEC(x) __sync_sub_and_fetch(&x, 1)
+#else
+# define ATOMIC_INT int
+# define ATOMIC_INC(x) (++x)
+# define ATOMIC_DEC(x) (--x)
+#endif
+
+namespace TagLib
+{
+  class RefCounter::RefCounterPrivate
+  {
+  public:
+    RefCounterPrivate() : refCount(1) {}
+
+    void ref() { ATOMIC_INC(refCount); }
+    bool deref() { return (ATOMIC_DEC(refCount) == 0); }
+    int count() const { return refCount; }
+
+    volatile ATOMIC_INT refCount;
+  };
+
+  RefCounter::RefCounter()
+    : d(new RefCounterPrivate())
+  {
+  }
+
+  RefCounter::~RefCounter()
+  {
+    delete d;
+  }
+
+  void RefCounter::ref() 
+  { 
+    d->ref(); 
+  }
+
+  bool RefCounter::deref() 
+  { 
+    return d->deref(); 
+  }
+
+  int RefCounter::count() const 
+  { 
+    return d->count(); 
+  }
+}
\ No newline at end of file
diff --git a/taglib/toolkit/trefcounter.h b/taglib/toolkit/trefcounter.h
new file mode 100644 (file)
index 0000000..7559e69
--- /dev/null
@@ -0,0 +1,57 @@
+/***************************************************************************
+    copyright            : (C) 2013 by Tsuda Kageyu
+    email                : tsuda.kageyu@gmail.com
+ ***************************************************************************/
+
+/***************************************************************************
+ *   This library is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU Lesser General Public License version   *
+ *   2.1 as published by the Free Software Foundation.                     *
+ *                                                                         *
+ *   This library is distributed in the hope that it will be useful, but   *
+ *   WITHOUT ANY WARRANTY; without even the implied warranty of            *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
+ *   Lesser General Public License for more details.                       *
+ *                                                                         *
+ *   You should have received a copy of the GNU Lesser General Public      *
+ *   License along with this library; if not, write to the Free Software   *
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA         *
+ *   02110-1301  USA                                                       *
+ *                                                                         *
+ *   Alternatively, this file is available under the Mozilla Public        *
+ *   License Version 1.1.  You may obtain a copy of the License at         *
+ *   http://www.mozilla.org/MPL/                                           *
+ ***************************************************************************/
+
+#ifndef TAGLIB_REFCOUNTER_H
+#define TAGLIB_REFCOUNTER_H
+
+#include "taglib.h"
+
+#ifndef DO_NOT_DOCUMENT // Tell Doxygen to skip this class.
+/*!
+  * \internal
+  * This is just used as a base class for shared classes in TagLib.
+  *
+  * \warning This <b>is not</b> part of the TagLib public API!
+  */
+namespace TagLib
+{
+  class RefCounter
+  {
+  public:
+    RefCounter();
+    virtual ~RefCounter();
+
+    void ref();
+    bool deref();
+    int count() const;
+
+  private:
+    class RefCounterPrivate;
+    RefCounterPrivate *d;
+  };
+}
+
+#endif // DO_NOT_DOCUMENT
+#endif
\ No newline at end of file
index acf4847fb8e2b310135b4d51f75e3565f3f6f3d4..cf745f816e8cd5a8c884c9e43ddd9434ba392e5a 100644 (file)
@@ -30,6 +30,7 @@
 #include "tstring.h"
 #include "tdebug.h"
 #include "tstringlist.h"
+#include "trefcounter.h"
 
 #include <iostream>
 #include <string.h>