|
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.Collections.Generic; |
|
19 using System.Text; |
|
20 using System.IO; |
|
21 using SymbianUtils; |
|
22 using SymbianUtils.Settings; |
|
23 using SymbianUtils.FileSystem; |
|
24 using SymbianDebugLib.Engine; |
|
25 using SymbianDebugLib.Entity.Descriptors; |
|
26 |
|
27 namespace SymbianDebugLib.Entity |
|
28 { |
|
29 public class DbgEntityList : DisposableObject, IEnumerable<DbgEntity> |
|
30 { |
|
31 #region Constructors |
|
32 internal DbgEntityList( DbgEngine aEngine ) |
|
33 { |
|
34 iEngine = aEngine; |
|
35 } |
|
36 #endregion |
|
37 |
|
38 #region API |
|
39 public virtual void Add( DbgEntity aEntity ) |
|
40 { |
|
41 iEntities.Add( aEntity ); |
|
42 } |
|
43 |
|
44 public virtual DbgEntity Remove( DbgEntity aEntity ) |
|
45 { |
|
46 Predicate<DbgEntity> predicate = delegate( DbgEntity entity ) { return entity == aEntity; }; |
|
47 DbgEntity found = iEntities.Find( predicate ); |
|
48 if ( found != null ) |
|
49 { |
|
50 iEntities.Remove( found ); |
|
51 } |
|
52 // |
|
53 return found; |
|
54 } |
|
55 |
|
56 public bool Contains( FSEntity aFSEntity ) |
|
57 { |
|
58 bool ret = false; |
|
59 // |
|
60 foreach ( DbgEntity e in iEntities ) |
|
61 { |
|
62 if ( e.FSEntity == aFSEntity ) |
|
63 { |
|
64 ret = true; |
|
65 break; |
|
66 } |
|
67 } |
|
68 // |
|
69 return ret; |
|
70 } |
|
71 #endregion |
|
72 |
|
73 #region Properties |
|
74 public int Count |
|
75 { |
|
76 get { return iEntities.Count; } |
|
77 } |
|
78 |
|
79 public DbgEntity this[ int aIndex ] |
|
80 { |
|
81 get { return iEntities[ aIndex ]; } |
|
82 } |
|
83 |
|
84 public DbgEngine Engine |
|
85 { |
|
86 get { return iEngine; } |
|
87 } |
|
88 |
|
89 public string[] FileNames |
|
90 { |
|
91 get |
|
92 { |
|
93 List<string> ret = new List<string>(); |
|
94 foreach ( DbgEntity e in iEntities ) |
|
95 { |
|
96 ret.Add( e.FullName ); |
|
97 } |
|
98 return ret.ToArray(); |
|
99 } |
|
100 } |
|
101 #endregion |
|
102 |
|
103 #region From DisposableObject |
|
104 protected override void CleanupManagedResources() |
|
105 { |
|
106 try |
|
107 { |
|
108 base.CleanupManagedResources(); |
|
109 } |
|
110 finally |
|
111 { |
|
112 foreach ( DbgEntity entity in iEntities ) |
|
113 { |
|
114 entity.Dispose(); |
|
115 } |
|
116 } |
|
117 } |
|
118 #endregion |
|
119 |
|
120 #region Internal properties |
|
121 #endregion |
|
122 |
|
123 #region Internal methods |
|
124 #endregion |
|
125 |
|
126 #region From IEnumerable<DbgEntity> |
|
127 public IEnumerator<DbgEntity> GetEnumerator() |
|
128 { |
|
129 foreach ( DbgEntity e in iEntities ) |
|
130 { |
|
131 yield return e; |
|
132 } |
|
133 } |
|
134 |
|
135 System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() |
|
136 { |
|
137 foreach ( DbgEntity e in iEntities ) |
|
138 { |
|
139 yield return e; |
|
140 } |
|
141 } |
|
142 #endregion |
|
143 |
|
144 #region Data members |
|
145 private readonly DbgEngine iEngine; |
|
146 private List<DbgEntity> iEntities = new List<DbgEntity>(); |
|
147 #endregion |
|
148 } |
|
149 } |