extras/converter/engine/Src/TCnvUnit.h
branchRCL_3
changeset 15 2d0f9ab0ba18
parent 12 ddecbce3dc1f
child 16 82ca176301de
equal deleted inserted replaced
12:ddecbce3dc1f 15:2d0f9ab0ba18
     1 /*
       
     2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0""
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  
       
    15 *     This class is a data container of unit conversion parameters
       
    16 *     for a single unit.
       
    17 *     It is able to construct itself from a resource file.
       
    18 *
       
    19 */
       
    20 
       
    21 
       
    22 
       
    23 #ifndef __TCNVUNIT_H__
       
    24 #define __TCNVUNIT_H__
       
    25 
       
    26 // INCLUDES
       
    27 #include <e32base.h>
       
    28 #include "CCnvConverter.h"
       
    29 // FORWARD DECLARATIONS
       
    30 class TResourceReader;
       
    31 class RWriteStream;
       
    32 
       
    33 // CONSTANTS
       
    34 const TInt KMaxUnitNameLength = 36;
       
    35 
       
    36 // CLASS DEFINITION
       
    37 /**
       
    38 * This class is a data container of unit conversion parameters
       
    39 * for a single unit.
       
    40 * It is able to construct itself from a resource file.
       
    41 */
       
    42 class TCnvUnit
       
    43 	{
       
    44 	public: // Constructors
       
    45 
       
    46 		TCnvUnit();
       
    47 
       
    48 	public:	// new methods.
       
    49 
       
    50 		/**
       
    51 		* Constructs this unit from a CNV_UNIT or CNV_UNIT_TEMPERATURE
       
    52 		* resource.
       
    53 		* @param aReader A resource reader object initialised to a resource.
       
    54 		* @param aIsTemperature EFalse if we are going to read a CNV_UNIT
       
    55 		*        resource, ETrue if a CNV_UNIT_TEMPERATURE.
       
    56 		*/
       
    57 		void ReadFromResource( TResourceReader& aReader,
       
    58 							   TBool aIsTemperature = EFalse, TBool aIsCurrencyUnit =EFalse);
       
    59 
       
    60 		/**
       
    61 		* Stores the member variables to the given stream.
       
    62 		* @param aStream Stream for writing.
       
    63 		*/
       
    64 		void ExternalizeL( RWriteStream& aStream ) const;
       
    65 
       
    66 		/**
       
    67 		* Loads the member variables from the given stream.
       
    68 		* @param aStream Stream for reading.
       
    69 		*/
       
    70 		void InternalizeL( RReadStream& aStream , TBool aIsCurrencyCategory = EFalse);
       
    71 
       
    72 	public: // data
       
    73 
       
    74 		/**
       
    75 		* The factor for converting this unit to the base unit.
       
    76 		*/
       
    77 		TReal iFactor;
       
    78 
       
    79 		/**
       
    80 		* The offset for converting this unit to the base unit.
       
    81 		* Used only with temperature units.
       
    82 		*/
       
    83 		TReal iOffset;
       
    84 
       
    85 		/**
       
    86 		* Minimum allowable unit amount in conversion.
       
    87 		* Used only with temperature units.
       
    88 		*/
       
    89 		TReal iMinimum;
       
    90 
       
    91 		/**
       
    92 		* Unit name. Max lengh of 35 used in unit name queries.
       
    93 		*/
       
    94 		TBuf< KMaxUnitNameLength > iName;
       
    95 
       
    96 		/**
       
    97 		* Id of the unit. Used to identify unit among all other units.
       
    98 		* Unique.
       
    99 		*/
       
   100 		TUint iId;
       
   101 
       
   102 //	private: // data
       
   103 
       
   104 		/**
       
   105 		* ETrue if this unit defines a temperature, EFalse otherwise.
       
   106 		*/
       
   107 		TBool iIsTemperatureUnit;
       
   108 		TBool iIsCurrencyUnit;
       
   109 		TCurrencyType iNameType;
       
   110 	};
       
   111 
       
   112 #endif // __TCNVUNIT_H__