crashanalysercmd/Libraries/File Formats/Plugins/DExcPlugin/Reader/DExcReader.cs
changeset 0 818e61de6cd1
equal deleted inserted replaced
-1:000000000000 0:818e61de6cd1
       
     1 /*
       
     2 * Copyright (c) 2009 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 using System;
       
    18 using System.Text;
       
    19 using System.IO;
       
    20 using System.Collections.Generic;
       
    21 using CrashItemLib.Crash.Container;
       
    22 using CrashItemLib.PluginAPI;
       
    23 using SymbianUtils.DataBuffer;
       
    24 using SymbianUtils.DataBuffer.Primer;
       
    25 using SymbianUtils;
       
    26 using DExcPlugin.Extractor;
       
    27 using DExcPlugin.Descriptor;
       
    28 using DExcPlugin.Plugin;
       
    29 using DExcPlugin.Transformer;
       
    30 
       
    31 namespace DExcPlugin.Reader
       
    32 {
       
    33     internal class DExcReader : CFFReader
       
    34 	{
       
    35 		#region Constructors
       
    36         public DExcReader( DExcPluginImp aEngine, DExcDescriptor aDescriptor )
       
    37 		:   base( aEngine, aDescriptor )
       
    38 		{
       
    39             iTraceExtractor.StateChanged += new DExcExtractor.EventHandler( TraceExtractor_StateChanged );
       
    40         }
       
    41         #endregion
       
    42 
       
    43         #region From CFFReader
       
    44         public override void NativeReadInit()
       
    45         {
       
    46             throw new NotSupportedException();
       
    47         }
       
    48 
       
    49         public override void TraceReadInit()
       
    50         {
       
    51             // Check if there is an stk file with the same name
       
    52             string stackFile = DExcDescriptor.StackFileName;
       
    53             if ( File.Exists( stackFile ) )
       
    54             {
       
    55                 iTraceExtractor.Init( stackFile );
       
    56             }
       
    57             else
       
    58             {
       
    59                 iTraceExtractor.Init();
       
    60             }
       
    61         }
       
    62 
       
    63         public override bool TraceReadOffer( CFFTraceLine aLine )
       
    64         {
       
    65             bool consumed = iTraceExtractor.Offer( aLine, aLine.LineNumber );
       
    66             return consumed;
       
    67         }
       
    68 
       
    69         public override void TraceReadComplete()
       
    70         {
       
    71             // This flushes any pending raw data items in the interpreter.
       
    72             iTraceExtractor.Finialize();
       
    73             
       
    74             base.NotifyEvent( TEvent.EReadingComplete );
       
    75         }
       
    76         #endregion
       
    77 
       
    78         #region Properties
       
    79         public DExcPluginImp DExcEngine
       
    80         {
       
    81             get { return base.Plugin as DExcPluginImp; }
       
    82         }
       
    83 
       
    84         public DExcDescriptor DExcDescriptor
       
    85         {
       
    86             get { return base.Descriptor as DExcDescriptor; }
       
    87         }
       
    88         #endregion
       
    89 
       
    90         #region Observer - Trace interpreter
       
    91         private void TraceExtractor_StateChanged( DExcExtractor.TEvent aEvent, DExcExtractor aExtractor )
       
    92         {
       
    93             // This event is notified when the extractor has obtained one entire D_EXC crash
       
    94             if ( aEvent == DExcExtractor.TEvent.EEventExtractedAllData )
       
    95             {
       
    96                 DExcExtractedData data = aExtractor.CurrentData;
       
    97                 DExcTransformer transformer = new DExcTransformer( DExcDescriptor, base.Plugin.DataProvider, data );
       
    98 
       
    99                 // Transform into crash container
       
   100                 CIContainer container = transformer.Transform();
       
   101                 if ( container != null )
       
   102                 {
       
   103                     base.NotifyEvent( TEvent.EReadingContainerCreated, container );
       
   104                 }
       
   105 
       
   106                 // Get extractor ready for next file
       
   107                 iTraceExtractor.Init();
       
   108             }
       
   109         }
       
   110         #endregion
       
   111 
       
   112         #region Internal methods
       
   113         #endregion
       
   114 
       
   115         #region Data members
       
   116         private DExcExtractor iTraceExtractor = new DExcExtractor();
       
   117         #endregion
       
   118     }
       
   119 }