crystalspace.jbind.impl.csutil.eventq
Class csEventQueue

java.lang.Object
  extended bycrystalspace.jbind.impl.csNativeObject
      extended bycrystalspace.jbind.impl.csutil.scf.csBase
          extended bycrystalspace.jbind.impl.csutil.eventq.csEventQueue
All Implemented Interfaces:
iBase, iEventQueue, iPointer

public class csEventQueue
extends csBase
implements iEventQueue

Author:
qan To change the template for this generated type comment go to Window>Preferences>Java>Code Generation>Code and Comments

Field Summary
 
Fields inherited from class crystalspace.jbind.impl.csNativeObject
ImplFactory, nPointer
 
Constructor Summary
csEventQueue(iPointer nPointer)
           
 
Method Summary
 void changeListenerTrigger(iEventHandler handler, int trigger)
          Change a listener's trigger.
 void clear()
          Clear event queue.
 iEvent createEvent(byte type)
          Create an event, from the pool if there are any free events available.
 iEventOutlet createEventOutlet(iEventPlug plug)
          Register an event plug and return a new outlet.
 void dispatch(iEvent event)
          Dispatch a single event from the queue.
 iEvent get()
          Get next event from queue; returns a null reference if no events are present.
 iEventCord getEventCord(int Category, int Subcategory)
          Get the event cord for a given category and subcategory.
 iEventOutlet getEventOutlet()
          Get a public event outlet for posting just an event.
static java.lang.Class getInterfaceClass()
           
static java.lang.String getInterfaceName()
           
static int getInterfaceVersion()
           
 java.lang.String getName()
          Return the name of the interface
 int getVersion()
          Return the version of the interface
static void initSCF()
           
 boolean isEmpty()
          Query if queue is empty.
protected  boolean isNativePointerValidSafe()
           
 void post(iEvent event)
          Place an event into queue.
 void process()
          Process the event queue.
 void registerListener(iEventHandler handler, int trigger)
          Register a listener for specific events.
 void removeAllListeners()
          Unregister all listeners.
 void removeListener(iEventHandler handler)
          Unregister a listener.
 
Methods inherited from class crystalspace.jbind.impl.csutil.scf.csBase
decRef, equals, finalize, getRefCount, incRef, nDelete, queryInterface, queryInterfaceSafe
 
Methods inherited from class crystalspace.jbind.impl.csNativeObject
changePointer, getPointer, getPointer, getPointerArray, hashCode, isMemoryOwner, isNativePointerValid, isNativePointerValidSafe, newNativeObject, setMemoryOwner, toString
 
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface crystalspace.jbind.interfaces.iutil.scf.iBase
decRef, getRefCount, incRef, queryInterface, queryInterfaceSafe
 
Methods inherited from interface crystalspace.jbind.interfaces.iPointer
changePointer, getPointer, isMemoryOwner, setMemoryOwner
 

Constructor Detail

csEventQueue

public csEventQueue(iPointer nPointer)
Parameters:
nPointer -
Method Detail

getVersion

public int getVersion()
Description copied from interface: iBase
Return the version of the interface

Specified by:
getVersion in interface iBase
Specified by:
getVersion in class csBase

getName

public java.lang.String getName()
Description copied from interface: iBase
Return the name of the interface

Specified by:
getName in interface iBase
Specified by:
getName in class csBase

initSCF

public static void initSCF()

getEventOutlet

public iEventOutlet getEventOutlet()
Description copied from interface: iEventQueue
Get a public event outlet for posting just an event. In general most modules should create their own private outlet via CreateEventOutlet(); and register as a normal event plug. However, there are cases when you just need to post one event from time to time; in these cases it is easier to post it without the bulk of creating a new iEventPlug interface. In these cases, you can post the event by obtaining the shared event outlet from GetEventOutlet();, and use it to post an event instead. Implemented in csEventQueue.

Specified by:
getEventOutlet in interface iEventQueue
Returns:

getInterfaceVersion

public static int getInterfaceVersion()

getInterfaceName

public static java.lang.String getInterfaceName()

getInterfaceClass

public static java.lang.Class getInterfaceClass()

isNativePointerValidSafe

protected boolean isNativePointerValidSafe()

changeListenerTrigger

public void changeListenerTrigger(iEventHandler handler,
                                  int trigger)
Description copied from interface: iEventQueue
Change a listener's trigger. See RegisterListener(); for a discussion of the trigger. Implemented in csEventQueue.

Specified by:
changeListenerTrigger in interface iEventQueue
Parameters:
handler -
trigger -
See Also:
iEventQueue.changeListenerTrigger(crystalspace.jbind.interfaces.iutil.event.iEventHandler, int)

clear

public void clear()
Description copied from interface: iEventQueue
Clear event queue. Implemented in csEventQueue.

Specified by:
clear in interface iEventQueue
See Also:
iEventQueue.clear()

createEvent

public iEvent createEvent(byte type)
Description copied from interface: iEventQueue
Create an event, from the pool if there are any free events available. Else create a new event in the pool and use it. Implemented in csEventQueue.

Specified by:
createEvent in interface iEventQueue
Parameters:
type -
Returns:
See Also:
iEventQueue.createEvent(byte)

createEventOutlet

