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 Ada.Real_Time;                     use Ada.Real_Time; 
  10.  
  11. package Processes is 
  12.  
  13.     -- 'totalTime' is the amount of time elapsed since the process began. 
  14.     -- 'elapsedTime' is the time elapsed since the previous tick or frame of 
  15.     -- execution. 
  16.     type Tick_Time is 
  17.         record 
  18.             total   : Time_Span; 
  19.             elapsed : Time_Span; 
  20.         end record; 
  21.  
  22.     ---------------------------------------------------------------------------- 
  23.  
  24.     -- A Process is attached to a Process_Manager to execute code periodically 
  25.     -- in time slices (also called a frame). Implementing the Process interface 
  26.     -- with any class and attaching an instance of it a process manager allows 
  27.     -- for any object to have its own behavior. 
  28.     type Process is limited interface; 
  29.     type A_Process is access all Process'Class; 
  30.  
  31.     -- Returns a name identifying the process. 
  32.     function Get_Process_Name( this : access Process ) return String is abstract; 
  33.  
  34.     -- Executes one frame (time slice) of the process logic. 'time' contains 
  35.     -- information including how much time has elapsed since the last call to 
  36.     -- Tick and how long the process has been attached to the process manager. 
  37.     -- 
  38.     -- Processes are intended to execute their behavior iteratively; to update 
  39.     -- their state based on the passage of time and perform longer actions in 
  40.     -- small increments. Tick should finish its work and return as quickly as 
  41.     -- possible, to allow all the other processes attached to the manager 
  42.     -- enough time to execute before the next scheduled tick. 
  43.     procedure Tick( this : access Process; time : Tick_Time ) is abstract; 
  44.  
  45. end Processes;