os/mm/devsound/a3ftrace/src/a3f_trace_heap.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
sl@0
    17
sl@0
    18
sl@0
    19
// INCLUDE FILES
sl@0
    20
#include <e32std.h>
sl@0
    21
#include <e32svr.h>
sl@0
    22
#include "a3f_trace_heap.h"
sl@0
    23
sl@0
    24
// EXTERNAL DATA STRUCTURES
sl@0
    25
//extern  ?external_data;
sl@0
    26
TUint32* 	TraceHeap::iTraceMask = NULL;
sl@0
    27
TUint32* 	TraceHeap::iTraceLevel = NULL;
sl@0
    28
TBool*      TraceHeap::iApiOnly = NULL;
sl@0
    29
RHeap* 		TraceHeap::iTraceHeap = NULL;
sl@0
    30
sl@0
    31
sl@0
    32
// EXTERNAL FUNCTION PROTOTYPES  
sl@0
    33
//extern ?external_function( ?arg_type,?arg_type );
sl@0
    34
sl@0
    35
// CONSTANTS
sl@0
    36
//const ?type ?constant_var = ?constant;
sl@0
    37
sl@0
    38
// MACROS
sl@0
    39
//#define ?macro ?macro_def
sl@0
    40
sl@0
    41
// LOCAL CONSTANTS AND MACROS
sl@0
    42
//const ?type ?constant_var = ?constant;
sl@0
    43
//#define ?macro_name ?macro_def
sl@0
    44
sl@0
    45
// MODULE DATA STRUCTURES
sl@0
    46
//enum ?declaration
sl@0
    47
//typedef ?declaration
sl@0
    48
sl@0
    49
// LOCAL FUNCTION PROTOTYPES
sl@0
    50
//?type ?function_name( ?arg_type, ?arg_type );
sl@0
    51
sl@0
    52
// FORWARD DECLARATIONS
sl@0
    53
//class ?FORWARD_CLASSNAME;
sl@0
    54
sl@0
    55
// ============================ MEMBER FUNCTIONS ===============================
sl@0
    56
sl@0
    57
// -----------------------------------------------------------------------------
sl@0
    58
// ?classname::?member_function
sl@0
    59
// ?implementation_description
sl@0
    60
// (other items were commented in a header).
sl@0
    61
// -----------------------------------------------------------------------------
sl@0
    62
//
sl@0
    63
EXPORT_C void TraceHeap::CreateL(const TUint aDefaultMask)
sl@0
    64
    {
sl@0
    65
    // check that the heap is not already created
sl@0
    66
	if ( TraceHeap::iTraceHeap )
sl@0
    67
	    {
sl@0
    68
	    return;
sl@0
    69
	    }
sl@0
    70
	    
sl@0
    71
	// create a heap private to the owning process (heap can also be created as global)
sl@0
    72
	TraceHeap::iTraceHeap = UserHeap::ChunkHeap( NULL, KMinHeapSize, KMinHeapSize, KMinHeapGrowBy );
sl@0
    73
	__ASSERT_ALWAYS( TraceHeap::iTraceHeap, User::Leave(KErrGeneral));
sl@0
    74
	
sl@0
    75
	// create iTrace... variables
sl@0
    76
	TraceHeap::iTraceMask = (TUint32*)TraceHeap::iTraceHeap->AllocL( sizeof(TUint32) );
sl@0
    77
	*TraceHeap::iTraceMask = aDefaultMask;
sl@0
    78
    TraceHeap::iTraceLevel = (TUint32*)TraceHeap::iTraceHeap->AllocL( sizeof(TUint32) );
sl@0
    79
	*TraceHeap::iTraceLevel = 0;		
sl@0
    80
    TraceHeap::iApiOnly = (TBool*)TraceHeap::iTraceHeap->AllocL( sizeof(TBool) );
sl@0
    81
	*TraceHeap::iApiOnly = EFalse;		
sl@0
    82
    }
sl@0
    83
sl@0
    84
// -----------------------------------------------------------------------------
sl@0
    85
// ?classname::?member_function
sl@0
    86
// ?implementation_description
sl@0
    87
// (other items were commented in a header).
sl@0
    88
// -----------------------------------------------------------------------------
sl@0
    89
//
sl@0
    90
