crashanalysercmd/PerfToolsSharedLibraries/Engine/SymbianETMLib/Common/Packets/Base/ETMPcktBase.cs
changeset 0 818e61de6cd1
equal deleted inserted replaced
-1:000000000000 0:818e61de6cd1
       
     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.Utilities;
       
    24 
       
    25 namespace SymbianETMLib.Common.Packets
       
    26 {
       
    27     public abstract class ETMPcktBase
       
    28     {
       
    29         #region Constructors
       
    30         protected ETMPcktBase()
       
    31             : this( 0 )
       
    32         {
       
    33         }
       
    34 
       
    35         protected ETMPcktBase( SymByte aValue )
       
    36         {
       
    37             iRawByte = aValue;
       
    38         }
       
    39         #endregion
       
    40 
       
    41         #region API
       
    42         public bool IsBitSet( int aBitNumber )
       
    43         {
       
    44             bool ret = RawByte[ aBitNumber ];
       
    45             return ret;
       
    46         }
       
    47 
       
    48         protected SymByte CreateMask( string aBinary )
       
    49         {
       
    50             return (byte) SymBitUtils.CreateMask( aBinary );
       
    51         }
       
    52 
       
    53         protected void SetMask( string aHigh, string aLow )
       
    54         {
       
    55             SetMask( aHigh + aLow );
       
    56         }
       
    57 
       
    58         protected void SetMask( string aSignificantBitValues )
       
    59         {
       
    60             iBitMask = SymBitUtils.CreateMask( aSignificantBitValues, out iBitValue );
       
    61         }
       
    62         #endregion
       
    63 
       
    64         #region API - framework
       
    65         public virtual bool Matches( SymByte aOpCode )
       
    66         {
       
    67             uint masked = (byte) ( aOpCode & BitMask );
       
    68             if ( masked == BitValue )
       
    69             {
       
    70                 return true;
       
    71             }
       
    72 
       
    73             return false;
       
    74         }
       
    75 
       
    76         public virtual int Priority
       
    77         {
       
    78             get { return 0; }
       
    79         }
       
    80         #endregion
       
    81 
       
    82         #region Properties
       
    83         public string Binary
       
    84         {
       
    85             get
       
    86             {
       
    87                 StringBuilder ret = new StringBuilder();
       
    88                 ret.Append( Convert.ToString( iRawByte, 2 ).PadLeft( 8, '0' ) );
       
    89                 return ret.ToString();
       
    90             }
       
    91         }
       
    92 
       
    93         public SymByte RawByte
       
    94         {
       
    95             get { return iRawByte; }
       
    96             set { iRawByte = value; }
       
    97         }
       
    98 
       
    99         protected SymByte BitMask
       
   100         {
       
   101             get { return iBitMask; }
       
   102         }
       
   103 
       
   104         protected SymByte BitValue
       
   105         {
       
   106             get { return iBitValue; }
       
   107         }
       
   108         #endregion
       
   109 
       
   110         #region Data members
       
   111         private SymByte iBitMask = 0;
       
   112         private SymByte iBitValue = 0;
       
   113         private SymByte iRawByte = 0;
       
   114         #endregion
       
   115     }
       
   116 }