|
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 SymbianDebugLib.Engine; |
|
19 using SymbianStackLib.Data.Output; |
|
20 using SymbianStackLib.Data.Source; |
|
21 using SymbianStackLib.Engine; |
|
22 using SymbianStackLib.Interfaces; |
|
23 using SymbianUtils; |
|
24 |
|
25 namespace SymbianStackLib.Algorithms |
|
26 { |
|
27 public abstract class StackAlgorithm : AsyncReaderBase |
|
28 { |
|
29 #region Constructors |
|
30 protected StackAlgorithm( IStackAlgorithmManager aManager, IStackAlgorithmObserver aObserver ) |
|
31 : base( aManager ) |
|
32 { |
|
33 iManager = aManager; |
|
34 iAlgorithmObserver = aObserver; |
|
35 } |
|
36 #endregion |
|
37 |
|
38 #region API |
|
39 public abstract string Name { get; } |
|
40 public abstract int Priority { get; } |
|
41 |
|
42 public virtual bool IsAvailable() |
|
43 { |
|
44 // We must have symbols |
|
45 bool ret = DebugEngineView.Symbols.IsReady; |
|
46 // |
|
47 base.Trace( "[StackAlgorithm] IsAvailable() - ret: {0}", ret ); |
|
48 return ret; |
|
49 } |
|
50 |
|
51 public virtual void BuildStack( TSynchronicity aSynchronicity ) |
|
52 { |
|
53 base.StartRead( aSynchronicity ); |
|
54 } |
|
55 #endregion |
|
56 |
|
57 #region Properties |
|
58 protected IStackAlgorithmManager Manager |
|
59 { |
|
60 get { return iManager; } |
|
61 } |
|
62 |
|
63 protected IStackAlgorithmObserver StackObserver |
|
64 { |
|
65 get { return iAlgorithmObserver; } |
|
66 } |
|
67 |
|
68 protected StackEngine Engine |
|
69 { |
|
70 get { return Manager.Engine; } |
|
71 } |
|
72 |
|
73 protected DbgEngineView DebugEngineView |
|
74 { |
|
75 get { return iManager.DebugEngineView; } |
|
76 } |
|
77 |
|
78 protected StackSourceData SourceData |
|
79 { |
|
80 get { return Engine.DataSource; } |
|
81 } |
|
82 |
|
83 protected StackOutputData OutputData |
|
84 { |
|
85 get { return Engine.DataOutput; } |
|
86 } |
|
87 #endregion |
|
88 |
|
89 #region From AsyncReaderBase |
|
90 protected override void HandleReadException( Exception aException ) |
|
91 { |
|
92 iAlgorithmObserver.StackBuildingException( this, aException ); |
|
93 } |
|
94 |
|
95 protected override void NotifyEvent( AsyncReaderBase.TEvent aEvent ) |
|
96 { |
|
97 switch ( aEvent ) |
|
98 { |
|
99 case TEvent.EReadingStarted: |
|
100 iAlgorithmObserver.StackBuildingStarted( this ); |
|
101 break; |
|
102 case TEvent.EReadingProgress: |
|
103 { |
|
104 int progress = base.Progress; |
|
105 if ( progress != iLastProgress ) |
|
106 { |
|
107 iAlgorithmObserver.StackBuldingProgress( this, base.Progress ); |
|
108 iLastProgress = progress; |
|
109 } |
|
110 break; |
|
111 } |
|
112 case TEvent.EReadingComplete: |
|
113 iAlgorithmObserver.StackBuildingComplete( this ); |
|
114 break; |
|
115 } |
|
116 // |
|
117 base.NotifyEvent( aEvent ); |
|
118 } |
|
119 #endregion |
|
120 |
|
121 #region From System.Object |
|
122 public override string ToString() |
|
123 { |
|
124 return Name; |
|
125 } |
|
126 #endregion |
|
127 |
|
128 #region Data members |
|
129 private readonly IStackAlgorithmManager iManager; |
|
130 private readonly IStackAlgorithmObserver iAlgorithmObserver; |
|
131 private int iLastProgress = 0; |
|
132 #endregion |
|
133 } |
|
134 } |