with Ada.Streams; use Ada.Streams;
package Objects is
type Object is abstract tagged private;
type A_Object is access all Object'Class;
pragma No_Strict_Aliasing( A_Object );
-- Adjusts the object's fields as part of a Copy. If this class or an
-- ancestor class doesn't support copying then COPY_NOT_ALLOWED will be
-- raised. A subclass should call its superclass' Adjust before doing any
-- work.
procedure Adjust( this : access Object );
-- Constructs the object. A subclass should call its superclass' Adjust
-- before doing any work.
procedure Construct( this : access Object );
-- Deletes the object's fields as part of object destruction. A subclass
-- should call its superclass' Adjust before doing any work.
procedure Delete( this : in out Object );
-- Returns the name of the instance's class in lower case characters. This
-- is defined to be the class' external tag which is not guaranteed to be
-- unique across the entire application. If 'full' is True, the fully
-- qualified class name which includes a package prefix will be returned.
function Get_Class_Name( this : not null access Object'Class;
full : Boolean := False ) return String;
pragma Postcondition( Get_Class_Name'Result'Length > 0 );
-- Returns a string representation of the object.
function To_String( this : access Object ) return String;
procedure Object_Read( stream : access Root_Stream_Type'Class; obj : out Object );
procedure Object_Write( stream : access Root_Stream_Type'Class; obj : Object );
-- Returns a copy of an Object. Not all object classes can be copied. If the
-- given object is not allowed to be copied, COPY_NOT_ALLOWED will be
-- raised.
function Copy( src : A_Object ) return A_Object;
pragma Postcondition( Copy'Result /= src or else src = null );
-- Deletes an Object.
procedure Delete( this : in out A_Object );
pragma Postcondition( this = null );
-- Concatenates the string representation of the Object, as returned by the
-- To_String function.
function "&"( left : A_Object; right : String ) return String;
-- Concatenates the string representation of the Object, as returned by the
-- To_String function.
function "&"( left : String; right : A_Object ) return String;
----------------------------------------------------------------------------
-- Raised when attempting a copy on an Object class that doesn't support
-- copying.
COPY_NOT_ALLOWED : exception;
private
type Object is abstract tagged null record;
for Object'Read use Object_Read;
for Object'Write use Object_Write;
end Objects;