xbmc
AddonEvents.h
1 /*
2  * Copyright (C) 2016-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "addons/IAddon.h"
12 
13 #include <string>
14 
15 namespace ADDON
16 {
17 
18 struct AddonEvent
19 {
20  std::string addonId;
21  AddonInstanceId instanceId{ADDON_SINGLETON_INSTANCE_ID};
22 
23  explicit AddonEvent(std::string addonId) : addonId(std::move(addonId)) {}
24  AddonEvent(std::string addonId, AddonInstanceId instanceId)
25  : addonId(std::move(addonId)), instanceId(instanceId)
26  {
27  }
28 
29  // Note: Do not remove the virtual dtor. There are types derived from AddonEvent (see below)
30  // and there are several places where 'typeid' is used to determine the runtime type of
31  // AddonEvent references. And 'typeid' only works for polymorphic objects.
32  virtual ~AddonEvent() = default;
33 };
34 
35 namespace AddonEvents
36 {
37 
42 {
43  explicit Enabled(std::string addonId) : AddonEvent(std::move(addonId)) {}
44 };
45 
50 {
51  explicit Disabled(std::string addonId) : AddonEvent(std::move(addonId)) {}
52 };
53 
58 {
59  InstanceAdded(std::string addonId, AddonInstanceId instanceId)
60  : AddonEvent(std::move(addonId), instanceId)
61  {
62  }
63 };
64 
69 {
70  InstanceRemoved(std::string addonId, AddonInstanceId instanceId)
71  : AddonEvent(std::move(addonId), instanceId)
72  {
73  }
74 };
75 
80 {
81  explicit MetadataChanged(std::string addonId) : AddonEvent(std::move(addonId)) {}
82 };
83 
89 {
90  explicit ReInstalled(std::string addonId) : AddonEvent(std::move(addonId)) {}
91 };
92 
97 {
98  explicit UnInstalled(std::string addonId) : AddonEvent(std::move(addonId)) {}
99 };
100 
104 struct Load : AddonEvent
105 {
106  explicit Load(std::string addonId) : AddonEvent(std::move(addonId)) {}
107 };
108 
113 {
114  explicit Unload(std::string addonId) : AddonEvent(std::move(addonId)) {}
115 };
116 
121 {
122  explicit AutoUpdateStateChanged(std::string addonId) : AddonEvent(std::move(addonId)) {}
123 };
124 
125 } // namespace AddonEvents
126 } // namespace ADDON
Emitted after the add-on has been disabled.
Definition: AddonEvents.h:49
Emitted after the add-on has been uninstalled.
Definition: AddonEvents.h:96
Definition: AddonEvents.h:18
Emitted after the add-on&#39;s metadata has been changed.
Definition: AddonEvents.h:79
Emitted after a new usable add-on instance was added.
Definition: AddonEvents.h:57
Definition: Addon.cpp:39
Emitted after an add-on instance was removed.
Definition: AddonEvents.h:68
Emitted after the add-on has been enabled.
Definition: AddonEvents.h:41
Emitted after the add-on has been unloaded.
Definition: AddonEvents.h:112
Emitted when a different version of the add-on has been installed to the file system and should be re...
Definition: AddonEvents.h:88
Emitted after the auto-update state of the add-on has been changed.
Definition: AddonEvents.h:120
Emitted after the add-on has been loaded.
Definition: AddonEvents.h:104