OpenCPN Partial API docs
Loading...
Searching...
No Matches
obs::Observable Class Reference

The observable notify/listen basic nuts and bolts. More...

#include <observable.h>

Inheritance diagram for obs::Observable:
obs::KeyProvider obs::ConfigVar< T > obs::EventVar obs::GlobalVar< T >

Public Member Functions

 Observable (const std::string &_key)
 Initiate an object which can apply Notify() and Listen() to given key.
 
 Observable (const KeyProvider &kp)
 Initiate an object which can apply Notify() and Listen() to given key.
 
virtual void Notify ()
 Notify all listeners to configured key about variable change.
 
virtual void Notify (const std::shared_ptr< const void > &p)
 Notify all listeners to configured key about variable change.
 
bool Unlisten (wxEvtHandler *listener, wxEventType ev)
 Remove window listening to ev from list of listeners.
 
std::string GetKey () const override
 Return the key given to the constructor.
 

Public Attributes

const std::string key
 The key used to create and clone.
 

Protected Member Functions

void Notify (const std::shared_ptr< const void > &ptr, const std::string &s, int num, void *client_data)
 Notify all listeners: send them a 'type' ObservedEvt message as defined by Listen() with optional data available using GetString(), GetClientData(), GetInt() and/or GetSharedPtr()
 
void Notify (const std::string &s, void *client_data)
 Notify all listeners: send them a 'type' ObservedEvt message as defined by Listen() with optional data available using GetString(), and/or GetClientData().
 

Friends

class ::ObservableListener
 

Detailed Description

The observable notify/listen basic nuts and bolts.


Definition at line 100 of file observable.h.

Constructor & Destructor Documentation

◆ Observable() [1/2]

obs::Observable::Observable ( const std::string &  _key)
inlineexplicit

Initiate an object which can apply Notify() and Listen() to given key.

Definition at line 105 of file observable.h.

◆ Observable() [2/2]

obs::Observable::Observable ( const KeyProvider kp)
inlineexplicit

Initiate an object which can apply Notify() and Listen() to given key.

Definition at line 109 of file observable.h.

Member Function Documentation

◆ GetKey()

std::string obs::Observable::GetKey ( ) const
inlineoverridevirtual

Return the key given to the constructor.

Implements obs::KeyProvider.

Definition at line 133 of file observable.h.

◆ Notify() [1/4]

void obs::Observable::Notify ( )
virtual

Notify all listeners to configured key about variable change.

Reimplemented in obs::EventVar.

Definition at line 95 of file observable.cpp.

◆ Notify() [2/4]

virtual void obs::Observable::Notify ( const std::shared_ptr< const void > &  p)
inlinevirtual

Notify all listeners to configured key about variable change.

Send them a 'type' ObservedEvt message as defined by Listen() with a shared_ptr<const whatever> available to listeners using event.GetSharedPtr().

Reimplemented in obs::EventVar.

Definition at line 122 of file observable.h.

◆ Notify() [3/4]

void obs::Observable::Notify ( const std::shared_ptr< const void > &  ptr,
const std::string &  s,
int  num,
void *  client_data 
)
protected

Notify all listeners: send them a 'type' ObservedEvt message as defined by Listen() with optional data available using GetString(), GetClientData(), GetInt() and/or GetSharedPtr()

Definition at line 80 of file observable.cpp.

◆ Notify() [4/4]

void obs::Observable::Notify ( const std::string &  s,
void *  client_data 
)
inlineprotected

Notify all listeners: send them a 'type' ObservedEvt message as defined by Listen() with optional data available using GetString(), and/or GetClientData().

Definition at line 152 of file observable.h.

◆ Unlisten()

bool obs::Observable::Unlisten ( wxEvtHandler *  listener,
wxEventType  ev 
)

Remove window listening to ev from list of listeners.

Returns
true if such a listener existed, else false.

Definition at line 69 of file observable.cpp.

Friends And Related Symbol Documentation

◆ ::ObservableListener

friend class ::ObservableListener
friend

Definition at line 101 of file observable.h.

Member Data Documentation

◆ key

const std::string obs::Observable::key

The key used to create and clone.

Definition at line 136 of file observable.h.


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