OpenCPN Partial API docs
Loading...
Searching...
No Matches
EventVar Class Reference

Generic event handling between MVC Model and Controller based on a shared EventVar variable. More...

#include <observable_evtvar.h>

Inheritance diagram for EventVar:
Observable KeyProvider

Public Member Functions

const void Notify ()
 Notify all listeners, no data supplied.
 
const void Notify (void *data)
 Notify all listeners about variable change with ClientData.
 
const void Notify (const std::string &s)
 Notify all listeners about variable change with a string.
 
const void Notify (int n, const std::string &s)
 Notify all listeners about variable change with a string and an int.
 
const void Notify (int n, void *p)
 Notify all listeners about variable change with an int and ClientData.
 
const void Notify (std::shared_ptr< void > p, const std::string &s, int n=0)
 Notify all listeners about variable change with shared_ptr, a string and an optional number.
 
- Public Member Functions inherited from Observable
 Observable (const std::string &_key)
 
 Observable (const KeyProvider &kp)
 
const void Notify (std::shared_ptr< const void > p)
 
bool Unlisten (wxEvtHandler *listener, wxEventType ev)
 Remove window listening to ev from list of listeners.
 
std::string GetKey () const
 

Additional Inherited Members

- Public Attributes inherited from Observable
const std::string key
 The key used to create and clone.
 
- Protected Member Functions inherited from Observable
const void Notify (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() and/or GetClientData().
 
const void Notify (const std::string &s, void *client_data)
 

Detailed Description

Generic event handling between MVC Model and Controller based on a shared EventVar variable.

Model usage:

class Model: ...
public:
EventVar change;
void some_method() {
...
change.Notify("new value")
}
Generic event handling between MVC Model and Controller based on a shared EventVar variable.

Controller/GUI usage:

class Gui: public wxEvtHandler {
public:
Gui:Gui(Model& model) {
auto action = [&](wxCommandEvent ev) {
auto s = ev.GetString(); // s -> "new value"
... do something;
});
change_listener.Init(model.change, action);
}
private:
ObsListener change_listener;
}
Define an action to be performed when a KeyProvider is notified.
Definition observable.h:228

Definition at line 71 of file observable_evtvar.h.

Constructor & Destructor Documentation

◆ EventVar()

EventVar::EventVar ( )
inline

Definition at line 73 of file observable_evtvar.h.

Member Function Documentation

◆ Notify() [1/6]

const void EventVar::Notify ( )
inlinevirtual

Notify all listeners, no data supplied.

Reimplemented from Observable.

Definition at line 76 of file observable_evtvar.h.

◆ Notify() [2/6]

const void EventVar::Notify ( const std::string &  s)
inline

Notify all listeners about variable change with a string.

Definition at line 82 of file observable_evtvar.h.

◆ Notify() [3/6]

const void EventVar::Notify ( int  n,
const std::string &  s 
)
inline

Notify all listeners about variable change with a string and an int.

Definition at line 85 of file observable_evtvar.h.

◆ Notify() [4/6]

const void EventVar::Notify ( int  n,
void *  p 
)
inline

Notify all listeners about variable change with an int and ClientData.

Definition at line 88 of file observable_evtvar.h.

◆ Notify() [5/6]

const void EventVar::Notify ( std::shared_ptr< void >  p,
const std::string &  s,
int  n = 0 
)
inline

Notify all listeners about variable change with shared_ptr, a string and an optional number.

Definition at line 94 of file observable_evtvar.h.

◆ Notify() [6/6]

const void EventVar::Notify ( void *  data)
inline

Notify all listeners about variable change with ClientData.

Definition at line 79 of file observable_evtvar.h.


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