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

#include <Observer.h>

Inheritance diagram for Observable:
CDisplaySettings CGameSettings CInputManager KODI::GAME::CAgentInput KODI::GAME::CGameClientInput KODI::GAME::CGameSettings KODI::SUBTITLES::CSubtitlesSettings PERIPHERALS::CPeripherals

Public Member Functions

 Observable ()=default
 
virtual ~Observable ()=default
 
Observableoperator= (const Observable &observable)
 
virtual void RegisterObserver (Observer *obs)
 Register an observer.
 
virtual void UnregisterObserver (Observer *obs)
 Unregister an observer.
 
virtual void NotifyObservers (const ObservableMessage message=ObservableMessageNone)
 Send a message to all observers when m_bObservableChanged is true.
 
virtual void SetChanged (bool bSetTo=true)
 Mark an observable changed.
 
virtual bool IsObserving (const Observer &obs) const
 Check whether this observable is being observed by an observer.
 

Protected Member Functions

void SendMessage (const ObservableMessage message)
 Send a message to all observer when m_bObservableChanged is true.
 

Protected Attributes

std::atomic< boolm_bObservableChanged {false}
 
std::vector< Observer * > m_observers
 
CCriticalSection m_obsCritSection
 

Friends

class ObservableMessageJob
 

Constructor & Destructor Documentation

◆ Observable()

Observable::Observable ( )
default

◆ ~Observable()

virtual Observable::~Observable ( )
virtualdefault

Member Function Documentation

◆ IsObserving()

bool Observable::IsObserving ( const Observer & obs) const
virtual

Check whether this observable is being observed by an observer.

Parameters
obsThe observer to check.
Returns
True if this observable is being observed by the given observer, false otherwise.

◆ NotifyObservers()

void Observable::NotifyObservers ( const ObservableMessage message = ObservableMessageNone)
virtual

Send a message to all observers when m_bObservableChanged is true.

Parameters
messageThe message to send.

◆ operator=()

Observable & Observable::operator= ( const Observable & observable)

◆ RegisterObserver()

void Observable::RegisterObserver ( Observer * obs)
virtual

Register an observer.

Parameters
obsThe observer to register.

◆ SendMessage()

void Observable::SendMessage ( const ObservableMessage message)
protected

Send a message to all observer when m_bObservableChanged is true.

Parameters
obsThe observer that sends the message.
messageThe message to send.

◆ SetChanged()

void Observable::SetChanged ( bool bSetTo = true)
virtual

Mark an observable changed.

Parameters
bSetToTrue to mark the observable changed, false to mark it as unchanged.

◆ UnregisterObserver()

void Observable::UnregisterObserver ( Observer * obs)
virtual

Unregister an observer.

Parameters
obsThe observer to unregister.

Friends And Related Symbol Documentation

◆ ObservableMessageJob

friend class ObservableMessageJob
friend

Member Data Documentation

◆ m_bObservableChanged

std::atomic<bool> Observable::m_bObservableChanged {false}
protected

true when the observable is marked as changed, false otherwise

◆ m_obsCritSection

CCriticalSection Observable::m_obsCritSection
mutableprotected

mutex

◆ m_observers

std::vector<Observer *> Observable::m_observers
protected

all observers


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