indexing
	description: "COM GUID structure"
	status: "See notice at end of class"
	date: "$Date$"
	revision: "$Revision$"

class interface
	ECOM_GUID

create 

	make
			-- Allocate item
			-- (from ECOM_STRUCTURE)
		ensure -- from WEL_STRUCTURE
			not_shared: not shared

	make_from_pointer (a_pointer: POINTER)
			-- Make from pointer.
		require -- from ECOM_STRUCTURE
			valid_pointer: a_pointer /= default_pointer

	make_from_string (string: STRING)
			-- Create GUID from string string.
		require
			non_void_string: string /= void
			valid_guid_string: guid_routines.is_valid_guid_string (string)
		ensure
			valid_item: item /= default_pointer

	make_from_guid (other: ECOM_GUID)
			-- Create new structure with same GUID as other.
		require
			valid_guid: other /= void and then other.item /= default_pointer
		ensure
			valid_item: item /= default_pointer

feature -- Access

	item: POINTER
			-- Generic Windows handle or structure pointer.
			-- Can be a HWND, HICON, RECT *, WNDCLASS *, etc...
			-- (from WEL_ANY)
	
feature -- Access
--	com_api: ECOM_COM is
--		once
--			create Result
--		end

	guid_routines: ECOM_GUID_ROUTINES
			-- (from ECOM_ROUTINES)
	
feature -- Measurement

	structure_size: INTEGER
			-- Size of GUID structure
		ensure -- from WEL_STRUCTURE
			positive_result: Result > 0
	
feature -- Status report

	exists: BOOLEAN
			-- Does the item exist?
			-- (from WEL_ANY)
		ensure -- from WEL_ANY
			Result = (item /= default_pointer)

	shared: BOOLEAN
			-- Is item shared by another object?
			-- If False (by default), item will
			-- be destroyed by destroy_item.
			-- If True, item will not be destroyed.
			-- (from WEL_ANY)
	
feature -- Status setting

	set_shared
			-- Set shared to True.
			-- (from WEL_ANY)
		ensure -- from WEL_ANY
			shared: shared

	set_unshared
			-- Set shared to False.
			-- (from WEL_ANY)
		ensure -- from WEL_ANY
			unshared: not shared
	
feature -- Removal

	dispose
			-- Destroy the inner structure of Current.
			--
			-- This function should be called by the GC when the
			-- object is collected or by the user if Current is
			-- no more usefull.
			-- (from WEL_ANY)
	
feature -- Conversion

	out: STRING
			-- String representation

	to_definition_string: STRING
			-- String representation needed for code generation.
		require
			valid_item: item /= default_pointer
		ensure
			non_void_representation: Result /= void

	to_integer: INTEGER
			-- Converts item to an integer.
			-- (from WEL_ANY)
		ensure -- from WEL_ANY
			Result = cwel_pointer_to_integer (item)

	to_string: STRING
			-- String representation
		require
			valid_item: item /= default_pointer
		ensure
			non_void_representation: Result /= void
	
feature -- Basic operations

	initialize
			-- Fill Current with zeros.
			-- (from WEL_STRUCTURE)
		require -- from WEL_STRUCTURE
			exists: exists

	initialize_with_character (a_character: CHARACTER)
			-- Fill current with a_character.
			-- (from WEL_STRUCTURE)
		require -- from WEL_STRUCTURE
			exists: exists

	memory_copy (source_pointer: POINTER; length: INTEGER)
			-- Copy length bytes from source_pointer to item.
			-- (from WEL_STRUCTURE)
		require -- from WEL_STRUCTURE
			length_small_enough: length <= structure_size
			length_large_enough: length > 0
			exists: exists
	
feature -- Basic Operations

	set_value (source: like Current)
			-- Set Current to 'source'.
			-- (from ECOM_STRUCTURE)
		require -- from ECOM_STRUCTURE
			non_void: source /= void
			valid_source: source.item /= default_pointer
	
feature -- Basic operation

	generate
			-- Generate a new GUID
	
feature -- Status Report

	is_equal (a_guid: ECOM_GUID): BOOLEAN
			-- Is a_guid equal to Current?
		require -- from ANY
			other_not_void: other /= void
		ensure -- from ANY
			symmetric: Result implies other.is_equal (Current)
			consistent: standard_is_equal (other) implies Result
	
invariant

		-- from ANY
	reflexive_equality: standard_is_equal (Current)
	reflexive_conformance: conforms_to (Current)

end -- class ECOM_GUID