public iEventOutlet createEventOutlet(iEventPlug plug)
Description copied from interface: iEventQueue
Register an event plug and return a new outlet. Any module which generates events should consider using this interface for posting those events to the queue. The module should implement the iEventPlug interface and register that interface with this method. In return, an iEventOutlet object will be created which can be used to actually post events to the queue. It is the caller's responsibility to send a DecRef(); message to the returned event outlet when it is no longer needed. Implemented in csEventQueue.

Specified by:
createEventOutlet in interface iEventQueue
Parameters:
plug -
Returns:
See Also:
iEventQueue.createEventOutlet(crystalspace.jbind.interfaces.iutil.event.iEventPlug)

dispatch

public void dispatch(iEvent event)
Description copied from interface: iEventQueue
Dispatch a single event from the queue. This is normally called by Process(); once for each event in the queue. Events are dispatched to the appropriate listeners (implementors of iEventHandler); which have been registered via RegisterListener();. Implemented in csEventQueue.

Specified by:
dispatch in interface iEventQueue
Parameters:
event -
See Also:
iEventQueue.dispatch(crystalspace.jbind.interfaces.iutil.event.iEvent)

get

public iEvent get()
Description copied from interface: iEventQueue
Get next event from queue; returns a null reference if no events are present. There is rarely any need to manually retrieve events from the queue. Instead, normal event processing via Process(); takes care of this responsibility. iEventQueue gives up ownership of the returned iEvent. Implemented in csEventQueue.

Specified by:
get in interface iEventQueue
Returns:
See Also:
iEventQueue.get()

getEventCord

public iEventCord getEventCord(int Category,
                               int Subcategory)
Description copied from interface: iEventQueue
Get the event cord for a given category and subcategory. This allows events to be delivered immediately, bypassing the normal event queue, to a chain of plugins that register with the implementation of iEventCord returned by this function. The category and subcategory are matched against the category and subcategory of each actual iEvent. Implemented in csEventQueue.

Specified by:
getEventCord in interface iEventQueue
Parameters:
Category -
Subcategory -
Returns:
See Also:
iEventQueue.getEventCord(int, int)

isEmpty

public boolean isEmpty()
Description copied from interface: iEventQueue
Query if queue is empty. Implemented in csEventQueue.

Specified by:
isEmpty in interface iEventQueue
Returns:
See Also:
iEventQueue.isEmpty()

post

public void post(iEvent event)
Description copied from interface: iEventQueue
Place an event into queue. In general, clients should post events to the queue via an iEventOutlet rather than directly via Post();, however there may be certain circumanstances where posting directly to the queue is preferred. Remarks: Post(); takes ownership of the event. That means that you MUST NOT DecRef(); the event after passing it to Post();. Instead, if you want to keep it, IncRef(); it. Implemented in csEventQueue.

Specified by:
post in interface iEventQueue
Parameters:
event -
See Also:
iEventQueue.post(crystalspace.jbind.interfaces.iutil.event.iEvent)

process

public void process()
Description copied from interface: iEventQueue
Process the event queue. Calls Dispatch(); once for each event in the queue in order to actually dispatch the event. Typically, this method is invoked by the host application on a periodic basis (often from the host's own event loop); in order to give Crystal Space modules a chance to run and respond to events. Implemented in csEventQueue.

Specified by:
process in interface iEventQueue
See Also:
iEventQueue.process()

registerListener

public void registerListener(iEventHandler handler,
                             int trigger)
Description copied from interface: iEventQueue
Register a listener for specific events. If the listener is already registered, then this method merely changes the listener's `trigger'. The `trigger' argument is a combination of the CSMASK_XXX event triggers defined in iutil/evdefs.h. Multiple triggers may be specified by combining them with the bitwise "or" operator (`|');. The CSMASK_Nothing event trigger is special. If registered with this trigger, the listener will be called in just before Process(); iterates over the event queue, and then it will be called with 3 different csevBroadcast events after has been dispatched the last event. In this case, the listener will be sent an csevBroadcast event with the Event.Command.Code equal to cscmdPreProcess before events dispatching, and after events dispatching the listener will receive three csevBroadcast events, in 3 successive phases, following this ordering: the first broadcasted event has the Event.Command.Code equal to cscmdProcess, then the second broadcasted event has a value of cscmdPostProcess and finally the last event broadcasted has the cscmdFinalProcess value . Implemented in csEventQueue.

Specified by:
registerListener in interface iEventQueue
Parameters:
handler -
trigger -
See Also:
iEventQueue.registerListener(crystalspace.jbind.interfaces.iutil.event.iEventHandler, int)

removeAllListeners

public void removeAllListeners()
Description copied from interface: iEventQueue
Unregister all listeners. Remarks: This function is used to clear all listeners from the event queue stack. You should only call this function at the end of your program after the event queue processing has terminated. If you make use of csInitializer::DestroyApplication();, this is done for you by that call. Implemented in csEventQueue.

Specified by:
removeAllListeners in interface iEventQueue
See Also:
iEventQueue.removeAllListeners()

removeListener

public void removeListener(iEventHandler handler)
Description copied from interface: iEventQueue
Unregister a listener. It is important to call RemoveListener(); before deleting your event handler! Implemented in csEventQueue.

Specified by:
removeListener in interface iEventQueue
Parameters:
handler -
See Also:
iEventQueue.removeListener(crystalspace.jbind.interfaces.iutil.event.iEventHandler)