english
version "1.0"
identify "wxyz"

#: Copyright (c) 1995, 1996, 2002 by Wayne C. Gramlich.
#, All rights reserved.
#,
#, Permission to use, copy, modify, distribute, and sell this software
#, for any purpose is hereby granted without fee provided that the above
#, copyright notice and this permission are retained.  The author makes
#, no representations about the suitability of this software for any purpose.
#, It is provided "as is" without express or implied warranty.

module delta

#: This module implements the delta object for SVMS.

define delta				#: A history file in memory
    record
	ancestor delta			#: Ancestor delta (or ?? if first)
	history history			#: Parent {history} object
	merge delta			#: Merge delta (or ?? if none)
	number unsigned			#: Delta number (never changes w/merge)
	offset unsigned			#: Offset number (changes w/merge)
	project_name project_name	#: {project_name} name for {delta}
	resources resources		#: {resources} {delta} allocated from
	symbolic_link string		#: Sym. link value (if {type} = {link})
	timestamp unsigned		#: Time delta showed up in project
	type delta_type			#: Delta type
	user_name string		#: User name
	version version			#: {version} obj. (if {type} = {file})
    generate address_get, allocate, erase, identical, print

define delta_type			#: Delta type
    enumeration
	deleted				#: Deleted file
	directory			#: Directory
	file				#: File
	link				#: Symbolic link
    generate equal, print



#: {delta} procedures:

procedure xallocate@delta
    takes
	history history
	type delta_type
	project_name project_name
	timestamp unsigned
	user_name string
    returns delta

    #: This procedure will allocate and return a new {delta} object
    #, from {history} with a type of {type}, a project of {project},
    #, a timestamp of {timestamp}, and a user name of {user_name}.


    #: Carefully reinitialize {delta}:

procedure compare@delta
    takes
	delta1 delta
	delta2 delta
    returns integer

    #: This procedure will return -1, 0, 1 depending upon whether {delta1}
    #, less than, equal to, or greater than {delta2}.


procedure deallocate@delta
    takes
	delta delta
    returns_nothing

    #: This procedure will deallocate {delta} and make it available for
    #, subsequent reallocation:


procedure deleted_allocate@delta
    takes
	history history
	project_name project_name
	timestamp unsigned
	user_name string
    returns delta

    #: This procedure will create and append a new directory {delta}
    #, object for {history} with a project name of {project_name}, a timestamp
    #, of {timestamp}, and a user name of {user_name}.


procedure delta_allocate@delta
    takes
	version version
	project_name project_name
	timestamp unsigned
	user_name string
	ancestor delta
	merge delta
    returns delta

    #: This procedure will allocate and return a new {delta} object for
    #, {version} with a project name of {project_name}, a timestamp of
    #, {timestamp}, a number of {number}, and a user name of {user_name}.


procedure directory_allocate@delta
    takes
	history history
	project_name project_name
	timestamp unsigned
	user_name string
    returns delta

    #: This procedure will create and return a new {delta} object for
    #, {history} with a project name of {project_name}, a timestamp of
    #, {timestamp}, and a user name of {user_name}.


procedure read@delta
    takes
	data_in_stream data_in_stream
	history history
    returns delta

    #: This procedure will read in a {delta} object from {data_in_stream}
    #, and return it.


procedure string_append@delta
    takes
	delta delta
	text string
    returns_nothing

    #: This procedure will append the contents of {delta} to the end
    #, of {delta}.


procedure write@delta
    takes
	delta delta
	data_out_stream data_out_stream
    returns_nothing

    #: This procedure will write {delta} out to {data_out_stream}.