analyzetool/analyzetool_plat/analyzetool_api/inc/analyzetool/customuser.h
branchRCL_3
changeset 59 8ad140f3dd41
parent 49 7fdc9a71d314
equal deleted inserted replaced
49:7fdc9a71d314 59:8ad140f3dd41
     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:  Declaration of the class CustomUser containing overloaded User static functions.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CUSTOMUSER_H
       
    20 #define CUSTOMUSER_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <u32std.h>
       
    24 #include <e32svr.h>
       
    25 
       
    26 // CONSTANTS
       
    27 const TInt KATVersionLength = 20;
       
    28 const TInt KATDefaultLogOption = 0;
       
    29 const TInt KATDefaultDebug = 1;
       
    30 const TInt KATDefaultAllocCallStackSize = 40;
       
    31 const TInt KATDefaultFreeCallStackSize = 0;
       
    32     
       
    33 // TYPEDEFS
       
    34 typedef TBuf<KATVersionLength> TATVersion;
       
    35 
       
    36 // Argument list for SetupThreadHeap function parameters. (currently not used)
       
    37 // When needed, update the argument type directly inside _LIT macro.
       
    38 _LIT( KATArgumentList, "%i%i" ); //etc. 
       
    39 
       
    40 // CLASS DECLARATION
       
    41 
       
    42 /**
       
    43 *  Class which overloads the User functions and provides access to 
       
    44 *  the overloaded functions  
       
    45 */
       
    46 class CustomUser
       
    47     {
       
    48     public: // Enumerations
       
    49         enum TATOptions
       
    50             {
       
    51             /** Acquiring the log filename */
       
    52             ELogFileName = 1,   
       
    53             /** Acquiring the version number */
       
    54             EVersion,
       
    55             /** Acquiring logging option */
       
    56             ELogOption,
       
    57             /** Acquiring UDEB/UREL information */  
       
    58             EDebug,
       
    59             /** Acquiring max allocation call stack size */
       
    60             EAllocCallStackSize,
       
    61             /** Acquiring max free call stack size */
       
    62             EFreeCallStackSize,
       
    63             /** Acquiring the path of logfile */
       
    64             ELogFilePath
       
    65             };
       
    66         
       
    67     public:
       
    68 
       
    69         /**
       
    70         * Overloaded version of User::Exit()
       
    71         * Terminates the current thread, specifying a reason. All child 
       
    72         * threads are terminated and all resources are cleaned up.If the 
       
    73         * current thread is the main thread in a process, the process is
       
    74         * also terminated.
       
    75         * @param aReason The reason code.
       
    76         */
       
    77         IMPORT_C static void Exit( TInt aReason );
       
    78 
       
    79         /**
       
    80         * Overloaded version of User::Panic()
       
    81         * Panics the current thread, specifying a category name and panic
       
    82         * number. Keep the length of the category name small;
       
    83         * a length of 16 is ideal.
       
    84         * @param aCategory A reference to the descriptor containing the text 
       
    85         * that defines the category for this panic.
       
    86         * @param aReason The panic number. 
       
    87         */   
       
    88         IMPORT_C static void Panic( const TDesC& aCategory, TInt aReason );
       
    89 
       
    90         /**
       
    91         * Overloaded version of UserHeap::SetupThreadHeap()
       
    92         * Setups the threads heap.
       
    93         * @param aNotFirst Is this first thread using specified heap
       
    94         * @param aInfo Specifies the thread heap properties
       
    95         * @param aFileName The name of the log file
       
    96         * @param aLogOption The logging option
       
    97         * @param aIsDebug Determines whether a binary is UDEB or UREL
       
    98         * @param aVersion Atool version number
       
    99         * @param aAllocCallStackSize Max number of stored callstack items when memory allocated
       
   100         * @param aFreeCallStackSize Max number of stored callstack items when memory freed
       
   101         * @param aFmt A descriptor containing the format string
       
   102         * @return TInt KErrNone, if the insertion is successful, otherwise 
       
   103         * one of the system wide error codes.
       
   104         */   
       
   105         IMPORT_C static TInt SetupThreadHeap( 
       
   106                              TBool aNotFirst, 
       
   107                              SStdEpocThreadCreateInfo& aInfo,
       
   108                              const TFileName& aFileName,
       
   109                              const TPath& aFilePath,
       
   110                              TUint32 aLogOption, TUint32 aIsDebug,
       
   111                              const TATVersion& aVersion,
       
   112                              TUint32 aAllocCallStackSize,
       
   113                              TUint32 aFreeCallStackSize,
       
   114                              TRefByValue<const TDesC> aFmt, ... );
       
   115                              
       
   116         /**
       
   117         * Overloaded version of UserHeap::SetCritical()
       
   118         * Sets up or changes the effect that termination of the current 
       
   119         * thread has, either on its owning process, or on the whole system.
       
   120         * The precise effect of thread termination is defined by the following
       
   121         *  specific values of the TCritical enum:
       
   122         * ENotCritical
       
   123         * EProcessCritical
       
   124         * EProcessPermanent
       
   125         * ESystemCritical
       
   126         * ESystemPermanent
       
   127         * Notes: The enum value EAllThreadsCritical cannot be set using this
       
   128         * function. It is associated with a process, not a thread, and, if 
       
   129         * appropriate, should be set using User::SetProcessCritical().
       
   130         * The states associated with ENotCritical, EProcessCritical, 
       
   131         * EProcessPermanent, ESystemCritical and ESystemPermanent are all 
       
   132         * mutually exclusive, i.e. the thread can only be in one of these 
       
   133         * states at any one time.
       
   134         * @param aCritical The state to be set.
       
   135         * @return TInt KErrNone, if successful; KErrArgument, if 
       
   136         * EAllThreadsCritical is passed - this is a state associated with a 
       
   137         * process, and you use User::SetProcessCritical() to set it.
       
   138         */ 
       
   139         IMPORT_C static TInt SetCritical( User::TCritical aCritical );
       
   140         
       
   141         /**
       
   142         * Overloaded version of UserHeap::SetCritical()
       
   143         * Sets up or changes the effect that termination of subsequently 
       
   144         * created threads will have, either on the owning process, 
       
   145         * or on the whole system. It is important to note that we are not
       
   146         * referring to threads that have already been created, but threads
       
   147         * that will be created subsequent to a call to this function.
       
   148         * The precise effect of thread termination is defined by the following
       
   149         * specific values of the TCritical enum:
       
   150         * ENotCritical
       
   151         * EAllThreadsCritical
       
   152         * ESystemCritical
       
   153         * ESystemPermanent
       
   154         * Notes:
       
   155         * The enum values EProcessCritical and EProcessPermanent cannot be set
       
   156         * using this function. They are states associated with a thread, not a
       
   157         * process, and, if appropriate, should be set using 
       
   158         * User::SetCritical(). The states associated with ENotCritical, 
       
   159         * EAllThreadsCritical, ESystemCritical and ESystemPermanent are all 
       
   160         * mutually exclusive, i.e. the process can only be in one of these 
       
   161         * states at any one time.
       
   162         * @param aCritical The state to be set.
       
   163         * @return TInt KErrNone, if successful; KErrArgument, if either 
       
   164         * EProcessCritical or EProcessPermanent is passed - these are states
       
   165         * associated with a thread, and you use User::SetCritical() 
       
   166         * to set them.
       
   167         */ 
       
   168         IMPORT_C static TInt SetProcessCritical( User::TCritical aCritical );
       
   169                 
       
   170     private: // Private functions
       
   171         
       
   172         /**
       
   173         * Factory function for creating RAllocator instances.
       
   174         * @param aNotFirst Is this first thread using specified heap
       
   175         * @param aLogOption The logging option
       
   176         * @param aFileName The name of the logging file
       
   177         * @param aIsDebug Determines whether a binary is UDEB or UREL
       
   178         * @param aAllocCallStackSize Max number of stored callstack items when memory allocated
       
   179         * @param aFreecallStackSize Max number of stored callstack items when memory freed
       
   180         * @param aAtoolVersion Version of atool
       
   181         * @param aApiVersion  Version of atool's api
       
   182         * @return RAllocator& A reference to created allocator
       
   183         */  
       
   184         static RAllocator& InstallAllocator( TBool aNotFirst,
       
   185                                              const TFileName& aFileName,
       
   186                                              const TPath& aFilePath,
       
   187                                              TUint32 aLogOption, TUint32 aIsDebug,
       
   188                                              TUint32 aAllocCallStackSize,
       
   189                                              TUint32 aFreeCallStackSize, 
       
   190                                              const TDesC8& aAtoolVersion,
       
   191                                              const TDesC8& aApiVersion );
       
   192         
       
   193 		/**
       
   194 		* Check atool version
       
   195 		* @param aVersion - Atool version number.
       
   196 		* @param aToolVersion The atool version number
       
   197 		* @return KErrNone if correct version found, otherwise one of the system wide 
       
   198 		* error codes.
       
   199 		*/
       
   200         static TInt CheckVersion( const TATVersion& aVersion, TDes& aToolVersion, TDes& aApiVersion ); 
       
   201         
       
   202 
       
   203         /**
       
   204 		* Function for showing incorrect version information (file or debug channel).
       
   205 		* @param aLogOption The logging option
       
   206 		* @param aFileName The name of the log file
       
   207 		* @param aToolVersion The atool version number
       
   208 		*/
       
   209         static void ReportIncorrectVersion( const TUint32 aLogOption, 
       
   210 											const TFileName& aFileName,
       
   211 											const TPath& aFilePath,
       
   212 											const TDes& aToolVersion );
       
   213         
       
   214     };
       
   215 
       
   216 #endif // CUSTOMUSER_H
       
   217 
       
   218 // End of File