|
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 System.Drawing; |
|
22 using SymbianUtils; |
|
23 using SymbianUtils.FileSystem; |
|
24 using SymbianUtils.Settings; |
|
25 using SymbianDebugLib.Engine; |
|
26 using SymbianDebugLib.Entity.Primer; |
|
27 using SymbianDebugLib.PluginAPI; |
|
28 |
|
29 namespace SymbianDebugLib.Entity.Configurations |
|
30 { |
|
31 public class DbgEntityConfig : IEnumerable<DbgEntityConfig.CfgSet> |
|
32 { |
|
33 #region Constructors |
|
34 public DbgEntityConfig( DbgEntityConfigManager aManager ) |
|
35 { |
|
36 iManager = aManager; |
|
37 } |
|
38 #endregion |
|
39 |
|
40 #region Classes |
|
41 public sealed class CfgFile |
|
42 { |
|
43 #region Constructors |
|
44 public CfgFile( string aFileName ) |
|
45 { |
|
46 iFileNameAndPath = aFileName; |
|
47 } |
|
48 #endregion |
|
49 |
|
50 #region API |
|
51 public void AddId( string aId ) |
|
52 { |
|
53 iId.Add( aId ); |
|
54 } |
|
55 |
|
56 public bool Contains( DbgEntityConfigIdentifier aId ) |
|
57 { |
|
58 bool ret = iId.Contains( aId ); |
|
59 return ret; |
|
60 } |
|
61 #endregion |
|
62 |
|
63 #region Properties |
|
64 public string FileNameAndPath |
|
65 { |
|
66 get { return iFileNameAndPath; } |
|
67 } |
|
68 #endregion |
|
69 |
|
70 #region Data members |
|
71 private string iFileNameAndPath = string.Empty; |
|
72 private DbgEntityConfigIdentifier iId = new DbgEntityConfigIdentifier(); |
|
73 #endregion |
|
74 } |
|
75 |
|
76 public sealed class CfgSet : IEnumerable<CfgFile> |
|
77 { |
|
78 #region Constructors |
|
79 public CfgSet( string aSetName ) |
|
80 { |
|
81 iSetName = aSetName; |
|
82 } |
|
83 #endregion |
|
84 |
|
85 #region API |
|
86 public void Add( CfgFile aFile ) |
|
87 { |
|
88 iFiles.Add( aFile ); |
|
89 } |
|
90 |
|
91 public bool Contains( DbgEntityConfigIdentifier aId ) |
|
92 { |
|
93 bool ret = false; |
|
94 // |
|
95 foreach ( CfgFile file in iFiles ) |
|
96 { |
|
97 if ( file.Contains( aId ) ) |
|
98 { |
|
99 ret = true; |
|
100 break; |
|
101 } |
|
102 } |
|
103 // |
|
104 return ret; |
|
105 } |
|
106 #endregion |
|
107 |
|
108 #region Properties |
|
109 public string Name |
|
110 { |
|
111 get { return iSetName; } |
|
112 } |
|
113 |
|
114 public int Count |
|
115 { |
|
116 get { return iFiles.Count; } |
|
117 } |
|
118 |
|
119 public CfgFile this[ int aIndex ] |
|
120 { |
|
121 get { return iFiles[ aIndex ]; } |
|
122 } |
|
123 #endregion |
|
124 |
|
125 #region From IEnumerable<CfgFile> |
|
126 public IEnumerator<CfgFile> GetEnumerator() |
|
127 { |
|
128 foreach ( CfgFile f in iFiles ) |
|
129 { |
|
130 yield return f; |
|
131 } |
|
132 } |
|
133 |
|
134 System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() |
|
135 { |
|
136 foreach ( CfgFile f in iFiles ) |
|
137 { |
|
138 yield return f; |
|
139 } |
|
140 } |
|
141 #endregion |
|
142 |
|
143 #region Data members |
|
144 private readonly string iSetName; |
|
145 private List<CfgFile> iFiles = new List<CfgFile>(); |
|
146 #endregion |
|
147 } |
|
148 #endregion |
|
149 |
|
150 #region API |
|
151 public bool Contains( DbgEntityConfigIdentifier aId ) |
|
152 { |
|
153 bool ret = false; |
|
154 // |
|
155 foreach ( KeyValuePair<string, CfgSet> kvp in iSets ) |
|
156 { |
|
157 if ( kvp.Value.Contains( aId ) ) |
|
158 { |
|
159 ret = true; |
|
160 break; |
|
161 } |
|
162 } |
|
163 // |
|
164 return ret; |
|
165 } |
|
166 |
|
167 public void Add( CfgSet aSet ) |
|
168 { |
|
169 CfgSet ret = null; |
|
170 if ( iSets.TryGetValue( aSet.Name, out ret ) ) |
|
171 { |
|
172 throw new ArgumentException( "Specified set already registered" ); |
|
173 } |
|
174 // |
|
175 iSets.Add( aSet.Name, aSet ); |
|
176 } |
|
177 #endregion |
|
178 |
|
179 #region Properties |
|
180 public DbgEngine Engine |
|
181 { |
|
182 get { return Manager.Engine; } |
|
183 } |
|
184 |
|
185 protected DbgEntityConfigManager Manager |
|
186 { |
|
187 get { return iManager; } |
|
188 } |
|
189 #endregion |
|
190 |
|
191 #region Internal methods |
|
192 #endregion |
|
193 |
|
194 #region From IEnumerable<CfgSet> |
|
195 public IEnumerator<CfgSet> GetEnumerator() |
|
196 { |
|
197 foreach ( KeyValuePair< string, CfgSet> kvp in iSets ) |
|
198 { |
|
199 yield return kvp.Value; |
|
200 } |
|
201 } |
|
202 |
|
203 System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() |
|
204 { |
|
205 foreach ( KeyValuePair<string, CfgSet> kvp in iSets ) |
|
206 { |
|
207 yield return kvp.Value; |
|
208 } |
|
209 } |
|
210 #endregion |
|
211 |
|
212 #region Data members |
|
213 private readonly DbgEntityConfigManager iManager; |
|
214 private Dictionary<string, CfgSet> iSets = new Dictionary<string, CfgSet>(); |
|
215 #endregion |
|
216 } |
|
217 } |