with Objects; use Objects;
with Statuses; use Statuses;
private with Ada.Containers;
private with Ada.Strings.Unbounded;
private with Ada.Real_Time;
package Events is
type Event_Id is private;
function "="( l, r : Event_Id ) return Boolean;
function To_Event_Id( evtName : String ) return Event_Id;
pragma Precondition( evtName'Length > 0 );
type Event_Type is private;
function "="( l, r : Event_Type ) return Boolean;
type Response_Type is private;
function Get_Message( response : Response_Type ) return String;
function Get_Status( response : Response_Type ) return Status;
procedure Set_Response( response : in out Response_Type;
stat : Status;
msg : String := "" );
No_Response : constant Response_Type;
type Event is abstract new Object with private;
type A_Event is access all Event'Class;
function Get_Name( this : not null access Event'Class ) return String;
pragma Postcondition( Get_Name'Result'Length > 0 );
function Get_Id( this : not null access Event'Class ) return Event_Id;
function Copy( src : A_Event ) return A_Event;
pragma Postcondition( Copy'Result /= src or else src = null );
procedure Delete( this : in out A_Event );
pragma Postcondition( this = null );
private
use Ada.Real_Time;
use Ada.Strings.Unbounded;
type Event_Id is new Ada.Containers.Hash_Type;
type Event_Type is
record
id : Event_Id := Event_Id'First;
name : Unbounded_String;
end record;
type Response_Type is
record
stat : Status := ST_NONE;
msg : Unbounded_String;
end record;
No_Response : constant Response_Type := Response_Type'(others => <>);
type Event is abstract new Object with
record
eType : Event_Type;
eTime : Time := Time_First;
end record;
procedure Construct( this : access Event; name : String );
pragma Precondition( name'Length > 0 );
function To_String( this : access Event ) return String;
end Events;