Why there is code of "_Emitters"?(solved)

Added by sambsp over 4 years ago

In event_server.cpp, there are codes:

void CEventServer::pump(bool allWindows)
{
    // Avoid recurse (can arise if the process of an event decide to pump the server again....)
    nlassert(!_Pumping);
    _Pumping= true;

    // **** submit emitters events
    std::list<IEventEmitter*>::iterator item = _Emitters.begin();

    // getting events from emitters
     while(item!=_Emitters.end())
    {
        // ask emitters to submit their events to server
        (*item)->submitEvents(*this, allWindows);
        item++;
    }

    // **** process to listeners
    std::list<CEvent*>::iterator itev = _Events.begin();
    while(itev!=_Events.end())
    {
        // pump event
        bool bDelete=pumpEvent(*itev);
        if (bDelete)
            delete *itev;
        itev=_Events.erase (itev);
    }

    // end of pumping
    _Pumping= false;
}

I cannot understand why every event should be tackled by "_Emitters" first, because I thought event server process those events. To simplify the answer, an example like "if there isn't this _Emitter, then ..." to explain this will be great appreciated.


Replies (3)

RE: Why there is code of "_Emitters"? - Added by sfb over 4 years ago

sambsp,

You're looking at emitters backwards. Emitters are emitting events, hence the name. The list of emitters is a list of objects which are emitting objects into NeL for consumption by NeL event listener. An emitter represents a class that converts from some native event system (e.g. Windows, X11, Qt) into NeL.

HTH.

Thanks,
sfb
/s

RE: Why there is code of "_Emitters"? - Added by kervala over 4 years ago

Emitters are all classes implementing IEventEmitter interface :

  • CDIEventEmitter : code\nel\include\nel\misc\di_event_emitter.h
  • CWinEventEmitter : code\nel\include\nel\misc\win_event_emitter.h
  • CUnixEventEmitter : code\nel\src\3d\driver\opengl\unix_event_emitter.h
  • CCocoaEventEmitter : code\nel\src\3d\driver\opengl\mac\cocoa_event_emitter.h

RE: Why there is code of "_Emitters"? - Added by sambsp over 4 years ago

Understood, thanks.

(1-3/3)