crashanalysercmd/Libraries/Engine/CrashDebuggerLib/Structures/Process/ProcessChunk.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 CrashDebuggerLib.Structures.KernelObjects;
       
    22 using CrashDebuggerLib.Structures.Chunk;
       
    23 using CrashDebuggerLib.Structures.Common;
       
    24 
       
    25 namespace CrashDebuggerLib.Structures.Process
       
    26 {
       
    27     public class ProcessChunk : CrashDebuggerAware
       
    28     {
       
    29         #region Constructors
       
    30         public ProcessChunk( CrashDebuggerInfo aCrashDebugger, uint aChunkAddress, int aAccessCount )
       
    31             : base( aCrashDebugger )
       
    32         {
       
    33             iChunkAddress = aChunkAddress;
       
    34             iAccessCount = aAccessCount;
       
    35         }
       
    36         #endregion
       
    37 
       
    38         #region API
       
    39         #endregion
       
    40 
       
    41         #region Properties
       
    42         public uint ChunkAddress
       
    43         {
       
    44             get { return iChunkAddress; }
       
    45             set { iChunkAddress = value; }
       
    46         }
       
    47 
       
    48         public Chunk.DChunk Chunk
       
    49         {
       
    50             get { return CrashDebugger.ChunkByAddress( ChunkAddress ); }
       
    51         }
       
    52 
       
    53         public int AccessCount
       
    54         {
       
    55             get { return iAccessCount; }
       
    56             set { iAccessCount = value; }
       
    57         }
       
    58         #endregion
       
    59 
       
    60         #region Internal methods
       
    61         #endregion
       
    62 
       
    63         #region Internal constants
       
    64         #endregion
       
    65 
       
    66         #region From System.Object
       
    67         public override string ToString()
       
    68         {
       
    69             return base.ToString();
       
    70         }
       
    71         #endregion
       
    72 
       
    73         #region Data members
       
    74         private uint iChunkAddress = 0;
       
    75         private int iAccessCount = 0;
       
    76         #endregion
       
    77     }
       
    78 
       
    79     public class ProcessChunkCollection : IEnumerable<ProcessChunk>
       
    80     {
       
    81         #region Constructors
       
    82         public ProcessChunkCollection()
       
    83         {
       
    84         }
       
    85         #endregion
       
    86 
       
    87         #region API
       
    88         public void Add( ProcessChunk aChunk )
       
    89         {
       
    90             iEntries.Add( aChunk );
       
    91         }
       
    92         #endregion
       
    93 
       
    94         #region Properties
       
    95         public ProcessChunk this[ int aIndex ]
       
    96         {
       
    97             get { return iEntries[ aIndex ]; }
       
    98         }
       
    99 
       
   100         public int Count
       
   101         {
       
   102             get { return iEntries.Count; }
       
   103         }
       
   104         #endregion
       
   105 
       
   106         #region Internal methods
       
   107         #endregion
       
   108 
       
   109         #region Internal constants
       
   110         #endregion
       
   111 
       
   112         #region From System.Object
       
   113         public override string ToString()
       
   114         {
       
   115             return base.ToString();
       
   116         }
       
   117         #endregion
       
   118 
       
   119         #region From IEnumerable<Chunk>
       
   120         public IEnumerator<ProcessChunk> GetEnumerator()
       
   121         {
       
   122             return new ProcessChunkEnumerator( this );
       
   123         }
       
   124 
       
   125         System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
       
   126         {
       
   127             return new ProcessChunkEnumerator( this );
       
   128         }
       
   129         #endregion
       
   130 
       
   131         #region Data members
       
   132         private List<ProcessChunk> iEntries = new List<ProcessChunk>();
       
   133         #endregion
       
   134     }
       
   135 
       
   136     #region Internal enumerator
       
   137     internal class ProcessChunkEnumerator : IEnumerator<ProcessChunk>
       
   138     {
       
   139         #region Constructors
       
   140         public ProcessChunkEnumerator( ProcessChunkCollection aList )
       
   141         {
       
   142             iList = aList;
       
   143         }
       
   144         #endregion
       
   145 
       
   146         #region IEnumerator Members
       
   147         public void Reset()
       
   148         {
       
   149             iCurrentIndex = -1;
       
   150         }
       
   151 
       
   152         public object Current
       
   153         {
       
   154             get
       
   155             {
       
   156                 return iList[ iCurrentIndex ];
       
   157             }
       
   158         }
       
   159 
       
   160         public bool MoveNext()
       
   161         {
       
   162             return ( ++iCurrentIndex < iList.Count );
       
   163         }
       
   164         #endregion
       
   165 
       
   166         #region From IEnumerator<ProcessChunk>
       
   167         ProcessChunk IEnumerator<ProcessChunk>.Current
       
   168         {
       
   169             get { return iList[ iCurrentIndex ]; }
       
   170         }
       
   171         #endregion
       
   172 
       
   173         #region From IDisposable
       
   174         public void Dispose()
       
   175         {
       
   176         }
       
   177         #endregion
       
   178 
       
   179         #region Data members
       
   180         private readonly ProcessChunkCollection iList;
       
   181         private int iCurrentIndex = -1;
       
   182         #endregion
       
   183     }
       
   184     #endregion
       
   185 }