add CFileItemListModification to handle all IFileItemListModifier implementations
authormontellese <montellese@xbmc.org>
Wed, 7 Aug 2013 15:10:08 +0000 (17:10 +0200)
committermontellese <montellese@xbmc.org>
Sun, 3 Nov 2013 09:05:15 +0000 (10:05 +0100)
xbmc/FileItemListModification.cpp [new file with mode: 0644]
xbmc/FileItemListModification.h [new file with mode: 0644]
xbmc/Makefile.in

diff --git a/xbmc/FileItemListModification.cpp b/xbmc/FileItemListModification.cpp
new file mode 100644 (file)
index 0000000..a092e57
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ *      Copyright (C) 2013 Team XBMC
+ *      http://xbmc.org
+ *
+ *  This Program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2, or (at your option)
+ *  any later version.
+ *
+ *  This Program 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 General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with XBMC; see the file COPYING.  If not, see
+ *  <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "FileItemListModification.h"
+
+#include "playlists/SmartPlaylistFileItemListModifier.h"
+
+using namespace std;
+
+CFileItemListModification::CFileItemListModification()
+{
+  m_modifiers.insert(new CSmartPlaylistFileItemListModifier());
+}
+
+CFileItemListModification::~CFileItemListModification()
+{
+  for (set<IFileItemListModifier*>::const_iterator modifier = m_modifiers.begin(); modifier != m_modifiers.end(); ++modifier)
+    delete *modifier;
+
+  m_modifiers.clear();
+}
+
+CFileItemListModification& CFileItemListModification::Get()
+{
+  static CFileItemListModification instance;
+  return instance;
+}
+
+bool CFileItemListModification::CanModify(const CFileItemList &items) const
+{
+  for (set<IFileItemListModifier*>::const_iterator modifier = m_modifiers.begin(); modifier != m_modifiers.end(); ++modifier)
+  {
+    if ((*modifier)->CanModify(items))
+      return true;
+  }
+
+  return false;
+}
+
+bool CFileItemListModification::Modify(CFileItemList &items) const
+{
+  bool result = false;
+  for (set<IFileItemListModifier*>::const_iterator modifier = m_modifiers.begin(); modifier != m_modifiers.end(); ++modifier)
+    result |= (*modifier)->Modify(items);
+
+  return result;
+}
diff --git a/xbmc/FileItemListModification.h b/xbmc/FileItemListModification.h
new file mode 100644 (file)
index 0000000..8be9398
--- /dev/null
@@ -0,0 +1,42 @@
+#pragma once
+/*
+ *      Copyright (C) 2013 Team XBMC
+ *      http://xbmc.org
+ *
+ *  This Program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2, or (at your option)
+ *  any later version.
+ *
+ *  This Program 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 General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with XBMC; see the file COPYING.  If not, see
+ *  <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <set>
+
+#include "IFileItemListModifier.h"
+
+class CFileItemListModification : public IFileItemListModifier
+{
+public:
+  ~CFileItemListModification();
+
+  static CFileItemListModification& Get();
+
+  virtual bool CanModify(const CFileItemList &items) const;
+  virtual bool Modify(CFileItemList &items) const;
+
+private:
+  CFileItemListModification();
+  CFileItemListModification(const CFileItemListModification&);
+  CFileItemListModification const& operator=(CFileItemListModification const&);
+
+  std::set<IFileItemListModifier*> m_modifiers;
+};
index 2dd53f8..76ec9bf 100644 (file)
@@ -10,6 +10,7 @@ SRCS=Application.cpp \
      DbUrl.cpp \
      DynamicDll.cpp \
      FileItem.cpp \
+     FileItemListModification.cpp \
      GitRevision.cpp \
      GUIInfoManager.cpp \
      GUILargeTextureManager.cpp \