]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/mimecmn.cpp
wx/debug.h is always unconditionally included by wx/defs.h
[wxWidgets.git] / src / common / mimecmn.cpp
index 4afd332148bdf150522813524c4ed1e875e25a91..27d4b8d4295cc0f0fa1f018967f4053dd5aa5581 100644 (file)
@@ -1,5 +1,5 @@
 /////////////////////////////////////////////////////////////////////////////
-// Name:        common/mimecmn.cpp
+// Name:        src/common/mimecmn.cpp
 // Purpose:     classes and functions to manage MIME types
 // Author:      Vadim Zeitlin
 // Modified by:
 
 #if wxUSE_MIMETYPE
 
+#include "wx/mimetype.h"
+
 #ifndef WX_PRECOMP
-  #include "wx/string.h"
+    #include "wx/dynarray.h"
+    #include "wx/string.h"
+    #include "wx/intl.h"
+    #include "wx/log.h"
 #endif //WX_PRECOMP
 
 #include "wx/module.h"
-#include "wx/log.h"
 #include "wx/file.h"
 #include "wx/iconloc.h"
-#include "wx/intl.h"
-#include "wx/dynarray.h"
 #include "wx/confbase.h"
 
-#include "wx/mimetype.h"
-
 // other standard headers
 #include <ctype.h>
 
@@ -453,6 +453,34 @@ bool wxFileType::SetDefaultIcon(const wxString& cmd, int index)
 #endif
 }
 
+//----------------------------------------------------------------------------
+// wxMimeTypesManagerFactory
+//----------------------------------------------------------------------------
+
+wxMimeTypesManagerFactory *wxMimeTypesManagerFactory::m_factory = NULL;
+
+/* static */
+void wxMimeTypesManagerFactory::SetFactory( wxMimeTypesManagerFactory *factory )
+{
+    if (wxMimeTypesManagerFactory::m_factory)
+        delete wxMimeTypesManagerFactory::m_factory;
+
+    wxMimeTypesManagerFactory::m_factory = factory;
+}
+
+/* static */
+wxMimeTypesManagerFactory *wxMimeTypesManagerFactory::GetFactory()
+{
+    if (!wxMimeTypesManagerFactory::m_factory)
+        wxMimeTypesManagerFactory::m_factory = new wxMimeTypesManagerFactory;
+
+    return wxMimeTypesManagerFactory::m_factory;
+}
+
+wxMimeTypesManagerImpl *wxMimeTypesManagerFactory::CreateMimeTypesManagerImpl()
+{
+    return new wxMimeTypesManagerImpl;
+}
 
 // ----------------------------------------------------------------------------
 // wxMimeTypesManager
@@ -461,7 +489,7 @@ bool wxFileType::SetDefaultIcon(const wxString& cmd, int index)
 void wxMimeTypesManager::EnsureImpl()
 {
     if ( !m_impl )
-        m_impl = new wxMimeTypesManagerImpl;
+        m_impl = wxMimeTypesManagerFactory::GetFactory()->CreateMimeTypesManagerImpl();
 }
 
 bool wxMimeTypesManager::IsOfType(const wxString& mimeType,