with Ada.Real_Time; use Ada.Real_Time;
with Ada.Streams; use Ada.Streams;
package Support.Real_Time is
type Timer_Type is limited private;
function Elapsed( t : Timer_Type ) return Time_Span;
function Is_Running( t : Timer_Type ) return Boolean;
procedure Pause( t : in out Timer_Type );
procedure Restart( t : in out Timer_Type );
procedure Start( t : in out Timer_Type );
type Frame_Timer is limited private;
function Is_Updated( t : Frame_Timer ) return Boolean;
function Rate( t : access Frame_Timer ) return Natural;
procedure Rate( t : in out Frame_Timer; fps : out Natural );
procedure Set_Update_Delay( t : in out Frame_Timer; ts : Time_Span );
procedure Tick( t : in out Frame_Timer );
function Format( ts : Time_Span ) return String;
pragma Postcondition( Format'Result'Length > 0 );
function To_Float( ts : Time_Span ) return Long_Float;
function To_Microseconds( ts : Time_Span ) return Natural;
function To_Milliseconds( ts : Time_Span ) return Natural;
function To_Minutes( ts : Time_Span ) return Natural;
function To_Seconds( ts : Time_Span ) return Natural;
function To_String( t : Time ) return String;
function To_String( ts : Time_Span; precision : Natural := 3 ) return String;
pragma Postcondition( To_String'Result'Length > 0 );
function Time_Input( stream : access Root_Stream_Type'Class ) return Time;
procedure Time_Output( stream : access Root_Stream_Type'Class; t : Time );
private
type Timer_Type is limited
record
started : Time := Time_First;
paused : Time := Time_First;
running : Boolean := False;
end record;
type Frame_Timer is limited
record
ticks : Natural := 0;
updateDelay : Time_Span := Seconds( 1 );
lastUpdate : Time := Clock;
updated : Boolean := True;
fps : Natural := 0;
end record;
end Support.Real_Time;