[windows] Fix MAC Address Discovery
[xbmc.git] / xbmc / BackgroundInfoLoader.h
blob1f58fe502e228c502bb989d9713c9600fe866fa3
1 /*
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.
7 */
9 #pragma once
11 #include "IProgressCallback.h"
12 #include "threads/CriticalSection.h"
13 #include "threads/IRunnable.h"
15 #include <memory>
16 #include <vector>
18 class CFileItem; typedef std::shared_ptr<CFileItem> CFileItemPtr;
19 class CFileItemList;
20 class CThread;
22 class IBackgroundLoaderObserver
24 public:
25 virtual ~IBackgroundLoaderObserver() = default;
26 virtual void OnItemLoaded(CFileItem* pItem) = 0;
29 class CBackgroundInfoLoader : public IRunnable
31 public:
32 CBackgroundInfoLoader();
33 ~CBackgroundInfoLoader() override;
35 void Load(CFileItemList& items);
36 bool IsLoading();
37 void Run() override;
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
47 protected:
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};
62 private:
63 void Reset();