summaryrefslogtreecommitdiffstats
path: root/xbmc/BackgroundInfoLoader.h
diff options
context:
space:
mode:
Diffstat (limited to 'xbmc/BackgroundInfoLoader.h')
-rw-r--r--xbmc/BackgroundInfoLoader.h62
1 files changed, 62 insertions, 0 deletions
diff --git a/xbmc/BackgroundInfoLoader.h b/xbmc/BackgroundInfoLoader.h
new file mode 100644
index 0000000..31de46c
--- /dev/null
+++ b/xbmc/BackgroundInfoLoader.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2005-2018 Team Kodi
+ * This file is part of Kodi - https://kodi.tv
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ * See LICENSES/README.md for more information.
+ */
+
+#pragma once
+
+#include "IProgressCallback.h"
+#include "threads/CriticalSection.h"
+#include "threads/IRunnable.h"
+
+#include <memory>
+#include <vector>
+
+class CFileItem; typedef std::shared_ptr<CFileItem> CFileItemPtr;
+class CFileItemList;
+class CThread;
+
+class IBackgroundLoaderObserver
+{
+public:
+ virtual ~IBackgroundLoaderObserver() = default;
+ virtual void OnItemLoaded(CFileItem* pItem) = 0;
+};
+
+class CBackgroundInfoLoader : public IRunnable
+{
+public:
+ CBackgroundInfoLoader();
+ ~CBackgroundInfoLoader() override;
+
+ void Load(CFileItemList& items);
+ bool IsLoading();
+ void Run() override;
+ void SetObserver(IBackgroundLoaderObserver* pObserver);
+ void SetProgressCallback(IProgressCallback* pCallback);
+ virtual bool LoadItem(CFileItem* pItem) { return false; }
+ virtual bool LoadItemCached(CFileItem* pItem) { return false; }
+ virtual bool LoadItemLookup(CFileItem* pItem) { return false; }
+
+ void StopThread(); // will actually stop the loader thread.
+ void StopAsync(); // will ask loader to stop as soon as possible, but not block
+
+protected:
+ virtual void OnLoaderStart() {}
+ virtual void OnLoaderFinish() {}
+
+ CFileItemList *m_pVecItems;
+ std::vector<CFileItemPtr> m_vecItems; // FileItemList would delete the items and we only want to keep a reference.
+ CCriticalSection m_lock;
+
+ volatile bool m_bIsLoading;
+ volatile bool m_bStop;
+ CThread *m_thread;
+
+ IBackgroundLoaderObserver* m_pObserver;
+ IProgressCallback* m_pProgressCallback;
+};
+