indexing
	description: "Fixed array for WEL_STRUCTURE. Used internally by WEL."
	status: "See notice at end of class."
	date: "$Date$"
	revision: "$Revision$"

class interface
	WEL_ARRAY [G -> WEL_STRUCTURE]

create 

	make (a_count, an_item_size: INTEGER)
			-- Create a fixed array.
			-- a_count specifies the number of items and
			-- an_item_size specifies the item_size of an item.
		require
			positive_count: a_count >= 0
			positive_item_size: an_item_size >= 0
		ensure
			count_set: count = a_count
			item_size_set: item_size = an_item_size

feature -- Access

	item: POINTER
			-- Generic Windows handle or structure pointer.
			-- Can be a HWND, HICON, RECT *, WNDCLASS *, etc...
			-- (from WEL_ANY)
	
feature -- Measurement

	count: INTEGER
			-- Number of items in the array

	item_size: INTEGER
			-- Size of an item (in bytes)

	structure_size: INTEGER
			-- Size of the array (in bytes)
		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 -- Element change

	i_th_item (index: INTEGER): POINTER
			-- Retrieve the pointer at the zero-based index.
		require
			index_large_enough: index >= 0
			index_small_enpugh: index < count

	put (an_item: G; index: INTEGER)
			-- Put an_item at zero based index index.
		require
			an_item_not_void: an_item /= void
			valid_item_size: item_size = an_item.structure_size
			index_large_enough: index >= 0
			index_small_enough: index < count

	set_item (an_item: POINTER)
			-- Set item with an_item
			-- (from WEL_ANY)
		ensure -- from WEL_ANY
			item_set: item = an_item
	
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

	to_integer: INTEGER
			-- Converts item to an integer.
			-- (from WEL_ANY)
		ensure -- from WEL_ANY
			Result = cwel_pointer_to_integer (item)
	
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
	
invariant

	positive_count: count >= 0
	positive_item_size: item_size >= 0
		-- from ANY
	reflexive_equality: standard_is_equal (Current)
	reflexive_conformance: conforms_to (Current)

end -- class WEL_ARRAY