commsfwtools/commstools/utracedecoder/inc/messagedefparser/identifierbase.h
changeset 0 dfb7c4ff071f
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #ifndef IDENTIFIERBASE_H
       
    17 #define IDENTIFIERBASE_H
       
    18 
       
    19 #include <string>
       
    20 
       
    21 namespace Parser
       
    22 {
       
    23 
       
    24 /**
       
    25 The types of identifiers
       
    26 */
       
    27 enum TIdentifierType
       
    28     {
       
    29     /** Constants (only integer constants supported) */
       
    30     EConstIdentifier,
       
    31 
       
    32     /** Any integer type (INTx/UINTx) */
       
    33     EIntegerTypeIdentifier,
       
    34 
       
    35     /** The enumeration type - contains enumeration value types */
       
    36     EEnumTypeIdentifier,
       
    37 
       
    38     /** The enumation value type that represents the values contained in an enumeration */
       
    39 //    EEnumValueIdentifier,
       
    40 
       
    41     /** A user defined structure */
       
    42     EStructIdentifier,
       
    43 
       
    44     /** A user defined signature */
       
    45     ESignatureIdentifier,
       
    46 
       
    47     /** A user defined context */
       
    48     EContextIdentifier,
       
    49 
       
    50     /** A user definied message */ 
       
    51     EMessageIdentifier,
       
    52 
       
    53     /** Identifies padding bytes */
       
    54     EPadTypeIdentifier,
       
    55 
       
    56     /** The builtin struct for TMessageId */
       
    57     EMessageIdTypeIdentifier,
       
    58     };
       
    59 
       
    60 /**
       
    61 CIdentifierBase is an abstract class that provides the base functionality
       
    62 for any basic or builtin types.
       
    63 */
       
    64 class CIdentifierBase
       
    65     {
       
    66     public:
       
    67         /**
       
    68         D'tor
       
    69         */
       
    70         virtual ~CIdentifierBase();
       
    71 
       
    72         /**
       
    73         Returns the type of identifier that this identifier is
       
    74         @see TIdentifierType
       
    75         */
       
    76         inline TIdentifierType Type() const
       
    77             {
       
    78             return iType;
       
    79             }
       
    80 
       
    81         /**
       
    82         Returns the unique name that identifies this identifier
       
    83         */
       
    84         inline const char* Name() const
       
    85             {
       
    86             return iName;
       
    87             }
       
    88 
       
    89         /**
       
    90         Returns identifier flags
       
    91         */
       
    92         inline int Flags() const
       
    93             {
       
    94             return iFlags;
       
    95             }
       
    96         
       
    97         /** Returns the size of this type in bytes */
       
    98         int Size() const;
       
    99 
       
   100         /** Returns the size of this type in bytes including the size of any base types */
       
   101         virtual int TotalSize() const;
       
   102 
       
   103         /**
       
   104         Formats the data provided according to the layout of the type represented by
       
   105         the implementation and outputs it to the stream.
       
   106         @param aData A pointer to the buffer containing the data for this type.
       
   107         @param aLength The number of bytes believed to belong to this type.
       
   108                It should match the TotalSize() of the identifier.
       
   109         @param aOptions A pointer to an identifier type specific object containing
       
   110                options that the type will understand and can use to alter the output
       
   111                formatting on a per item basis. This usually comes from TMember.
       
   112         @param aDescription The stream to output to.
       
   113         */
       
   114         virtual void Describe(const unsigned char* aData, unsigned int aLength, const void* aOptions, std::ostream& aDescription) const = 0;
       
   115 
       
   116     protected:
       
   117         explicit CIdentifierBase(TIdentifierType aType, const char* aName)
       
   118             {
       
   119             iType = aType;
       
   120             iName = _strdup(aName);
       
   121             iSize = 0;
       
   122             iFlags = 0;
       
   123             }
       
   124 
       
   125     protected:
       
   126         int iSize; // The size of this type in bytes
       
   127         int iFlags;
       
   128 
       
   129     private:
       
   130         TIdentifierType iType;
       
   131         char* iName;
       
   132     };
       
   133     
       
   134 
       
   135 /**
       
   136 TMember represents a data member of a structure style type.
       
   137 These are STRUCT, CONTEXT, and SIGNATURE.
       
   138 */
       
   139 struct TMember
       
   140     {
       
   141     public:
       
   142         TMember()
       
   143             : iMemberType(NULL), iOffset(0), iArraySize(1), iIdentifierOptions(NULL)
       
   144             {
       
   145             }
       
   146 
       
   147         const CIdentifierBase* iMemberType;
       
   148         std::string iMemberName;
       
   149         int iOffset;
       
   150         int iArraySize;
       
   151         void* iIdentifierOptions;
       
   152     };
       
   153 
       
   154 } // namespace Parser
       
   155 
       
   156 #endif
       
   157 // IDENTIFIERBASE_H
       
   158