|
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.IO; |
|
20 using System.Collections.Generic; |
|
21 using System.Text; |
|
22 using System.Threading; |
|
23 using SymbianStructuresLib.Debug.Symbols; |
|
24 using SymbianStructuresLib.Debug.Symbols.Interfaces; |
|
25 using SymbianSymbolLib.SourceManagement.Source; |
|
26 using SymbianSymbolLib.SourceManagement.Provisioning; |
|
27 using SymbianUtils.FileTypes; |
|
28 using SymbianUtils; |
|
29 using SLPluginSymbol.Data; |
|
30 using SLPluginSymbol.Reader; |
|
31 using SLPluginSymbol.Utilities; |
|
32 |
|
33 namespace SLPluginSymbol.Source |
|
34 { |
|
35 internal class SymbolSource : SymSource |
|
36 { |
|
37 #region Constructors |
|
38 public SymbolSource( string aURI, SymSourceProvider aProvider ) |
|
39 : base( aURI, aProvider ) |
|
40 { |
|
41 iData = new SymbolFileData( this ); |
|
42 // |
|
43 FindCollections(); |
|
44 } |
|
45 #endregion |
|
46 |
|
47 #region API |
|
48 public SymbolFileData ExcavateData() |
|
49 { |
|
50 SymbolFileData ret = iData; |
|
51 iData = null; |
|
52 return ret; |
|
53 } |
|
54 #endregion |
|
55 |
|
56 #region From SymSource |
|
57 public override void Read( TSynchronicity aSynchronicity ) |
|
58 { |
|
59 EnsureCollectionsAreFound(); |
|
60 // |
|
61 base.Read( aSynchronicity ); |
|
62 } |
|
63 #endregion |
|
64 |
|
65 #region Properties |
|
66 public new SymSourceProvider Provider |
|
67 { |
|
68 get |
|
69 { |
|
70 SymSourceProvider provider = (SymSourceProvider) base.Provider; |
|
71 return provider; |
|
72 } |
|
73 } |
|
74 #endregion |
|
75 |
|
76 #region Event handlers |
|
77 #endregion |
|
78 |
|
79 #region Internal constants |
|
80 #endregion |
|
81 |
|
82 #region Internal methods |
|
83 private void EnsureCollectionsAreFound() |
|
84 { |
|
85 System.Diagnostics.Debug.Assert( iFindCollectionsARE != null ); |
|
86 using ( iFindCollectionsARE ) |
|
87 { |
|
88 iFindCollectionsARE.WaitOne(); |
|
89 } |
|
90 // |
|
91 iFindCollectionsARE = null; |
|
92 } |
|
93 |
|
94 private void FindCollections() |
|
95 { |
|
96 iFindCollectionsARE = new AutoResetEvent( false ); |
|
97 // |
|
98 iData.Split( System.Environment.ProcessorCount ); |
|
99 iData.DataPrepared += new SymbolFileData.DataPreparedHandler( SymbolFileData_DataPrepared ); |
|
100 iData.FindCollections(); |
|
101 } |
|
102 |
|
103 private void SymbolFileData_DataPrepared( SymbolFileData aData ) |
|
104 { |
|
105 System.Diagnostics.Debug.Assert( iFindCollectionsARE != null ); |
|
106 System.Diagnostics.Debug.Assert( base.HaveBeenDisposedOf == false ); |
|
107 // |
|
108 lock ( iAutoResetEventLock ) |
|
109 { |
|
110 iFindCollectionsARE.Set(); |
|
111 } |
|
112 } |
|
113 #endregion |
|
114 |
|
115 #region From DisposableObject |
|
116 protected override void CleanupManagedResources() |
|
117 { |
|
118 try |
|
119 { |
|
120 base.CleanupManagedResources(); |
|
121 } |
|
122 finally |
|
123 { |
|
124 if ( iFindCollectionsARE != null ) |
|
125 { |
|
126 iFindCollectionsARE.Close(); |
|
127 iFindCollectionsARE = null; |
|
128 } |
|
129 } |
|
130 } |
|
131 #endregion |
|
132 |
|
133 #region Data members |
|
134 private SymbolFileData iData; |
|
135 private object iAutoResetEventLock = new object(); |
|
136 private AutoResetEvent iFindCollectionsARE = null; |
|
137 #endregion |
|
138 } |
|
139 } |