1. -- 
  2. -- Copyright (c) 2012 Kevin Wellwood 
  3. -- All rights reserved. 
  4. -- 
  5. -- This source code is distributed under the Modified BSD License. For terms and 
  6. -- conditions, see license.txt. 
  7. -- 
  8.  
  9. with Events.Corrals;                    use Events.Corrals; 
  10.  
  11. package Events.Manager is 
  12.  
  13.     -- Adds an event to the queue. 
  14.     procedure Queue_Event( evt : in out A_Event ); 
  15.     pragma Precondition( evt /= null ); 
  16.     pragma Postcondition( evt = null ); 
  17.  
  18.     -- Registers a corral as a listener for a specific type of event. Corrals 
  19.     -- only receive events for which they are registered. 
  20.     procedure Register_Listener( corral : not null A_Corral; evtName : String ); 
  21.     pragma Precondition( evtName'Length > 0 ); 
  22.  
  23.     -- Dispatches queued events, waiting for more if the queue is empty. The 
  24.     -- calling thread will not return from this procedure until Stop is invoked. 
  25.     procedure Run; 
  26.  
  27.     -- Shuts down the event manager and causes the thread in Run to return, if 
  28.     -- the event manager is currently running. Any further calls to Queue_Event 
  29.     -- or Trigger event will consume the event objects but do nothing. 
  30.     procedure Stop; 
  31.  
  32.     -- Synchronously dispatches an event to its listeners until one of the 
  33.     -- listeners consumes the event. The listener's response is ignored. 
  34.     procedure Trigger_Event( evt : in out A_Event ); 
  35.     pragma Precondition( evt /= null ); 
  36.     pragma Postcondition( evt = null ); 
  37.  
  38.     -- Synchronously dispatches an event to its listeners until one of the 
  39.     -- listeners consumes the event. 
  40.     procedure Trigger_Event( evt : in out A_Event; response : out Response_Type ); 
  41.     pragma Precondition( evt /= null ); 
  42.     pragma Postcondition( evt = null ); 
  43.  
  44.     -- Unregisters a corral as a listener for a specific type of event. If the 
  45.     -- corral was not previously registered, this has no effect. 
  46.     procedure Unregister_Listener( corral : not null A_Corral; evtName : String ); 
  47.     pragma Precondition( evtName'Length > 0 ); 
  48.  
  49. end Events.Manager;