Kodi Development 22.0
for Binary and Script based Add-Ons
 
Loading...
Searching...
No Matches
class CAddonBase

Detailed Description

Add-on main instance class
This is the addon main class, similar to an int main() in executable and carries out initial work and later management of it.

Topics

 Definitions, structures and enumerators
 General definition values
 

Function Documentation

◆ CAddonBase()

CAddonBase ( )
inline

Addon base class constructor.

◆ ~CAddonBase()

virtual ~CAddonBase ( )
virtualdefault

Destructor.

◆ Create()

virtual ADDON_STATUS Create ( )
inlinevirtual

Main addon creation function.

With this function addon can carry out necessary work which is required at later points or start necessary processes.

This function is optional and necessary work can also be carried out using CreateInstance (if it concerns any instance types).

Returns
ADDON_STATUS_OK if correct, for possible errors see ADDON_STATUS
Note
Terminating the add-on must be carried out using the class destructor given by child.

◆ SetSetting()

virtual ADDON_STATUS SetSetting ( const std::string & settingName,
const kodi::addon::CSettingValue & settingValue )
inlinevirtual

To inform addon about changed settings values.

This becomes called for every entry defined inside his settings.xml and as last call the one where last in xml (to identify end of calls).


The following table contains values that can be set with class CSettingValue :

Name Type Get call
Settings value as string std::string GetString
Settings value as integer int GetInt
Settings value as unsigned integer unsigned int GetUInt
Settings value as boolean bool GetBoolean
Settings value as floating point float GetFloat
Settings value as enum enum GetEnum

Here is a code example how this is used:

#include <kodi/AddonBase.h>
{
};
std::string m_myStringValue;
ADDON_STATUS CMyAddon::SetSetting(const std::string& settingName, const kodi::addon::CSettingValue& settingValue)
{
if (settingName == "my_string_value")
else if (settingName == "my_integer_value")
else if (settingName == "my_boolean_value")
else if (settingName == "my_float_value")
else if (settingName == "my_enum_value")
}
Definition AddonBase.h:245
Definition PeripheralUtils.h:48
ADDON_STATUS
Definition addon_base.h:138
Note
The asked type should match the type used on settings.xml.

◆ CreateInstance()

virtual ADDON_STATUS CreateInstance ( const kodi::addon::IInstanceInfo & instance,
KODI_ADDON_INSTANCE_HDL & hdl )
inlinevirtual

Instance created.

Parameters
[in]instanceInstance informations about
[out]hdlThe pointer to instance class created in addon. Needed to be able to identify them on calls.
Returns
ADDON_STATUS_OK if correct, for possible errors see ADDON_STATUS

Here is a code example how this is used:

#include <kodi/AddonBase.h>
...
// If you use only one instance in your add-on, can be instanceType and
// instanceID ignored
ADDON_STATUS CMyAddon::CreateInstance(const kodi::addon::IInstanceInfo& instance,
KODI_ADDON_INSTANCE_HDL& hdl)
{
{
kodi::Log(ADDON_LOG_INFO, "Creating my Screensaver");
hdl = new CMyScreensaver(instance);
}
{
kodi::Log(ADDON_LOG_INFO, "Creating my Visualization");
hdl = new CMyVisualization(instance);
}
else if (...)
{
...
}
}
...
Definition AddonBase.h:306
@ ADDON_LOG_INFO
1 : To include information messages in the log file.
Definition addon_base.h:187
@ ADDON_STATUS_OK
For everything OK and no error.
Definition addon_base.h:140
@ ADDON_STATUS_UNKNOWN
Unknown and incomprehensible error.
Definition addon_base.h:152
@ ADDON_INSTANCE_VISUALIZATION
Music visualization instance, see kodi::addon::CInstanceVisualization.
Definition versions.h:239
@ ADDON_INSTANCE_SCREENSAVER
Screen saver instance, see kodi::addon::CInstanceScreensaver.
Definition versions.h:236
bool IsType(KODI_ADDON_INSTANCE_TYPE type) const
Check asked type used on this class.
Definition AddonBase.h:333
void ATTR_DLL_LOCAL Log(const ADDON_LOG loglevel, const char *format,...)
Add a message to Kodi's log.
Definition AddonBase.h:1746

◆ DestroyInstance()

virtual void DestroyInstance ( const IInstanceInfo & instance,
const KODI_ADDON_INSTANCE_HDL hdl )
inlinevirtual

Instance destroy.

This function is optional and intended to notify addon that the instance is terminating.

Parameters
[in]instanceInstance informations about
[in]hdlThe pointer to instance class created in addon.
Warning
This call is only used to inform that the associated instance is terminated. The deletion is carried out in the background.