tzpcside/tzcompiler/Include/TzEntities.h
changeset 0 2e3d3ce01487
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // DST TZ Database Compiler 
       
    15 // 
       
    16 //
       
    17 
       
    18 #ifndef __TZENTITIES_H_
       
    19 #define __TZENTITIES_H_
       
    20 
       
    21 #include "PersistedEntityWrapper.h"
       
    22 #include "..\..\tz\server\include\tzpersisted.h"
       
    23 #include "TzNode.h"
       
    24 #include "TzEntities.h"
       
    25 #include "TzDocument.h"
       
    26 #include <vector>
       
    27 #include <string>
       
    28 using namespace std;
       
    29 
       
    30 class CTzCpRuleSet;
       
    31 //============================================================================
       
    32 // CTzCpString Class Definition
       
    33 // String wrapper class, binds a string to its offset in the string table.
       
    34 //============================================================================
       
    35 class CTzCpString : public CPersistedEntityWrapper
       
    36 	{
       
    37 public:
       
    38 	CTzCpString(CTZDocument& aDocument);
       
    39 	//From CPersistedEntityWrapper
       
    40 	int AssembleL(CTZNode& aNode) {return 0;}
       
    41 	void ExternaliseL(ofstream& aFilestream);
       
    42 public:
       
    43 	std::string iString;
       
    44 	//int iOffset;
       
    45 	};
       
    46 //============================================================================
       
    47 // CTzCpStdTimeAlignment Class Definition
       
    48 //============================================================================
       
    49 class CTzCpStdTimeAlignment : public CPersistedEntityWrapper
       
    50 	{
       
    51 public:
       
    52 	CTzCpStdTimeAlignment(CTZDocument& aDocument);
       
    53 	~CTzCpStdTimeAlignment();
       
    54 	//From CPersistedEntityWrapper
       
    55 	int AssembleL(CTZNode& aNode);
       
    56 	void ExternaliseL(ofstream& aFilestream);
       
    57 
       
    58 	//member data
       
    59 	std::vector<CTzCpString*> iOffsetsToTimeZonesShortNames;
       
    60 	CTzCpString* iOffsetToTimeZoneFormatName;
       
    61 	CTzCpRuleSet* iRuleSet;
       
    62 	TTzStdTimeAlignment iPersistedEntity;
       
    63 	};
       
    64 //============================================================================
       
    65 // CTzCpZone Class Definition
       
    66 //============================================================================
       
    67 class CTzCpZone : public CPersistedEntityWrapper
       
    68 	{
       
    69 public:
       
    70 	CTzCpZone(CTZDocument& aDocument);
       
    71 	~CTzCpZone();
       
    72 	//From CPersistedEntityWrapper
       
    73 	void ExternaliseL(ofstream& aFilestream);
       
    74 
       
    75 public: 
       
    76 	//member data
       
    77 	std::vector<CTzCpStdTimeAlignment*> iTimeAlignments;
       
    78 	CTzCpString* iRegionNameRef;
       
    79 	CTzCpString* iZoneNameRef;
       
    80 	TUint16 iLocationId;
       
    81 
       
    82 	TTzZone iPersistedEntity;
       
    83 
       
    84 	//
       
    85 	// three different methods to sort zones:
       
    86 	//
       
    87 	// alphabetically by zone name (for the regional zone indices):
       
    88 	struct SZoneNameSort
       
    89 		{
       
    90 		TBool operator()(CTzCpZone* aZone1, CTzCpZone* aZone2)
       
    91 			{
       
    92 			return aZone1->iZoneNameRef->iString < aZone2->iZoneNameRef->iString;
       
    93 			}
       
    94 		};
       
    95 
       
    96 	// by LocationId (for the Zones table)
       
    97 	struct SLocationIdSort
       
    98 		{
       
    99 		TBool operator()(CTzCpZone* aZone1, CTzCpZone* aZone2)
       
   100 			{
       
   101 			return aZone1->iLocationId < aZone2->iLocationId;
       
   102 			}
       
   103 		};
       
   104 
       
   105 	struct SZoneFullNameSort
       
   106 		{
       
   107 		TBool operator()(CTzCpZone* aZone1, CTzCpZone* aZone2)
       
   108 			{
       
   109 			if (aZone1->iRegionNameRef->iString < aZone2->iRegionNameRef->iString)
       
   110 				{
       
   111 				return true;
       
   112 				}
       
   113 			else if (aZone1->iRegionNameRef->iString ==  aZone2->iRegionNameRef->iString)
       
   114 				{
       
   115 				if (aZone1->iZoneNameRef->iString < aZone2->iZoneNameRef->iString)
       
   116 					{
       
   117 					return true;
       
   118 					}
       
   119 				else
       
   120 					{
       
   121 					return false;
       
   122 					}
       
   123 				}
       
   124 			else
       
   125 				{	
       
   126 				return false;
       
   127 				}			
       
   128 			}
       
   129 		};
       
   130 	};
       
   131 //============================================================================
       
   132 // CTzCpRegionalZonesIndex Class Definition
       
   133 //============================================================================
       
   134 class CTzCpRegionalZonesIndex : public CPersistedEntityWrapper
       
   135 	{
       
   136 public:
       
   137 	CTzCpRegionalZonesIndex(CTZDocument& aDocument);
       
   138 	//From CPersistedEntityWrapper
       
   139 	void ExternaliseL(ofstream& aFilestream);
       
   140 
       
   141 	void AddZoneIndex(CTzCpZone& aZoneRef);
       
   142 	//member data
       
   143 	TTzRegionalZoneIndex iPersistedEntity;
       
   144 	std::vector<CTzCpZone*> iZoneIndex;
       
   145 	};
       
   146 //============================================================================
       
   147 // CTzCpRegion Class Definition
       
   148 //============================================================================
       
   149 class CTzCpRegion : public CPersistedEntityWrapper
       
   150 	{
       
   151 public:
       
   152 	CTzCpRegion(CTZDocument& aDocument);
       
   153 	~CTzCpRegion();
       
   154 	//From CPersistedEntityWrapper
       
   155 	void ExternaliseL(ofstream& aFilestream);
       
   156 
       
   157 	//member data
       
   158 	CTzCpRegionalZonesIndex* iRegionalZonesIndex;
       
   159 	CTzCpString* iRegionNameRef;
       
   160 	TTzRegion iPersistedEntity;
       
   161 
       
   162 	};
       
   163 //============================================================================
       
   164 // CTzCpLink Class Definition
       
   165 // Wrapper class for a TTzLink.
       
   166 //============================================================================
       
   167 class CTzCpLink : public CPersistedEntityWrapper
       
   168 	{
       
   169 public:
       
   170 	CTzCpLink(CTZDocument& aDocument);
       
   171 	//From CPersistedEntityWrapper
       
   172 	int AssembleL(CTZNode& aNode);
       
   173 	void ExternaliseL(ofstream& aFilestream);
       
   174 
       
   175 	//member data
       
   176 	TTzLink iPersistedEntity;
       
   177 	//These objects are NOT owned by CTzCpLink
       
   178 	CTzCpString* iLinkString;
       
   179 	CTzCpString* iRegionString;
       
   180 	CTzCpString* iZoneString;
       
   181 	CTzCpZone* iLinkedZoneOffset;
       
   182 	};
       
   183 //============================================================================
       
   184 // CTzCpRuleDefinition Class Definition
       
   185 //============================================================================
       
   186 class CTzCpRuleDefinition : public CPersistedEntityWrapper
       
   187 	{
       
   188 public:
       
   189 	CTzCpRuleDefinition(CTZDocument& aDocument);
       
   190 	//From CPersistedEntityWrapper
       
   191 	int AssembleL(CTZNode& aNode);
       
   192 	void ExternaliseL(ofstream& aFilestream);
       
   193 	//member data
       
   194 	TTzRuleDefinition iPersistedEntity;
       
   195 	};
       
   196 //============================================================================
       
   197 // CTzCpRuleUse Class Definition
       
   198 // Encapsulates TRuleUse.  Will be part of a collection of CTzCpRuleUse
       
   199 // objects owned by a CTzCpRuleSet
       
   200 //============================================================================
       
   201 class CTzCpRuleUse : public CPersistedEntityWrapper
       
   202 	{
       
   203 public:
       
   204 	CTzCpRuleUse(CTZDocument& aDocument);
       
   205 	~CTzCpRuleUse();
       
   206 	//From CPersistedEntityWrapper
       
   207 	void AssembleL(CTZNode& aNode);
       
   208 	void ExternaliseL(ofstream& aFilestream);
       
   209 
       
   210 	//member data
       
   211 	CTzCpString* iRuleLetterPtr;
       
   212 	CTzCpRuleDefinition* iRuleDefinitionPtr;
       
   213 	TTzRuleUse iPersistedEntity;
       
   214 	};
       
   215 //============================================================================
       
   216 // CTzCPRuleSet Class Definition
       
   217 // Encapsulates a TTzRuleSet, and is responsible for creating a collection of
       
   218 // CTzCpRuleUse objects.
       
   219 //============================================================================
       
   220 class CTzCpRuleSet : public CPersistedEntityWrapper
       
   221 	{
       
   222 public:
       
   223 	CTzCpRuleSet(CTZDocument& aDocument,std::string aName);
       
   224 	~CTzCpRuleSet();
       
   225 	//From CPersistedEntityWrapper
       
   226 	void ExternaliseL(ofstream& aFilestream);
       
   227 
       
   228 	void AddRuleUse(CTzCpRuleUse& aRuleUseRef);
       
   229 
       
   230 	std::vector<CTzCpRuleUse*>& RuleUses() { return iVector; }
       
   231 	std::string& Name() { return iName; }
       
   232 
       
   233 private:
       
   234 	//member data
       
   235 	TTzRuleSet iPersistedEntity;
       
   236 	std::string iName;	//Name string for the ruleset. DO NOT add to string table
       
   237 	std::vector<CTzCpRuleUse*> iVector;
       
   238 	};
       
   239 #endif // __TZENTITIES_H_
       
   240 //============================================================================
       
   241 // End of file
       
   242 //============================================================================