crashanalysercmd/PerfToolsSharedLibraries/Engine/SymbianCodeLib/SourceManagement/Source/CodeSourceManager.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 SymbianUtils;
       
    22 using SymbianStructuresLib.CodeSegments;
       
    23 using SymbianStructuresLib.Debug.Code;
       
    24 using SymbianCodeLib.DbgEnginePlugin;
       
    25 
       
    26 namespace SymbianCodeLib.SourceManagement.Source
       
    27 {
       
    28     internal class CodeSourceManager : CodeSourceCollection
       
    29     {
       
    30         #region Delegates & events
       
    31         public delegate void SourceEventHandler( CodeSource aSource );
       
    32         public event SourceEventHandler SourceAdded = null;
       
    33         public event SourceEventHandler SourceRemoved = null;
       
    34         #endregion
       
    35 
       
    36         #region Constructors
       
    37         public CodeSourceManager( CodePlugin aPlugin )
       
    38         {
       
    39             iPlugin = aPlugin;
       
    40         }
       
    41         #endregion
       
    42 
       
    43         #region API
       
    44         public IEnumerable<CodeCollection> GetFixedCollectionEnumerator()
       
    45         {
       
    46             foreach ( CodeSource source in this )
       
    47             {
       
    48                 foreach ( CodeCollection col in source )
       
    49                 {
       
    50                     if ( col.IsFixed )
       
    51                     {
       
    52                         yield return col;
       
    53                     }
       
    54                 }
       
    55             }
       
    56         }
       
    57         #endregion
       
    58 
       
    59         #region Properties
       
    60         public CodeSourceAndCollection this[ CodeSegDefinition aCodeSeg ]
       
    61         {
       
    62             get
       
    63             {
       
    64                 CodeSourceAndCollection ret = null;
       
    65                 //
       
    66                 foreach ( CodeSource source in this )
       
    67                 {
       
    68                     CodeCollection col = source[ aCodeSeg ];
       
    69                     if ( col != null )
       
    70                     {
       
    71                         ret = new CodeSourceAndCollection( source, col );
       
    72                         break;
       
    73                     }
       
    74                 }
       
    75                 //
       
    76                 return ret;
       
    77             }
       
    78         }
       
    79         #endregion
       
    80 
       
    81         #region From CodeSourceCollection
       
    82         protected override void OnAdded( CodeSource aSource )
       
    83         {
       
    84             base.OnAdded( aSource );
       
    85             if ( SourceAdded != null )
       
    86             {
       
    87                 SourceAdded( aSource );
       
    88             }
       
    89         }
       
    90 
       
    91         protected override void OnRemoved( CodeSource aSource )
       
    92         {
       
    93             base.OnRemoved( aSource );
       
    94             if ( SourceRemoved != null )
       
    95             {
       
    96                 SourceRemoved( aSource );
       
    97             }
       
    98         }
       
    99         #endregion
       
   100 
       
   101         #region Data members
       
   102         private readonly CodePlugin iPlugin;
       
   103         #endregion
       
   104     }
       
   105 }