SHAPER  9.12.0
Events_Loop Class Reference

Base class that manages the receiving and sending of all not Qt-events in the application. More...

Public Member Functions

EVENTS_EXPORT void send (const std::shared_ptr< Events_Message > &theMessage, bool isGroup=true)
 Allows to send an event. More...
 
EVENTS_EXPORT void registerListener (Events_Listener *theListener, const Events_ID theID, void *theSender=0, bool theImmediate=false)
 Registers (or adds if such listener is already registered) a listener that will be called on the event and from the defined sender. More...
 
EVENTS_EXPORT void removeListener (Events_Listener *theListener)
 Remove the listener from internal maps if it was registered there. More...
 
EVENTS_EXPORT void flush (const Events_ID &theID)
 Initializes sending of a group-message by the given ID. More...
 
EVENTS_EXPORT void eraseMessages (const Events_ID &theID)
 Removes messages with the given ID: they are not needed anymore (UPDATE on close) More...
 
EVENTS_EXPORT bool activateFlushes (const bool theActivate)
 Allows to disable flushes: needed in synchronization of document mechanism (to synchronize all and only then flush create, update, etc in correct order) More...
 
EVENTS_EXPORT void clear (const Events_ID &theID)
 Clears all collected messages. More...
 
EVENTS_EXPORT bool isFlushed (const Events_ID &theID)
 Returns true if the evement is flushed right now. More...
 
EVENTS_EXPORT void setFlushed (const Events_ID &theID, const bool theValue)
 Sets the flag that the event is flished right now. More...
 
EVENTS_EXPORT bool hasGrouppedEvent (const Events_ID &theID)
 Returns true if a loop accumulated events to be flashed. More...
 

Static Public Member Functions

static EVENTS_EXPORT Events_Looploop ()
 ! Returns the main object of the loop, one per application. More...
 
static EVENTS_EXPORT Events_ID eventByName (const char *theName)
 Returns the unique event by the given name. More...
 

Detailed Description

Base class that manages the receiving and sending of all not Qt-events in the application.

One per application, initialized on start. Listeners must register in this loop to get events, called by senders. Sending of events is very fast (just adding to container). Performing of events is processed in separated thread, so, sender takes control back immideately.

Member Function Documentation

◆ loop()

Events_Loop * Events_Loop::loop ( )
static

! Returns the main object of the loop, one per application.

◆ eventByName()

Events_ID Events_Loop::eventByName ( const char *  theName)
static

Returns the unique event by the given name.

Call this method only on initialization of object to speedup the events processing without parsing of the string.

! All events created in this session, uniquely identified by the text and char pointer

◆ send()

void Events_Loop::send ( const std::shared_ptr< Events_Message > &  theMessage,
bool  isGroup = true 
)

Allows to send an event.

Parameters
theMessagethe enevt message to send
isGroupis true for grouping messages if possible

◆ registerListener()

void Events_Loop::registerListener ( Events_Listener theListener,
const Events_ID  theID,
void *  theSender = 0,
bool  theImmediate = false 
)

Registers (or adds if such listener is already registered) a listener that will be called on the event and from the defined sender.

Parameters
theListenerthe object that will listen (process) the event
theIDlisten for messages with this ID
theSenderlisten only for this sender (NULL - listen everybody)
theImmediatefor listeners who can not wait (no groupping mechanism is used for it)

◆ removeListener()

void Events_Loop::removeListener ( Events_Listener theListener)

Remove the listener from internal maps if it was registered there.

Parameters
theListenera listener

◆ flush()

void Events_Loop::flush ( const Events_ID theID)

Initializes sending of a group-message by the given ID.

◆ eraseMessages()

void Events_Loop::eraseMessages ( const Events_ID theID)

Removes messages with the given ID: they are not needed anymore (UPDATE on close)

◆ activateFlushes()

bool Events_Loop::activateFlushes ( const bool  theActivate)

Allows to disable flushes: needed in synchronization of document mechanism (to synchronize all and only then flush create, update, etc in correct order)

Parameters
theActivatea state about flushe is active. If false, the flush is disabled
Returns
the previous active flush state

◆ clear()

void Events_Loop::clear ( const Events_ID theID)

Clears all collected messages.

◆ isFlushed()

bool Events_Loop::isFlushed ( const Events_ID theID)

Returns true if the evement is flushed right now.

◆ setFlushed()

void Events_Loop::setFlushed ( const Events_ID theID,
const bool  theValue 
)

Sets the flag that the event is flished right now.

◆ hasGrouppedEvent()

bool Events_Loop::hasGrouppedEvent ( const Events_ID theID)

Returns true if a loop accumulated events to be flashed.