|
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 |
|
18 using System; |
|
19 using System.Collections.Generic; |
|
20 using System.Text; |
|
21 using SymbianUtils.BasicTypes; |
|
22 using SymbianETMLib.Common.Types; |
|
23 using SymbianETMLib.Common.Packets; |
|
24 |
|
25 namespace SymbianETMLib.Common.State |
|
26 { |
|
27 public class ETMDecodeStateContextID : ETMDecodeState |
|
28 { |
|
29 #region Constructors |
|
30 public ETMDecodeStateContextID( ETMStateData aManager ) |
|
31 : base( aManager ) |
|
32 { |
|
33 iContextIdBytesRequired = aManager.Config.ContextIDSize; |
|
34 iBytesRemaining = iContextIdBytesRequired; |
|
35 } |
|
36 #endregion |
|
37 |
|
38 #region API |
|
39 public override ETMDecodeState HandleByte( SymByte aByte ) |
|
40 { |
|
41 // TODO: test this |
|
42 ETMDecodeState nextState = this; |
|
43 // |
|
44 int byteNumber = iContextIdBytesRequired - iBytesRemaining; |
|
45 uint val = aByte.LShift( byteNumber * 8 ); |
|
46 iContextId |= val; |
|
47 // |
|
48 if ( --iBytesRemaining == 0 ) |
|
49 { |
|
50 // Got everything |
|
51 base.StateData.SetContextID( iContextId ); |
|
52 nextState = new ETMDecodeStateSynchronized( base.StateData ); |
|
53 } |
|
54 // |
|
55 return nextState; |
|
56 } |
|
57 #endregion |
|
58 |
|
59 #region Properties |
|
60 public string ContextIDName |
|
61 { |
|
62 get |
|
63 { |
|
64 string ret = base.StateData.Config.GetContextID( iContextId ); |
|
65 return ret; |
|
66 } |
|
67 } |
|
68 #endregion |
|
69 |
|
70 #region Internal methods |
|
71 private void Trace() |
|
72 { |
|
73 base.DbgTrace( "CONTEXT_ID", string.Format( "ID: {0} [{1}]", iContextId, ContextIDName ) ); |
|
74 } |
|
75 #endregion |
|
76 |
|
77 #region From System.Object |
|
78 #endregion |
|
79 |
|
80 #region Data members |
|
81 private readonly int iContextIdBytesRequired; |
|
82 private uint iContextId = 0; |
|
83 private int iBytesRemaining = 0; |
|
84 #endregion |
|
85 } |
|
86 } |