crashanalysercmd/PerfToolsSharedLibraries/Engine/SymBuildParsingLib/Token/SymTokenBalancerMatchCriteria.cs
changeset 0 818e61de6cd1
equal deleted inserted replaced
-1:000000000000 0:818e61de6cd1
       
     1 /*
       
     2 * Copyright (c) 2004-2008 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 *
       
    16 */
       
    17 
       
    18 using System;
       
    19 using System.Text;
       
    20 using System.Collections;
       
    21 using SymBuildParsingLib.Tree;
       
    22 using SymbianTree;
       
    23 
       
    24 namespace SymBuildParsingLib.Token
       
    25 {
       
    26 	#region Enumerations
       
    27 	public enum TLevelExpectations
       
    28 	{
       
    29 		ELevelExpectationsAny = 0,
       
    30 		ELevelExpectationsAtLevel,
       
    31 		ELevelExpectationsBelowLevelNumber,
       
    32 		ELevelExpectationsAboveLevelNumber
       
    33 	}
       
    34 
       
    35 	[Flags]
       
    36 	public enum TAssociatedBehaviour
       
    37 	{
       
    38 		EBehaviourNone = 0,
       
    39 		EBehaviourRemoveReduntantBracketing = 1,
       
    40 		EBehaviourCreateSubTree = 2
       
    41 	}
       
    42 	#endregion
       
    43 
       
    44 	public class SymTokenBalancerMatchCriteria
       
    45 	{
       
    46 		#region Constructors & destructor
       
    47 		public SymTokenBalancerMatchCriteria( SymToken aDiametricToken, bool aEmit, bool aChangesLevel, TLevelExpectations aLevelExpectations, int aAssociatedLevel, TAssociatedBehaviour aAssociatedBehaviour )
       
    48 		{
       
    49 			iDiametricToken = aDiametricToken;
       
    50 			iEmit = aEmit;
       
    51 			iChangesLevel = aChangesLevel;
       
    52 			iLevelExpectations = aLevelExpectations;
       
    53 			iAssociatedLevel = aAssociatedLevel;
       
    54 			iAssociatedBehaviour = aAssociatedBehaviour;
       
    55 		}
       
    56 		#endregion
       
    57 
       
    58 		#region API
       
    59 		public bool Matches( int aLevel )
       
    60 		{
       
    61 			bool matches = false;
       
    62 			//
       
    63 			switch( iLevelExpectations )
       
    64 			{
       
    65 			default:
       
    66 			case TLevelExpectations.ELevelExpectationsAny:
       
    67 				matches = true;
       
    68 				break;
       
    69 			case TLevelExpectations.ELevelExpectationsAtLevel:
       
    70 				matches = ( aLevel == iAssociatedLevel );
       
    71 				break;
       
    72 			case TLevelExpectations.ELevelExpectationsBelowLevelNumber:
       
    73 				matches = ( aLevel < iAssociatedLevel );
       
    74 				break;
       
    75 			case TLevelExpectations.ELevelExpectationsAboveLevelNumber:
       
    76 				matches = ( aLevel > iAssociatedLevel );
       
    77 				break;
       
    78 			}
       
    79 			//
       
    80 			return matches;
       
    81 		}
       
    82 		#endregion
       
    83 
       
    84 		#region Properties
       
    85 		public SymToken DiametricToken
       
    86 		{
       
    87 			get { return iDiametricToken; }
       
    88 		}
       
    89 
       
    90 		public bool Emit
       
    91 		{
       
    92 			get { return iEmit; }
       
    93 		}
       
    94 
       
    95 		public bool ChangesLevel
       
    96 		{
       
    97 			get { return iChangesLevel; }
       
    98 		}
       
    99 
       
   100 		public int AssociatedLevel
       
   101 		{
       
   102 			get { return iAssociatedLevel; }
       
   103 		}
       
   104 
       
   105 		public TLevelExpectations LevelExpectations
       
   106 		{
       
   107 			get { return iLevelExpectations; }
       
   108 		}
       
   109 
       
   110 		public TAssociatedBehaviour AssociatedBehaviour
       
   111 		{
       
   112 			get { return iAssociatedBehaviour; }
       
   113 		}
       
   114 		#endregion
       
   115 
       
   116 		#region Properties - associated behaviour bitflag helpers
       
   117 		public bool IsAssociatedBehaviourRemoveRedundantBracketing
       
   118 		{
       
   119 			get { return ( iAssociatedBehaviour & TAssociatedBehaviour.EBehaviourRemoveReduntantBracketing ) == TAssociatedBehaviour.EBehaviourRemoveReduntantBracketing; }
       
   120 		}
       
   121 
       
   122 		public bool IsAssociatedBehaviourCreateSubTree
       
   123 		{
       
   124 			get { return ( iAssociatedBehaviour & TAssociatedBehaviour.EBehaviourCreateSubTree ) == TAssociatedBehaviour.EBehaviourCreateSubTree; }
       
   125 		}
       
   126 		#endregion
       
   127 
       
   128 		#region From System.Object
       
   129 		public override bool Equals( object aObject )
       
   130 		{
       
   131 			bool same = false;
       
   132 			//
       
   133 			if	( aObject is SymTokenBalancerMatchCriteria )
       
   134 			{
       
   135 				SymTokenBalancerMatchCriteria otherInfo = (SymTokenBalancerMatchCriteria) aObject;
       
   136 				//
       
   137 				same = ( Emit == otherInfo.Emit ) &&
       
   138 					   ( ChangesLevel == otherInfo.ChangesLevel ) &&
       
   139 					   ( LevelExpectations == otherInfo.LevelExpectations ) &&
       
   140 					   ( AssociatedLevel == otherInfo.AssociatedLevel ) &&
       
   141 					   ( AssociatedBehaviour == otherInfo.AssociatedBehaviour );
       
   142 			}
       
   143 			//
       
   144 			return same;
       
   145 		}
       
   146 		#endregion
       
   147 
       
   148 		#region Constants
       
   149 		public const int KAssociatedLevelDefault = 1;
       
   150 		#endregion
       
   151 
       
   152 		#region Data members
       
   153 		private readonly SymToken iDiametricToken;
       
   154 		private readonly bool iEmit;
       
   155 		private readonly bool iChangesLevel;
       
   156 		private readonly TLevelExpectations iLevelExpectations = TLevelExpectations.ELevelExpectationsAny;
       
   157 		private readonly int iAssociatedLevel = KAssociatedLevelDefault;
       
   158 		private readonly TAssociatedBehaviour iAssociatedBehaviour;
       
   159 		#endregion
       
   160 	}
       
   161 }