|
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; |
|
19 using System.Collections.Generic; |
|
20 |
|
21 namespace CrashItemLib.Engine.Sources |
|
22 { |
|
23 public class CIEngineSourceCollection : IEnumerable<CIEngineSource> |
|
24 { |
|
25 #region Constructors |
|
26 public CIEngineSourceCollection( CIEngine aEngine ) |
|
27 { |
|
28 iEngine = aEngine; |
|
29 } |
|
30 #endregion |
|
31 |
|
32 #region API |
|
33 public void Clear() |
|
34 { |
|
35 lock ( iSources ) |
|
36 { |
|
37 iSources.Clear(); |
|
38 } |
|
39 } |
|
40 |
|
41 public void Add( CIEngineSource aEntry ) |
|
42 { |
|
43 aEntry.Collection = this; |
|
44 lock ( iSources ) |
|
45 { |
|
46 iSources.Add( aEntry ); |
|
47 } |
|
48 } |
|
49 #endregion |
|
50 |
|
51 #region Properties |
|
52 public int Count |
|
53 { |
|
54 get |
|
55 { |
|
56 lock ( iSources ) |
|
57 { |
|
58 return iSources.Count; |
|
59 } |
|
60 } |
|
61 } |
|
62 |
|
63 public CIEngineSource this[ int aIndex ] |
|
64 { |
|
65 get |
|
66 { |
|
67 lock ( iSources ) |
|
68 { |
|
69 return iSources[ aIndex ]; |
|
70 } |
|
71 } |
|
72 } |
|
73 |
|
74 public CIEngine Engine |
|
75 { |
|
76 get { return iEngine; } |
|
77 } |
|
78 #endregion |
|
79 |
|
80 #region Internal methods |
|
81 internal void OnSourceProgress( CIEngineSource aSource, int aProgress ) |
|
82 { |
|
83 iEngine.OnSourceProgress( aSource, aProgress ); |
|
84 } |
|
85 |
|
86 internal void OnSourceStateChanged( CIEngineSource aSource ) |
|
87 { |
|
88 iEngine.OnSourceStateChanged( aSource ); |
|
89 } |
|
90 |
|
91 internal void OnException( Exception aException ) |
|
92 { |
|
93 iEngine.Trace( "[CIEngineSourceCollection] OnException() - aException: {0} / {1}", aException.Message, aException.StackTrace ); |
|
94 iEngine.OnException( aException ); |
|
95 } |
|
96 #endregion |
|
97 |
|
98 #region From IEnumerable<CIEngineSource> |
|
99 public IEnumerator<CIEngineSource> GetEnumerator() |
|
100 { |
|
101 foreach ( CIEngineSource entry in iSources ) |
|
102 { |
|
103 yield return entry; |
|
104 } |
|
105 } |
|
106 |
|
107 IEnumerator IEnumerable.GetEnumerator() |
|
108 { |
|
109 foreach ( CIEngineSource entry in iSources ) |
|
110 { |
|
111 yield return entry; |
|
112 } |
|
113 } |
|
114 #endregion |
|
115 |
|
116 #region Data members |
|
117 private readonly CIEngine iEngine; |
|
118 private List<CIEngineSource> iSources = new List<CIEngineSource>(); |
|
119 #endregion |
|
120 } |
|
121 } |