Kodi Documentation 22.0
Kodi is an open source media player and entertainment hub.
Loading...
Searching...
No Matches
CWeatherManager Class Reference

#include <WeatherManager.h>

Inheritance diagram for CWeatherManager:
CInfoLoader ISettingCallback IJobCallback

Classes

struct  CaseInsensitiveCompare
 

Public Types

using WeatherInfoV2 = std::map<std::string, std::string, CaseInsensitiveCompare>
 

Public Member Functions

 CWeatherManager (ADDON::CAddonMgr &addonManager)
 
 ~CWeatherManager () override
 
std::string GetProperty (const std::string &property) const
 Retrieve the value for the given weather property.
 
std::string GetDayProperty (unsigned int index, const std::string &property) const
 Retrieve the value for the given "day" weather property.
 
int GetLocation () const
 Get the index for currently active location.
 
void SetLocation (int location)
 Set the active location. Will trigger a data refresh if current location is different from the given location.
 
std::vector< std::string > GetLocations () const
 Get the city names of all available locations, sorted by location index.
 
std::string GetLocation (int iLocation) const
 Retrieve the city name for the specified location from the settings.
 
std::string GetLastUpdateTime () const
 
ForecastDay GetForecast (int day) const
 
bool IsFetched ()
 
- Public Member Functions inherited from CInfoLoader
 CInfoLoader (unsigned int timeToRefresh=5 *60 *1000)
 
 ~CInfoLoader () override
 
std::string GetInfo (int info)
 
void Refresh ()
 
bool IsUpdating () const
 
- Public Member Functions inherited from IJobCallback
virtual ~IJobCallback ()=default
 Destructor for job call back objects.
 
virtual void OnJobAbort (unsigned int jobID, CJob *job)
 An optional callback function used when a job will be aborted.
 
virtual void OnJobProgress (unsigned int jobID, unsigned int progress, unsigned int total, const CJob *job)
 An optional callback function that a job may call while processing.
 
- Public Member Functions inherited from ISettingCallback
virtual ~ISettingCallback ()=default
 
virtual bool OnSettingChanging (const std::shared_ptr< const CSetting > &setting)
 The value of the given setting is being changed.
 
virtual bool OnSettingUpdate (const std::shared_ptr< CSetting > &setting, const char *oldSettingId, const TiXmlNode *oldSettingNode)
 The given setting needs to be updated.
 
virtual void OnSettingPropertyChanged (const std::shared_ptr< const CSetting > &setting, const char *propertyName)
 The given property of the given setting has changed.
 

Static Public Attributes

static constexpr int WEATHER_REFRESH_INTERVAL_MS = 30 * 60 * 1000
 The intervall for refreshing weather data.
 

Protected Member Functions

CJobGetJob () const override
 
std::string TranslateInfo (int info) const override
 
std::string BusyInfo (int info) const override
 
void OnJobComplete (unsigned int jobID, bool success, CJob *job) override
 The callback used when a job completes.
 
void OnSettingChanged (const std::shared_ptr< const CSetting > &setting) override
 The value of the given setting has changed.
 
void OnSettingAction (const std::shared_ptr< const CSetting > &setting) override
 The given setting has been activated.
 
- Protected Member Functions inherited from CInfoLoader
bool RefreshIfNeeded ()
 

Member Typedef Documentation

◆ WeatherInfoV2

using CWeatherManager::WeatherInfoV2 = std::map<std::string, std::string, CaseInsensitiveCompare>

Constructor & Destructor Documentation

◆ CWeatherManager()

CWeatherManager::CWeatherManager ( ADDON::CAddonMgr & addonManager)
explicit

◆ ~CWeatherManager()

CWeatherManager::~CWeatherManager ( )
override

Member Function Documentation

◆ BusyInfo()

std::string CWeatherManager::BusyInfo ( int info) const
overrideprotectedvirtual

Reimplemented from CInfoLoader.

◆ GetDayProperty()

std::string CWeatherManager::GetDayProperty ( unsigned int index,
const std::string & property ) const

Retrieve the value for the given "day" weather property.

Parameters
indexthe index for the day, (can be in the range [0..6])
propertythe name of the property (e.g. HighTemp)
Returns
the property value

◆ GetForecast()

ForecastDay CWeatherManager::GetForecast ( int day) const

◆ GetJob()

CJob * CWeatherManager::GetJob ( ) const
overrideprotectedvirtual

Implements CInfoLoader.

◆ GetLastUpdateTime()

std::string CWeatherManager::GetLastUpdateTime ( ) const

◆ GetLocation() [1/2]

int CWeatherManager::GetLocation ( ) const

Get the index for currently active location.

Returns
the id of the location

◆ GetLocation() [2/2]

std::string CWeatherManager::GetLocation ( int iLocation) const

Retrieve the city name for the specified location from the settings.

Parameters
iLocationthe location index (can be in the range [1..MAXLOCATION])
Returns
the city name (without the accompanying region area code)

◆ GetLocations()

std::vector< std::string > CWeatherManager::GetLocations ( ) const

Get the city names of all available locations, sorted by location index.

Returns
the city names
See also
GetLocation

◆ GetProperty()

std::string CWeatherManager::GetProperty ( const std::string & property) const

Retrieve the value for the given weather property.

Parameters
propertythe full name of the property (e.g. Current.Temperature, Hourly.1.Temperature)
Returns
the property value

◆ IsFetched()

bool CWeatherManager::IsFetched ( )

◆ OnJobComplete()

void CWeatherManager::OnJobComplete ( unsigned int jobID,
bool success,
CJob * job )
overrideprotectedvirtual

The callback used when a job completes.

OnJobComplete is called at the completion of the job's DoWork() function, and is used to return information to the caller on the result of the job. On returning form this function the CJobManager will destroy this job.

Parameters
jobIDthe unique id of the job (as retrieved from CJobManager::AddJob)
successthe result from the DoWork call
jobthe job that has been processed. The job will be destroyed after this function returns
See also
CJobManager and CJob

Reimplemented from CInfoLoader.

◆ OnSettingAction()

void CWeatherManager::OnSettingAction ( const std::shared_ptr< const CSetting > & setting)
overrideprotectedvirtual

The given setting has been activated.

This callback is triggered whenever the given setting has been activated. This callback is only fired for CSettingAction settings.

Parameters
settingThe setting which has been activated.

Reimplemented from ISettingCallback.

◆ OnSettingChanged()

void CWeatherManager::OnSettingChanged ( const std::shared_ptr< const CSetting > & setting)
overrideprotectedvirtual

The value of the given setting has changed.

This callback is triggered whenever the value of a setting has been successfully changed (i.e. none of the OnSettingChanging() handlers) has reverted the change.

Parameters
settingThe setting whose value has been changed

Reimplemented from ISettingCallback.

◆ SetLocation()

void CWeatherManager::SetLocation ( int location)

Set the active location. Will trigger a data refresh if current location is different from the given location.

Parameters
locationthe location index (can be in the range [1..MAXLOCATION])

◆ TranslateInfo()

std::string CWeatherManager::TranslateInfo ( int info) const
overrideprotectedvirtual

Reimplemented from CInfoLoader.

Member Data Documentation

◆ WEATHER_REFRESH_INTERVAL_MS

int CWeatherManager::WEATHER_REFRESH_INTERVAL_MS = 30 * 60 * 1000
staticconstexpr

The intervall for refreshing weather data.


The documentation for this class was generated from the following files: