indexing
	description: "COM Decimal Structure.  Wrapping COM DECIMAL type"
	status: "See notice at end of class"
	date: "$Date$"
	revision: "$Revision$"

class interface
	ECOM_DECIMAL

create 

	make

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

	make_from_double (dbl_value: DOUBLE)
			-- Create with value 'dbl_value'

feature -- Access

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

	one: ECOM_DECIMAL
			-- Neutral element for * operation
		ensure -- from NUMERIC
			result_exists: Result /= void

	scale: INTEGER
			-- Scale of value.  e.g. 123.45 has a scale of 2
		require
			non_void_item: item /= void
			valid_item: item /= default_pointer

	zero: ECOM_DECIMAL
			-- Neutral element for + operation
		ensure -- from NUMERIC
			result_exists: Result /= void
	
feature -- Measurement

	structure_size: INTEGER
			-- Size of DECIMAL (DECIMAL) 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

	absolute: ECOM_DECIMAL
			-- Absolute value of decimal
		require
			non_void_item: item /= void
			valid_item: item /= default_pointer
		ensure
			non_void_result: Result /= void

	ceiled_integer_portion: ECOM_DECIMAL
			-- Integer portion of decimal value.
			-- The first negative integer >= to the value is returned if the value is negative.
		require
			non_void_item: item /= void
			valid_item: item /= default_pointer
		ensure
			non_void_result: Result /= void

	rounded (value: INTEGER): ECOM_DECIMAL
			-- Round value with value decimal places
		require
			valid_value: value >= 0
			non_void_item: item /= void
			valid_item: item /= default_pointer
		ensure
			non_void_result: Result /= void

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

	truncated_to_double: DOUBLE
			-- Double value

	truncated_to_integer_portion: ECOM_DECIMAL
			-- Integer portion of a decimal value. The first negative integer
			-- <= to the value is returned if the value is negative.
		require
			non_void_item: item /= void
			valid_item: item /= default_pointer
		ensure
			valid_result: 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

	infix "*" (other: ECOM_DECIMAL): ECOM_DECIMAL
			-- Multiply by other
		require -- from NUMERIC
			other_exists: other /= void
		require else
			non_void_item: item /= void
			valid_item: item /= default_pointer
		ensure -- from NUMERIC
			result_exists: Result /= void

	prefix "+": ECOM_DECIMAL
			-- Unary plus
		require -- from  NUMERIC
			True
		require else
			non_void_item: item /= void
			valid_item: item /= default_pointer
		ensure -- from NUMERIC
			result_exists: Result /= void

	infix "+" (other: ECOM_DECIMAL): ECOM_DECIMAL
			-- Add with other
		require -- from NUMERIC
			other_exists: other /= void
		require else
			non_void_item: item /= void
			valid_item: item /= default_pointer
		ensure -- from NUMERIC
			result_exists: Result /= void
			commutative: equal (Result, other + Current)

	infix "-" (other: ECOM_DECIMAL): ECOM_DECIMAL
			-- Subtract with other
		require -- from NUMERIC
			other_exists: other /= void
		require else
			non_void_item: item /= void
			valid_item: item /= default_pointer
		ensure -- from NUMERIC
			result_exists: Result /= void

	prefix "-": ECOM_DECIMAL
			-- Negative value of decimal
		require -- from  NUMERIC
			True
		require else
			non_void_item: item /= void
			valid_item: item /= default_pointer
		ensure -- from NUMERIC
			result_exists: Result /= void

	infix "/" (other: ECOM_DECIMAL): ECOM_DECIMAL
			-- Multiply by other
		require -- from NUMERIC
			other_exists: other /= void
			good_divisor: divisible (other)
		require else
			non_void_item: item /= void
			valid_item: item /= default_pointer
		ensure -- from NUMERIC
			result_exists: Result /= void

	infix "^" (other: NUMERIC): NUMERIC
			-- Current objects to the power 'other'
		require else
			non_void_item: item /= void
			valid_item: item /= default_pointer
	
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 -- Initialiazation

	make

	make_from_double (dbl_value: DOUBLE)
			-- Create with value 'dbl_value'
	
feature -- status report

	divisible (other: ECOM_DECIMAL): BOOLEAN
			-- Is divisible by other?
		require -- from NUMERIC
			other_exists: other /= void

	exponentiable (other: ECOM_DECIMAL): BOOLEAN
			-- Is exponentiable by other?
		require -- from NUMERIC
			other_exists: other /= void

	is_equal (other: like Current): BOOLEAN
			-- Is 'other' equal to Current object?
			-- Not implemented yet.
		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_DECIMAL