crashanalysercmd/Libraries/Engine/CrashDebuggerLib/Structures/CodeSeg/CodeSegCollection.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.Common;
       
    23 
       
    24 namespace CrashDebuggerLib.Structures.CodeSeg
       
    25 {
       
    26     public class CodeSegCollection : CrashDebuggerAware, IEnumerable<CodeSegEntry>
       
    27     {
       
    28         #region Constructors
       
    29         public CodeSegCollection( CrashDebuggerInfo aCrashDebugger )
       
    30             : base( aCrashDebugger )
       
    31         {
       
    32         }
       
    33         #endregion
       
    34 
       
    35         #region API
       
    36         public void Clear()
       
    37         {
       
    38             iEntries.Clear();
       
    39         }
       
    40 
       
    41         public void Add( CodeSegEntry aEntry )
       
    42         {
       
    43             iEntries.Add( aEntry );
       
    44         }
       
    45         #endregion
       
    46 
       
    47         #region Properties
       
    48         public CodeSegEntry this[ int aIndex ]
       
    49         {
       
    50             get { return iEntries[ aIndex ]; }
       
    51         }
       
    52 
       
    53         public CodeSegEntry this[ uint aAddress ]
       
    54         {
       
    55             get
       
    56             {
       
    57                 CodeSegEntry ret = iEntries.Find( delegate( CodeSegEntry aEntry ) { return aEntry.KernelAddress == aAddress; } );
       
    58                 return ret;
       
    59             }
       
    60         }
       
    61 
       
    62         public int Count
       
    63         {
       
    64             get { return iEntries.Count; }
       
    65         }
       
    66         #endregion
       
    67 
       
    68         #region Internal methods
       
    69         #endregion
       
    70 
       
    71         #region Internal constants
       
    72         #endregion
       
    73 
       
    74         #region From System.Object
       
    75         public override string ToString()
       
    76         {
       
    77             return base.ToString();
       
    78         }
       
    79         #endregion
       
    80 
       
    81         #region From IEnumerable<CodeSegEntry>
       
    82         public IEnumerator<CodeSegEntry> GetEnumerator()
       
    83         {
       
    84             return new CodeSegEnumerator( this );
       
    85         }
       
    86 
       
    87         System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
       
    88         {
       
    89             return new CodeSegEnumerator( this );
       
    90         }
       
    91         #endregion
       
    92 
       
    93         #region Data members
       
    94         private List<CodeSegEntry> iEntries = new List<CodeSegEntry>();
       
    95         #endregion
       
    96     }
       
    97 
       
    98     #region Internal enumerator
       
    99     internal class CodeSegEnumerator : IEnumerator<CodeSegEntry>
       
   100     {
       
   101         #region Constructors
       
   102         public CodeSegEnumerator( CodeSegCollection aList )
       
   103         {
       
   104             iList = aList;
       
   105         }
       
   106         #endregion
       
   107 
       
   108         #region IEnumerator Members
       
   109         public void Reset()
       
   110         {
       
   111             iCurrentIndex = -1;
       
   112         }
       
   113 
       
   114         public object Current
       
   115         {
       
   116             get
       
   117             {
       
   118                 return iList[ iCurrentIndex ];
       
   119             }
       
   120         }
       
   121 
       
   122         public bool MoveNext()
       
   123         {
       
   124             return ( ++iCurrentIndex < iList.Count );
       
   125         }
       
   126         #endregion
       
   127 
       
   128         #region From IEnumerator<CodeSegEntry>
       
   129         CodeSegEntry IEnumerator<CodeSegEntry>.Current
       
   130         {
       
   131             get { return iList[ iCurrentIndex ]; }
       
   132         }
       
   133         #endregion
       
   134 
       
   135         #region From IDisposable
       
   136         public void Dispose()
       
   137         {
       
   138         }
       
   139         #endregion
       
   140 
       
   141         #region Data members
       
   142         private readonly CodeSegCollection iList;
       
   143         private int iCurrentIndex = -1;
       
   144         #endregion
       
   145     }
       
   146     #endregion
       
   147 }