diff -r 000000000000 -r 818e61de6cd1 crashanalysercmd/PerfToolsSharedLibraries/Engine/SymbolLib/CodeSeg/Resolver/CodeSegResolverEntryCollection.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/crashanalysercmd/PerfToolsSharedLibraries/Engine/SymbolLib/CodeSeg/Resolver/CodeSegResolverEntryCollection.cs Thu Feb 11 15:50:58 2010 +0200 @@ -0,0 +1,190 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +using System; +using System.Collections; +using System.Collections.Generic; + +namespace SymbolLib.CodeSegDef +{ + public class CodeSegResolverEntryCollection : IEnumerable + { + #region Constructors & destructor + public CodeSegResolverEntryCollection() + : this( 10 ) + { + } + + public CodeSegResolverEntryCollection( int aGranularity ) + { + iEntries = new List( aGranularity ); + } + #endregion + + #region API + public void Reset() + { + iEntries.Clear(); + } + + public void Add( CodeSegResolverEntry aNewEntry ) + { + if ( aNewEntry.ImageFileName.Length == 0 ) + { + throw new ArgumentException( "Invalid code seg definition entry" ); + } + + // Our check-for-exists predicate + Predicate existsPredicate = delegate( CodeSegResolverEntry aEntry ) + { + return aEntry.ImageFileName.ToLower() == aNewEntry.ImageFileName.ToLower(); + }; + + // Check whether there is already an entry that matches + if ( !iEntries.Exists( existsPredicate ) ) + { + iEntries.Add( aNewEntry ); + } + else + { +#if TRACE_RESOLVER + System.Diagnostics.Debug.WriteLine( "IGNORING DUPE CodeSegDefinition: " + aNewEntry.ToString() ); +#endif + } + } + + public void Remove( CodeSegResolverEntry aRemoveEntry ) + { + if ( String.IsNullOrEmpty( aRemoveEntry.ImageFileName ) ) + { + // Remove by environment file name + Predicate matchPredicate = delegate( CodeSegResolverEntry aEntry ) + { + return aEntry.EnvironmentFileName.ToLower() == aRemoveEntry.EnvironmentFileName.ToLower(); + }; + iEntries.RemoveAll( matchPredicate ); + } + else + { + // Remove by phone file name + Predicate matchPredicate = delegate( CodeSegResolverEntry aEntry ) + { + return aEntry.ImageFileName.ToLower() == aRemoveEntry.ImageFileName.ToLower(); + }; + iEntries.RemoveAll( matchPredicate ); + } + } + + public int IndexOf( CodeSegResolverEntry aEntry ) + { + int index = -1; + // + int count = iEntries.Count; + for( int i=0; i( Compare ) ); + } + + public CodeSegResolverEntry FindByCodeSegmentFileNameAndPath( string aImageCodeSegmentFileNameAndPath ) + { + CodeSegResolverEntry temp = new CodeSegResolverEntry( string.Empty, aImageCodeSegmentFileNameAndPath ); + int index = iEntries.IndexOf( temp ); + + int x = 0; + if ( x != 0 ) + { + int count = iEntries.Count; + for( int i=0; i " + e.EnvironmentFileNameAndPath + " ] IMG[ " + e.ImageFileName + " => " + e.ImageFileNameAndPath + " ]" ); +#endif + + } + } + + if ( index >= 0 && index < Count ) + { + temp = this[ index ]; + } + else + { + // Not found + temp = null; + } + // + return temp; + } + #endregion + + #region Properties + public int Count + { + get { return iEntries.Count; } + } + + public CodeSegResolverEntry this[ int aIndex ] + { + get { return iEntries[ aIndex ]; } + } + #endregion + + #region IEnumerable Members + IEnumerator IEnumerable.GetEnumerator() + { + foreach ( CodeSegResolverEntry entry in iEntries ) + { + yield return entry; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + foreach ( CodeSegResolverEntry entry in iEntries ) + { + yield return entry; + } + } + #endregion + + #region Internal methods + private static int Compare( CodeSegResolverEntry aLeft, CodeSegResolverEntry aRight ) + { + return aLeft.EnvironmentFileNameAndPath.CompareTo( aRight.EnvironmentFileNameAndPath ); + } + #endregion + + #region Data members + private readonly List iEntries; + #endregion + } +}