EXPORT_C TUint32 TraceHeap::TraceMask()
sl@0
    91
	{
sl@0
    92
	return *TraceHeap::iTraceMask;
sl@0
    93
	}
sl@0
    94
sl@0
    95
// -----------------------------------------------------------------------------
sl@0
    96
// ?classname::?member_function
sl@0
    97
// ?implementation_description
sl@0
    98
// (other items were commented in a header).
sl@0
    99
// -----------------------------------------------------------------------------
sl@0
   100
//
sl@0
   101
EXPORT_C void TraceHeap::SetTraceMask(
sl@0
   102
	const TUint32 aTraceMask )
sl@0
   103
	{
sl@0
   104
    if ( !TraceHeap::iTraceHeap )
sl@0
   105
        {
sl@0
   106
        TRAP_IGNORE(TraceHeap::CreateL());   
sl@0
   107
        }
sl@0
   108
	*TraceHeap::iTraceMask = aTraceMask;
sl@0
   109
	}
sl@0
   110
sl@0
   111
// -----------------------------------------------------------------------------
sl@0
   112
// ?classname::?member_function
sl@0
   113
// ?implementation_description
sl@0
   114
// (other items were commented in a header).
sl@0
   115
// -----------------------------------------------------------------------------
sl@0
   116
//
sl@0
   117
EXPORT_C TBool TraceHeap::IsMaskOn(
sl@0
   118
	const TUint32 aMask )
sl@0
   119
	{
sl@0
   120
	return ( *TraceHeap::iTraceMask & aMask );
sl@0
   121
	}
sl@0
   122
sl@0
   123
// -----------------------------------------------------------------------------
sl@0
   124
// ?classname::?member_function
sl@0
   125
// ?implementation_description
sl@0
   126
// (other items were commented in a header).
sl@0
   127
// -----------------------------------------------------------------------------
sl@0
   128
//
sl@0
   129
EXPORT_C void TraceHeap::SetLevel( const TUint32 aTraceLevel )
sl@0
   130
    {
sl@0
   131
    *TraceHeap::iTraceLevel = aTraceLevel;
sl@0
   132
    }
sl@0
   133
    
sl@0
   134
// -----------------------------------------------------------------------------
sl@0
   135
// ?classname::?member_function
sl@0
   136
// ?implementation_description
sl@0
   137
// (other items were commented in a header).
sl@0
   138
// -----------------------------------------------------------------------------
sl@0
   139
//    
sl@0
   140
EXPORT_C TBool TraceHeap::IsBelowLevel( const TUint32 aLevel )
sl@0
   141
    {
sl@0
   142
    return (*TraceHeap::iTraceLevel > aLevel);
sl@0
   143
    }
sl@0
   144
    
sl@0
   145
// -----------------------------------------------------------------------------
sl@0
   146
// ?classname::?member_function
sl@0
   147
// ?implementation_description
sl@0
   148
// (other items were commented in a header).
sl@0
   149
// -----------------------------------------------------------------------------
sl@0
   150
//    
sl@0
   151
EXPORT_C TUint32 TraceHeap::TraceLevel()
sl@0
   152
    {
sl@0
   153
    return *TraceHeap::iTraceLevel;
sl@0
   154
    }
sl@0
   155
    
sl@0
   156
// -----------------------------------------------------------------------------
sl@0
   157
// ?classname::?member_function
sl@0
   158
// ?implementation_description
sl@0
   159
// (other items were commented in a header).
sl@0
   160
// -----------------------------------------------------------------------------
sl@0
   161
//    
sl@0
   162
EXPORT_C TBool TraceHeap::IsApiOnly()
sl@0
   163
    {
sl@0
   164
    return *iApiOnly;
sl@0
   165
    }
sl@0
   166
sl@0
   167
// -----------------------------------------------------------------------------
sl@0
   168
// ?classname::?member_function
sl@0
   169
// ?implementation_description
sl@0
   170
// (other items were commented in a header).
sl@0
   171
// -----------------------------------------------------------------------------
sl@0
   172
//    
sl@0
   173
EXPORT_C void TraceHeap::SetApiOnly( const TBool aApiOnly)
sl@0
   174
    {
sl@0
   175
    *iApiOnly = aApiOnly;
sl@0
   176
    }
sl@0
   177
sl@0
   178
//  End of File  
sl@0
   179