dims.sa
Generated by gen_html_sa_files from ICSI. Contact gomes@icsi.berkeley.edu for details
-------------------------> GNU Sather - sourcefile <-------------------------
-- Copyright (C) 2000 by K Hopper, University of Waikato, New Zealand --
-- This file is part of the GNU Sather library. It is free software; you may --
-- redistribute and/or modify it under the terms of the GNU Library General --
-- Public License (LGPL) as published by the Free Software Foundation; --
-- either version 2 of the license, or (at your option) any later version. --
-- This library is distributed in the hope that it will be useful, but --
-- WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See Doc/LGPL for more details. --
-- The license text is also available from: Free Software Foundation, Inc., --
-- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --
--------------> Please email comments to <bug-sather@gnu.org> <--------------
immutable class UNITS < $ENUMS{UNITS}, $IS_LT{UNITS}
immutable class UNITS < $ENUMS{UNITS}, $IS_LT{UNITS} is
-- This is an enumeration class which describes the different
-- units of measurement which may be used for import/export of data values.
-- Note that it provides an ordered domain.
-- The strings to be read into the Names array are expected to be
-- a culturally appropriate abbreviation like --
--
-- "", "pts", "mms", "cms", "ins", "ft", "yds", "m", "km", "mls"
-- Version 1.2 Aug 97. Copyright K Hopper, U of Waikato
-- Development History
-- -------------------
-- Date Who By Detail
-- ---- ------ ------
-- 11 Apr 96 kh Original
-- 10 Jan 97 kh Altered to conform to library portability.
-- 6 Aug 97 kh Incorporated factor routine.
include ENUM{UNITS} ;
private const val_count : CARD := 10 ;
-- The next routines provide the enumeration itself.
Other : SAME is return enum(1) end ;
-- This should be treated specially by using classes since the way in
-- which values of this kind may be converted into the other kinds of units
-- must be explicitly specified.
Points : SAME is return enum(2) end ;
Millimetres : SAME is return enum(3) end ;
Centimetres : SAME is return enum(4) end ;
Inches : SAME is return enum(5) end ;
Feet : SAME is return enum(6) end ;
Yards : SAME is return enum(7) end ;
Metres : SAME is return enum(8) end ;
Kilometres : SAME is return enum(9) end ;
Miles : SAME is return enum(10) end ;
private const convert : ARRAY{FLT} := | 1.0, 2.84527559, 10.0,
2.54, 12.0, 3.0,
1.093613298, 1000.0, 1.609344468,
1.0 | ;
-- The above table contains the multiplication table for the conversion
-- of one unit to another.
is_lt(
other : SAME
) : BOOL is
-- Returns true iff self is smaller than other!
return (self.enum < other.enum)
end ;
private steps!(
from,
to : SAME
) : FLT is
-- This iter is used to return successive values in the constant
-- conversion table.
this : CARD := from.card - 1 ; -- Arrays index from zero!
loop
if from = to then
yield 1.0 ;
quit
end ;
yield convert[this] ;
this := this + 1 ;
if this = to.card - 1 then
quit
end ;
end ;
end ;
factor(
kind : SAME
) : FLT
pre ~is_nil
and (self /= Other)
and ~kind.is_nil
post result > 0.0
is
-- This routine returns the multiplication factor required to multiply
-- an object dimensioned in self units to become a value in kind units.
factor : FLT := 1.0 ;
if kind > self then -- Increasing unit
loop
factor := steps!(self,kind) * factor ;
end ;
factor := 1.0 / factor -- reducing value!
else
loop
factor := steps!(kind,self) * factor ;
end
end ;
return factor
end ;
end ; -- UNITS
immutable class ASPECTS < $ENUMS{ASPECTS}
immutable class ASPECTS < $ENUMS{ASPECTS} is
-- This is an enumeration class which describes the different
-- aspects of a printed/displayed document page.
-- The strings to be read into the Names array are expected to be
-- culturally appropriate words like --
--
-- "Portrait", "Landscape"
-- Version 1.1 Jan 97. Copyright K Hopper, U of Waikato
-- Development History
-- -------------------
-- Date Who By Detail
-- ---- ------ ------
-- 10 Apr 96 kh Original
-- 10 Jan 97 kh Altered to conform to library portability.
include ENUM{ASPECTS} ;
private const val_count : CARD := 2 ;
-- The next routines provide the enumeration itself.
Portrait : SAME is return enum(1) end ;
Landscape : SAME is return enum(2) end ;
end ; -- ASPECTS
immutable class DIRECTIONS < $ENUMS{DIRECTIONS}
immutable class DIRECTIONS < $ENUMS{DIRECTIONS} is
-- This is an enumeration class which describes the different
-- directions in which text is produced on a display or printed page.
-- The strings to be read into the Names array are expected to be
-- culturally appropriate words like --
--
-- "up", "down", "left", "right"
-- Version 1.1 Jan 97. Copyright K Hopper, U of Waikato
-- Development History
-- -------------------
-- Date Who By Detail
-- ---- ------ ------
-- 14 Apr 96 kh Original
-- 10 Jan 97 kh Altered to conform to library portability.
include ENUM{DIRECTIONS} ;
private const val_count : CARD := 4 ;
-- The next constant routines provide the enumeration itself.
Up : SAME is return enum(1) end ;
Down : SAME is return enum(2) end ;
Left : SAME is return enum(3) end ;
Right : SAME is return enum(4) end ;
end ; -- DIRECTIONS
immutable class MEASURE_UNITS < $ENUMS{MEASURE_UNITS}
immutable class MEASURE_UNITS < $ENUMS{MEASURE_UNITS} is
-- This class is an enumeration of the value in the LC_MEASUREMENT
-- component of ISO/IEC 14652.
--
-- Version 1.0 Feb 98. Copyright K Hopper, U of Waikato
-- Development History
-- -------------------
-- Date Who By Detail
-- ---- ------ ------
-- 20 Feb 98 kh Original from ISO/IEC 14652
include ENUM{MEASURE_UNITS} ;
private const val_count : CARD := 3 ;
-- The following constant 'routines' specify the enumeration values.
ISO_1000 : SAME is return enum(1) end ;
US_System : SAME is return enum(2) end ;
Other : SAME is return enum(3) end ;
end ; -- MEASURE_UNITS