crashanalysercmd/PerfToolsSharedLibraries/Engine/SymbolLib/CodeSeg/Resolver/CodeSegResolverOperation.cs
changeset 0 818e61de6cd1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/crashanalysercmd/PerfToolsSharedLibraries/Engine/SymbolLib/CodeSeg/Resolver/CodeSegResolverOperation.cs	Thu Feb 11 15:50:58 2010 +0200
@@ -0,0 +1,147 @@
+/*
+* 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.IO;
+using System.Threading;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Collections.Specialized;
+using System.Collections.Generic;
+using System.ComponentModel;
+using SymbianUtils;
+using SymbianUtils.SerializedOperations;
+using SymbolLib.Sources.Map.Parser;
+
+namespace SymbolLib.CodeSegDef
+{
+	public abstract class CodeSegResolverOperation : SerializedOperation
+    {
+        #region Events
+        public delegate void LocatedFileNameHandler( string aFileName );
+        public event LocatedFileNameHandler LocatedFile;
+        public delegate void RawTextHandler( string aText );
+        public event RawTextHandler RawText;
+        #endregion
+
+        #region Constructors
+        protected CodeSegResolverOperation( CodeSegResolver aResolver, bool aResetResolver )
+            : base( false )
+		{
+            iResolver = aResolver;
+            iResetResolver = aResetResolver;
+		}
+		#endregion
+
+        #region From SerializedOperation
+        protected override void PerformOperation()
+        {
+            base.Trace( "" );
+            base.Trace( " => => => => => => => => => => => => => => => => => => => => => " );
+            base.Trace( "" );
+            base.Trace( "PerformOperation() - START - this: " + this.GetType().Name );
+
+            if ( iResetResolver )
+            {
+                iResolver.Clear();
+            }
+
+            this.NotifyRawText( "Scanning..." );
+            Scan();
+
+            base.Trace( "PerformOperation() - END - this: " + this.GetType().Name );
+        }
+        #endregion
+
+        #region API - new framework
+        protected abstract void Scan();
+        #endregion
+
+        #region API
+        protected void Add( CodeSegResolverEntry aEntry )
+        {
+            NotifyFile( aEntry.ImageFileNameAndPath );
+            base.Trace( "[{0}] device: {1}, host: {2}", this.GetType().Name, aEntry.ImageFileNameAndPath, aEntry.EnvironmentFileNameAndPath );
+            //
+            iResolver.Add( aEntry );
+        }
+        #endregion
+
+        #region Properties
+        protected string DriveLetter
+        {
+            get { return iResolver.DriveLetter; }
+            set { iResolver.DriveLetter = value; }
+        }
+        #endregion
+
+        #region Internal methods
+        protected void NotifyRawText( string aMessage )
+        {
+            if ( RawText != null )
+            {
+                RawText( aMessage );
+            }
+        }
+
+        protected void NotifyFile( string aFileName )
+        {
+            if ( LocatedFile != null )
+            {
+                LocatedFile( aFileName );
+            }
+        }
+
+        protected static string RemoveMapExtension( string aFileName )
+        {
+            StringBuilder ret = new StringBuilder( aFileName );
+            //
+            int pos = aFileName.LastIndexOf( CodeSegResolver.KMapFileExtension );
+            if ( pos >= 1 )
+            {
+                ret.Remove( pos, CodeSegResolver.KMapFileExtension.Length );
+            }
+            //
+            return ret.ToString().ToLower();
+        }
+
+        protected static string GeneratePhoneBinaryNameAndPath( string aFileName )
+        {
+            StringBuilder ret = new StringBuilder();
+            //
+            ret.Append( CodeSegResolver.KROMBinaryPath );
+            ret.Append( Path.GetFileName( aFileName ).ToLower() );
+            //
+            return ret.ToString();
+        }
+
+        protected string CombineWithDriveLetter( string aFileName )
+		{
+			string ret = string.Empty;
+			lock( this )
+			{
+				ret = Path.Combine( iResolver.DriveLetter, aFileName ).ToLower();
+			}
+			return ret;
+		}
+        #endregion
+
+        #region Data members
+        private readonly CodeSegResolver iResolver;
+        private readonly bool iResetResolver;
+		#endregion
+	}
+}