2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
11 #include "IProgressCallback.h"
12 #include "threads/CriticalSection.h"
13 #include "threads/IRunnable.h"
18 class CFileItem
; typedef std::shared_ptr
<CFileItem
> CFileItemPtr
;
22 class IBackgroundLoaderObserver
25 virtual ~IBackgroundLoaderObserver() = default;
26 virtual void OnItemLoaded(CFileItem
* pItem
) = 0;
29 class CBackgroundInfoLoader
: public IRunnable
32 CBackgroundInfoLoader();
33 ~CBackgroundInfoLoader() override
;
35 void Load(CFileItemList
& items
);
38 void SetObserver(IBackgroundLoaderObserver
* pObserver
);
39 void SetProgressCallback(IProgressCallback
* pCallback
);
40 virtual bool LoadItem(CFileItem
* pItem
) { return false; }
41 virtual bool LoadItemCached(CFileItem
* pItem
) { return false; }
42 virtual bool LoadItemLookup(CFileItem
* pItem
) { return false; }
44 void StopThread(); // will actually stop the loader thread.
45 void StopAsync(); // will ask loader to stop as soon as possible, but not block
48 virtual void OnLoaderStart() {}
49 virtual void OnLoaderFinish() {}
51 CFileItemList
* m_pVecItems
{nullptr};
52 std::vector
<CFileItemPtr
> m_vecItems
; // FileItemList would delete the items and we only want to keep a reference.
53 CCriticalSection m_lock
;
55 volatile bool m_bIsLoading
{false};
56 volatile bool m_bStop
{true};
57 CThread
* m_thread
{nullptr};
59 IBackgroundLoaderObserver
* m_pObserver
{nullptr};
60 IProgressCallback
* m_pProgressCallback
{nullptr};