crashanalysercmd/PerfToolsSharedLibraries/Engine/SymbianCodeLib/SourceManagement/Provisioning/CodeSourceProvider.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.Collections.Generic;
       
    20 using System.Text;
       
    21 using System.IO;
       
    22 using SymbianUtils;
       
    23 using SymbianUtils.Tracer;
       
    24 using SymbianUtils.FileTypes;
       
    25 using SymbianStructuresLib.Arm;
       
    26 using SymbianStructuresLib.Arm.Instructions;
       
    27 using SymbianStructuresLib.Debug.Common.Id;
       
    28 using SymbianStructuresLib.Debug.Common.Interfaces;
       
    29 using SymbianCodeLib.DbgEnginePlugin;
       
    30 using SymbianCodeLib.SourceManagement.Source;
       
    31 using SymbianInstructionLib.Arm.Library;
       
    32 using SymbianInstructionLib.Arm.Instructions.Common;
       
    33 
       
    34 namespace SymbianCodeLib.SourceManagement.Provisioning
       
    35 {
       
    36     public abstract class CodeSourceProvider : DisposableObject
       
    37     {
       
    38         #region Constructors
       
    39         protected CodeSourceProvider( CodeSourceProviderManager aManager )
       
    40         {
       
    41             iManager = aManager;
       
    42         }
       
    43         #endregion
       
    44 
       
    45         #region Framework API
       
    46         public virtual bool IsSupported( string aFileName )
       
    47         {
       
    48             SymFileTypeList fileTypes = FileTypes;
       
    49             string extension = Path.GetExtension( aFileName );
       
    50             //
       
    51             bool ret = fileTypes.IsSupported( extension );
       
    52             return ret;
       
    53         }
       
    54 
       
    55         public virtual CodeSourceCollection CreateSources( string aName )
       
    56         {
       
    57             throw new NotSupportedException( "Support not implemented by " + this.GetType().ToString() );
       
    58         }
       
    59 
       
    60         public abstract SymFileTypeList FileTypes
       
    61         {
       
    62             get;
       
    63         }
       
    64 
       
    65         public abstract string Name
       
    66         {
       
    67             get;
       
    68         }
       
    69 
       
    70         public virtual string GetFileName( CodeSource aSource )
       
    71         {
       
    72             string ret = aSource.URI;
       
    73             return ret;
       
    74         }
       
    75 
       
    76         public virtual void PrepareToCreateSources( IEnumerable<string> aFileNames )
       
    77         {
       
    78         }
       
    79         #endregion
       
    80 
       
    81         #region API
       
    82         public IArmInstruction[] ConvertToInstructions( TArmInstructionSet aInstructionSet, uint[] aRawInstructions, uint aStartingAddress )
       
    83         {
       
    84             IArmInstruction[] ret = iManager.InstructionLibrary.ConvertToInstructions( aInstructionSet, aRawInstructions, aStartingAddress );
       
    85             return ret;
       
    86         }
       
    87 
       
    88         public bool SourceRemove( CodeSource aSource )
       
    89         {
       
    90             CodeSourceManager manager = iManager.Plugin.SourceManager;
       
    91             bool removed = manager.Remove( aSource );
       
    92             return removed;
       
    93         }
       
    94 
       
    95         public bool SourceAdd( CodeSource aSource )
       
    96         {
       
    97             CodeSourceManager manager = iManager.Plugin.SourceManager;
       
    98             bool added = manager.Add( aSource );
       
    99             return added;
       
   100         }
       
   101         #endregion
       
   102 
       
   103         #region Properties
       
   104         public ITracer Tracer
       
   105         {
       
   106             get { return iManager; }
       
   107         }
       
   108 
       
   109         public IPlatformIdAllocator IdAllocator
       
   110         {
       
   111             get { return iManager.IdAllocator; }
       
   112         }
       
   113 
       
   114         public ArmLibrary InstructionLibrary
       
   115         {
       
   116             get { return iManager.InstructionLibrary; }
       
   117         }
       
   118 
       
   119         public int SourceCount
       
   120         {
       
   121             get { return iManager.Plugin.SourceManager.Count; }
       
   122         }
       
   123 
       
   124         protected CodeSourceProviderManager ProvisioningManager
       
   125         {
       
   126             get { return iManager; }
       
   127         }
       
   128         #endregion
       
   129 
       
   130         #region Data members
       
   131         private readonly CodeSourceProviderManager iManager;
       
   132         #endregion
       
   133     }
       
   134 }