devsound/a3ftrace/src/a3f_trace_heap.cpp
changeset 0 40261b775718
equal deleted inserted replaced
-1:000000000000 0:40261b775718
       
     1 // Copyright (c) 2004-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 
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <e32std.h>
       
    21 #include <e32svr.h>
       
    22 #include "a3f_trace_heap.h"
       
    23 
       
    24 // EXTERNAL DATA STRUCTURES
       
    25 //extern  ?external_data;
       
    26 TUint32* 	TraceHeap::iTraceMask = NULL;
       
    27 TUint32* 	TraceHeap::iTraceLevel = NULL;
       
    28 TBool*      TraceHeap::iApiOnly = NULL;
       
    29 RHeap* 		TraceHeap::iTraceHeap = NULL;
       
    30 
       
    31 
       
    32 // EXTERNAL FUNCTION PROTOTYPES  
       
    33 //extern ?external_function( ?arg_type,?arg_type );
       
    34 
       
    35 // CONSTANTS
       
    36 //const ?type ?constant_var = ?constant;
       
    37 
       
    38 // MACROS
       
    39 //#define ?macro ?macro_def
       
    40 
       
    41 // LOCAL CONSTANTS AND MACROS
       
    42 //const ?type ?constant_var = ?constant;
       
    43 //#define ?macro_name ?macro_def
       
    44 
       
    45 // MODULE DATA STRUCTURES
       
    46 //enum ?declaration
       
    47 //typedef ?declaration
       
    48 
       
    49 // LOCAL FUNCTION PROTOTYPES
       
    50 //?type ?function_name( ?arg_type, ?arg_type );
       
    51 
       
    52 // FORWARD DECLARATIONS
       
    53 //class ?FORWARD_CLASSNAME;
       
    54 
       
    55 // ============================ MEMBER FUNCTIONS ===============================
       
    56 
       
    57 // -----------------------------------------------------------------------------
       
    58 // ?classname::?member_function
       
    59 // ?implementation_description
       
    60 // (other items were commented in a header).
       
    61 // -----------------------------------------------------------------------------
       
    62 //
       
    63 EXPORT_C void TraceHeap::CreateL(const TUint aDefaultMask)
       
    64     {
       
    65     // check that the heap is not already created
       
    66 	if ( TraceHeap::iTraceHeap )
       
    67 	    {
       
    68 	    return;
       
    69 	    }
       
    70 	    
       
    71 	// create a heap private to the owning process (heap can also be created as global)
       
    72 	TraceHeap::iTraceHeap = UserHeap::ChunkHeap( NULL, KMinHeapSize, KMinHeapSize, KMinHeapGrowBy );
       
    73 	__ASSERT_ALWAYS( TraceHeap::iTraceHeap, User::Leave(KErrGeneral));
       
    74 	
       
    75 	// create iTrace... variables
       
    76 	TraceHeap::iTraceMask = (TUint32*)TraceHeap::iTraceHeap->AllocL( sizeof(TUint32) );
       
    77 	*TraceHeap::iTraceMask = aDefaultMask;
       
    78     TraceHeap::iTraceLevel = (TUint32*)TraceHeap::iTraceHeap->AllocL( sizeof(TUint32) );
       
    79 	*TraceHeap::iTraceLevel = 0;		
       
    80     TraceHeap::iApiOnly = (TBool*)TraceHeap::iTraceHeap->AllocL( sizeof(TBool) );
       
    81 	*TraceHeap::iApiOnly = EFalse;		
       
    82     }
       
    83 
       
    84 // -----------------------------------------------------------------------------
       
    85 // ?classname::?member_function
       
    86 // ?implementation_description
       
    87 // (other items were commented in a header).
       
    88 // -----------------------------------------------------------------------------
       
    89 //
       
    90 EXPORT_C TUint32 TraceHeap::TraceMask()
       
    91 	{
       
    92 	return *TraceHeap::iTraceMask;
       
    93 	}
       
    94 
       
    95 // -----------------------------------------------------------------------------
       
    96 // ?classname::?member_function
       
    97 // ?implementation_description
       
    98 // (other items were commented in a header).
       
    99 // -----------------------------------------------------------------------------
       
   100 //
       
   101 EXPORT_C void TraceHeap::SetTraceMask(
       
   102 	const TUint32 aTraceMask )
       
   103 	{
       
   104     if ( !TraceHeap::iTraceHeap )
       
   105         {
       
   106         TRAP_IGNORE(TraceHeap::CreateL());   
       
   107         }
       
   108 	*TraceHeap::iTraceMask = aTraceMask;
       
   109 	}
       
   110 
       
   111 // -----------------------------------------------------------------------------
       
   112 // ?classname::?member_function
       
   113 // ?implementation_description
       
   114 // (other items were commented in a header).
       
   115 // -----------------------------------------------------------------------------
       
   116 //
       
   117 EXPORT_C TBool TraceHeap::IsMaskOn(
       
   118 	const TUint32 aMask )
       
   119 	{
       
   120 	return ( *TraceHeap::iTraceMask & aMask );
       
   121 	}
       
   122 
       
   123 // -----------------------------------------------------------------------------
       
   124 // ?classname::?member_function
       
   125 // ?implementation_description
       
   126 // (other items were commented in a header).
       
   127 // -----------------------------------------------------------------------------
       
   128 //
       
   129 EXPORT_C void TraceHeap::SetLevel( const TUint32 aTraceLevel )
       
   130     {
       
   131     *TraceHeap::iTraceLevel = aTraceLevel;
       
   132     }
       
   133     
       
   134 // -----------------------------------------------------------------------------
       
   135 // ?classname::?member_function
       
   136 // ?implementation_description
       
   137 // (other items were commented in a header).
       
   138 // -----------------------------------------------------------------------------
       
   139 //    
       
   140 EXPORT_C TBool TraceHeap::IsBelowLevel( const TUint32 aLevel )
       
   141     {
       
   142     return (*TraceHeap::iTraceLevel > aLevel);
       
   143     }
       
   144     
       
   145 // -----------------------------------------------------------------------------
       
   146 // ?classname::?member_function
       
   147 // ?implementation_description
       
   148 // (other items were commented in a header).
       
   149 // -----------------------------------------------------------------------------
       
   150 //    
       
   151 EXPORT_C TUint32 TraceHeap::TraceLevel()
       
   152     {
       
   153     return *TraceHeap::iTraceLevel;
       
   154     }
       
   155     
       
   156 // -----------------------------------------------------------------------------
       
   157 // ?classname::?member_function
       
   158 // ?implementation_description
       
   159 // (other items were commented in a header).
       
   160 // -----------------------------------------------------------------------------
       
   161 //    
       
   162 EXPORT_C TBool TraceHeap::IsApiOnly()
       
   163     {
       
   164     return *iApiOnly;
       
   165     }
       
   166 
       
   167 // -----------------------------------------------------------------------------
       
   168 // ?classname::?member_function
       
   169 // ?implementation_description
       
   170 // (other items were commented in a header).
       
   171 // -----------------------------------------------------------------------------
       
   172 //    
       
   173 EXPORT_C void TraceHeap::SetApiOnly( const TBool aApiOnly)
       
   174     {
       
   175     *iApiOnly = aApiOnly;
       
   176     }
       
   177 
       
   178 //  End of File  
       
   179