Lomse library. API documentation  0.30.0
Observable Class Referenceabstract

#include <lomse_events.h>

Inheritance diagram for Observable:
Interactor

Detailed Description

Any object generating events must derive from Observable and must implement method "get_event_notifier()".

In order to allow for different event management models, responsibilities for event generation and event dispatching are decoupled. For this, the Observable pattern is split into two objects: the Observable itself is just a facade object providing the interface for adding/removing observers, and delegates in the EventNotifier object for doing the real work and event dispatching.

Public Types

enum  EObservedChild
 

Public Member Functions

virtual ~Observable ()
 
virtual EventNotifierget_event_notifier ()=0
 
virtual void add_event_handler (int eventType, EventHandler *pHandler)
 
virtual void add_event_handler (int eventType, void *pThis, void(*pt2Func)(void *pObj, SpEventInfo event))
 
virtual void add_event_handler (int eventType, void(*pt2Func)(SpEventInfo event))
 
void add_event_handler (int childType, ImoId childId, int eventType, EventHandler *pHandler)
 
void add_event_handler (int childType, ImoId childId, int eventType, void *pThis, void(*pt2Func)(void *pObj, SpEventInfo event))
 
void add_event_handler (int childType, ImoId childId, int eventType, void(*pt2Func)(SpEventInfo event))
 
virtual Observableget_observable_child (int UNUSED(childType), ImoId UNUSED(childId))
 

Member Enumeration Documentation

◆ EObservedChild

This enum describes the valid observable targets.

Enumerator
k_root 

The whole Document.

k_control 

A control (an ImoControl) object.

k_imo 

A child of the Document (an ImoObj) except ImoControl objs.

Constructor & Destructor Documentation

◆ ~Observable()

virtual Observable::~Observable ( )
inlinevirtual

Destructor.

Member Function Documentation

◆ add_event_handler() [1/6]

virtual void Observable::add_event_handler ( int  eventType,
EventHandler pHandler 
)
virtual

Register a notification handler (EventHandler object) for all events generated by this Observable object.

Parameters
eventTypeThe type of event to be notified. It must be a value from enmu EEventType.
pHandlerThe object, derived from EventHandler, that will receive the notifications (by invoking its EventHandler::handle_event() method.

◆ add_event_handler() [2/6]

virtual void Observable::add_event_handler ( int  eventType,
void *  pThis,
void(*)(void *pObj, SpEventInfo event)  pt2Func 
)
virtual

Register a notification handler (c++ method) for all events generated by this Observable object.

Parameters
eventTypeThe type of event to be notified. It must be a value from enmu EEventType.
pThisPointer to the object that will receive the notifications.
pt2FuncThe method in previous object that will be invoked to notify events.

See Events and how to handle them

◆ add_event_handler() [3/6]

virtual void Observable::add_event_handler ( int  eventType,
void(*)(SpEventInfo event)  pt2Func 
)
virtual

Register a notification handler (c function) for all events generated by this Observable object.

Parameters
eventTypeThe type of event to be notified. It must be a value from enmu EEventType.
pt2FuncThe function that will be invoked to notify events.

See Events and how to handle them

◆ add_event_handler() [4/6]

void Observable::add_event_handler ( int  childType,
ImoId  childId,
int  eventType,
EventHandler pHandler 
)

Register an event handler (EventHandler object) for some events generated by children of this Observable object. Parameters childType and childId allows to filter the desired events.

Parameters
childTypeIt must be value k_control or k_imo from enum EObservedChild, and selects the source of the events to be notified.
childIdIt is the ID of the ImoObj to observe.
eventTypeThe type of event to be notified. It must be a value from enmu EEventType.
pHandlerThe object, derived from EventHandler, that will receive the notifications (by invoking its EventHandler::handle_event() method.

◆ add_event_handler() [5/6]

void Observable::add_event_handler ( int  childType,
ImoId  childId,
int  eventType,
void *  pThis,
void(*)(void *pObj, SpEventInfo event)  pt2Func 
)

Register an event handler (c++ method) for some events generated by children of this Observable object. Parameters childType and childId allows to filter the desired events.

Parameters
childTypeIt must be value k_control or k_imo from enum EObservedChild, and selects the source of the events to be notified.
childIdIt is the ID of the ImoObj to observe.
eventTypeThe type of event to be notified. It must be a value from enmu EEventType.
pThisPointer to the object that will be notified.
pt2FuncThe method in previous object that will be invoked to notify events.

See Events and how to handle them

◆ add_event_handler() [6/6]

void Observable::add_event_handler ( int  childType,
ImoId  childId,
int  eventType,
void(*)(SpEventInfo event)  pt2Func 
)

Register an event handler (c function) for some events generated by children of this Observable object. Parameters childType and childId allows to filter the desired events.

Parameters
childTypeIt must be value k_control or k_imo from enum EObservedChild, and selects the source of the events to be notified.
childIdIt is the ID of the ImoObj to observe.
eventTypeThe type of event to be notified. It must be a value from enmu EEventType.
pt2FuncThe method in previous object that will be invoked to notify events.

◆ get_event_notifier()

virtual EventNotifier* Observable::get_event_notifier ( )
pure virtual

Returns the EventNotifier object associated to this Observable object.

◆ get_observable_child()

virtual Observable* Observable::get_observable_child ( int   UNUSEDchildType,
ImoId   UNUSEDchildId 
)
inlinevirtual

Returns a pointer to the observable child. */.