[Windows] Fix driver version detection of AMD RDNA+ GPU on Windows 10
[xbmc.git] / xbmc / addons / binary-addons / AddonInstanceHandler.h
blob27ba95b2be16ac1145241c29d07f4cd961b595e6
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 "addons/IAddon.h"
12 #include "addons/kodi-dev-kit/include/kodi/c-api/addon_base.h"
13 #include "addons/kodi-dev-kit/include/kodi/versions.h"
14 #include "threads/CriticalSection.h"
16 #include <memory>
17 #include <string>
19 class CSetting;
21 namespace ADDON
24 class CAddonDll;
25 using AddonDllPtr = std::shared_ptr<CAddonDll>;
27 class CAddonInfo;
28 using AddonInfoPtr = std::shared_ptr<CAddonInfo>;
30 class CBinaryAddonBase;
31 using BinaryAddonBasePtr = std::shared_ptr<CBinaryAddonBase>;
33 class IAddonInstanceHandler
35 public:
36 /**
37 * @brief Class constructor for handling add-on instance processes, allowing
38 * an add-on to handle multiple work simultaneously and independently.
40 * @param[in] type The associated add-on type which is processed in the running
41 * instance.
42 * @param[in] addonInfo Class for querying available add-on information (e.g.
43 * content declared in addon.xml).
44 * @param[in] parentInstance *[opt]* Above running add-on instance which starts this
45 * instance. Used to have the associated class for
46 * work to open in the add-on.\n\n
47 * **Currently used values:**
48 * | Parent | Target | Description
49 * |--------|--------|-------------
50 * | @ref kodi::addon::CInstanceInputStream | @ref kodi::addon::CInstanceVideoCodec | In order to be able to access the overlying input stream instance in the video codec created by Kodi on the add-on.
51 * @param[in] uniqueWorkID *[opt]* Identification value intended to pass any special
52 * values to the instance to be opened.
53 * If not used, the IAddonInstanceHandler class pointer
54 * is used as a string.\n\n
55 * **Currently used values:**
56 * | Add-on instance type | Description
57 * |----------------------|---------------------
58 * | @ref kodi::addon::CInstanceInputStream "Inputstream" | To transfer special values to inputstream using the property @ref STREAM_PROPERTY_INPUTSTREAM_INSTANCE_ID from external space, for example PVR add-on which also supports inputstream can exchange special values with it, e.g. select the necessary add-on processing class, since it is not known at the start what is being executed ( live TV, radio, recordings...) and add-on may use different classes.
59 * | All other | The used class pointer of Kodi's @ref IAddonInstanceHandler is used as a value to have an individually different value.
61 IAddonInstanceHandler(ADDON_TYPE type,
62 const AddonInfoPtr& addonInfo,
63 AddonInstanceId instanceId = ADDON_INSTANCE_ID_UNUSED,
64 KODI_HANDLE parentInstance = nullptr,
65 const std::string& uniqueWorkID = "");
66 virtual ~IAddonInstanceHandler();
68 ADDON_TYPE UsedType() const { return m_type; }
69 AddonInstanceId InstanceId() const { return m_instanceId; }
70 const std::string& UniqueWorkID() { return m_uniqueWorkID; }
72 std::string ID() const;
73 std::string Name() const;
74 std::string Author() const;
75 std::string Icon() const;
76 std::string Path() const;
77 std::string Profile() const;
78 CAddonVersion Version() const;
80 ADDON_STATUS CreateInstance();
81 void DestroyInstance();
82 const AddonDllPtr& Addon() const { return m_addon; }
83 AddonInfoPtr GetAddonInfo() const { return m_addonInfo; }
85 virtual void OnPreInstall() {}
86 virtual void OnPostInstall(bool update, bool modal) {}
87 virtual void OnPreUnInstall() {}
88 virtual void OnPostUnInstall() {}
90 protected:
91 KODI_ADDON_INSTANCE_INFO m_info{};
92 KODI_ADDON_INSTANCE_STRUCT m_ifc{};
94 private:
95 std::shared_ptr<CSetting> GetSetting(const std::string& setting);
97 static char* get_instance_user_path(const KODI_ADDON_INSTANCE_BACKEND_HDL hdl);
98 static bool is_instance_setting_using_default(const KODI_ADDON_INSTANCE_BACKEND_HDL hdl,
99 const char* id);
100 static bool get_instance_setting_bool(const KODI_ADDON_INSTANCE_BACKEND_HDL hdl,
101 const char* id,
102 bool* value);
103 static bool get_instance_setting_int(const KODI_ADDON_INSTANCE_BACKEND_HDL hdl,
104 const char* id,
105 int* value);
106 static bool get_instance_setting_float(const KODI_ADDON_INSTANCE_BACKEND_HDL hdl,
107 const char* id,
108 float* value);
109 static bool get_instance_setting_string(const KODI_ADDON_INSTANCE_BACKEND_HDL hdl,
110 const char* id,
111 char** value);
112 static bool set_instance_setting_bool(const KODI_ADDON_INSTANCE_BACKEND_HDL hdl,
113 const char* id,
114 bool value);
115 static bool set_instance_setting_int(const KODI_ADDON_INSTANCE_BACKEND_HDL hdl,
116 const char* id,
117 int value);
118 static bool set_instance_setting_float(const KODI_ADDON_INSTANCE_BACKEND_HDL hdl,
119 const char* id,
120 float value);
121 static bool set_instance_setting_string(const KODI_ADDON_INSTANCE_BACKEND_HDL hdl,
122 const char* id,
123 const char* value);
125 const ADDON_TYPE m_type;
126 const AddonInstanceId m_instanceId;
127 std::string m_uniqueWorkID;
128 KODI_HANDLE m_parentInstance;
129 AddonInfoPtr m_addonInfo;
130 BinaryAddonBasePtr m_addonBase;
131 AddonDllPtr m_addon;
132 static CCriticalSection m_cdSec;
135 } /* namespace ADDON */