sysanadatacapture/piprofiler/piprofiler_api/inc/SamplerPluginInterface.inl
author Matti Laitinen <matti.t.laitinen@nokia.com>
Thu, 11 Feb 2010 15:52:57 +0200
changeset 1 3ff3fecb12fe
permissions -rw-r--r--
Add initial version of PI Profiler under EPL
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
     1
/*
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
     8
*
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    11
*
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    12
* Contributors:
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    13
*
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    14
* Description:  
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    15
*
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    16
*/
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    17
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    18
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    19
// LITERALS
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    20
_LIT8(KTrue, "true");
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    21
_LIT8(KFalse, "false");
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    22
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    23
inline CSamplerPluginInterface::CSamplerPluginInterface()
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    24
    : iOrder( KSamplerPluginNotIndexed )
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    25
    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    26
    iBuffer = 0;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    27
    iStream = 0;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    28
    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    29
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    30
// -----------------------------------------------------------------------------
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    31
// CSamplerPluginInterface::~CSamplerPluginInterface()
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    32
// Destructor.
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    33
// -----------------------------------------------------------------------------
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    34
//
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    35
inline CSamplerPluginInterface::~CSamplerPluginInterface()
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    36
    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    37
    iBuffer = 0;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    38
    REComSession::DestroyedImplementation(iDtor_ID_Key);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    39
    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    40
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    41
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    42
inline CSamplerPluginInterface* CSamplerPluginInterface::NewL(const TUid aImplementationUid, TAny* aInitParams)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    43
    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    44
    // Define options, how the default resolver will find appropriate
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    45
    // implementation.
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    46
    return REINTERPRET_CAST(CSamplerPluginInterface*, 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    47
                            REComSession::CreateImplementationL(aImplementationUid,
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    48
                                                                _FOFF( CSamplerPluginInterface, iDtor_ID_Key ),
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    49
                                                                aInitParams)); 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    50
    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    51
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    52
inline void CSamplerPluginInterface::ListAllImplementationsL(RImplInfoPtrArray& aImplInfoArray)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    53
    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    54
    REComSession::ListImplementationsL(KSamplerPluginInterfaceUid, aImplInfoArray);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    55
    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    56
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    57
inline void CSamplerPluginInterface::SetOrder( TInt aOrder )
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    58
    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    59
    iOrder = aOrder;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    60
    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    61
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    62
inline TInt CSamplerPluginInterface::Flush() 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    63
    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    64
	// complete the header
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    65
	TUint32 header;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    66
	header = (iBuffer->iDataSize & 0x00ffffff) - 4;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    67
	header += (iSamplerId << 24);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    68
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    69
	// flush the header info
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    70
	iBuffer->iBuffer[0] = header;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    71
	iBuffer->iBuffer[1] = header >> 8;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    72
	iBuffer->iBuffer[2] = header >> 16;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    73
	iBuffer->iBuffer[3] = header >> 24;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    74
	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    75
    // write data to filled buffers
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    76
    iStream->AddToFilledBuffers(iBuffer);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    77
    // notify selected writer plugin to write data to output
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    78
    iStream->NotifyWriter();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    79
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    80
    iBuffer = 0;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    81
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    82
	return KErrNone;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    83
}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    84
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    85
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    86
inline TInt CSamplerPluginInterface::AddSample(TUint8* aSample, TUint32 aLength, TInt aLimitSize)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    87
    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    88
    LOGTEXT(_L("CSamplerPluginInterface::AddSample - entry"));
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    89
	if(iBuffer == 0) 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    90
	    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    91
	    // get next free buffer where to write data
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    92
		iBuffer = iStream->GetNextFreeBuffer();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    93
		iBuffer->iBufDes->Zero();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    94
		
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    95
		// get space for the header
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    96
		TUint32 header = 0;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    97
		iBuffer->iBufDes->Append((TUint8*)&header, 4);	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    98
		iBuffer->iDataSize += 4;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    99
	    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   100
		
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   101
	// add data to the buffer...
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   102
	// if all data fit to the current buffer
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   103
	if(iBuffer->iBufferSize - iBuffer->iDataSize >= (TInt)aLength)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   104
	    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   105
		iBuffer->iBufDes->Append(aSample, (TInt)aLength);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   106
		iBuffer->iDataSize += (TInt)aLength;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   107
	    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   108
	else 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   109
	    {	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   110
		// fill in the buffer
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   111
		TUint32 rest = iBuffer->iBufferSize - iBuffer->iDataSize;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   112
		iBuffer->iBufDes->Append(aSample, rest);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   113
		iBuffer->iDataSize += (TInt)rest;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   114
		
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   115
		// The buffer is full now, complete the header
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   116
		TUint32 header;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   117
		header = (iBuffer->iDataSize & 0x00ffffff) - 4;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   118
		header += (iSamplerId << 24);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   119
		iBuffer->iBuffer[0] = header;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   120
		iBuffer->iBuffer[1] = header >> 8;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   121
		iBuffer->iBuffer[2] = header >> 16;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   122
		iBuffer->iBuffer[3] = header >> 24;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   123
		
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   124
		// write data to filled buffers
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   125
		iStream->AddToFilledBuffers(iBuffer);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   126
	    // notify selected writer plugin to write data to output
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   127
	    iStream->NotifyWriter();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   128
		
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   129
		// Fetch an empty buffer and reserve space for the header
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   130
		iBuffer = iStream->GetNextFreeBuffer();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   131
		iBuffer->iBufDes->Zero();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   132
		header = 0;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   133
		iBuffer->iBufDes->Append((TUint8*)&header, 4);	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   134
		iBuffer->iDataSize += 4;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   135
			
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   136
		// copy the rest of data to the new buffer
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   137
		iBuffer->iBufDes->Append(aSample+rest, aLength-rest);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   138
		iBuffer->iDataSize += (TInt)aLength-rest;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   139
	    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   140
	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   141
	// Once iBuffer->dataSize reaches the limitSize, data from iBuffer is flushed to file/debug port.
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   142
	// If limitSize is set to zero, buffer is not changed until iBuffer gets full.
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   143
	if(aLimitSize != 0) 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   144
	    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   145
		if(iBuffer->iDataSize >= aLimitSize) 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   146
		    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   147
			// The buffer is full now, complete the header
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   148
			TUint32 header;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   149
			header = (iBuffer->iDataSize & 0x00ffffff) - 4;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   150
			header += (iSamplerId << 24);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   151
			iBuffer->iBuffer[0] = header;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   152
			iBuffer->iBuffer[1] = header >> 8;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   153
			iBuffer->iBuffer[2] = header >> 16;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   154
			iBuffer->iBuffer[3] = header >> 24;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   155
	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   156
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   157
            // write data to filled buffers
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   158
            iStream->AddToFilledBuffers(iBuffer);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   159
            // notify selected writer plugin to write data to output
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   160
            iStream->NotifyWriter();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   161
		    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   162
			// Fetch an empty buffer and reserve space for the header
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   163
			iBuffer = iStream->GetNextFreeBuffer();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   164
			iBuffer->iBufDes->Zero();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   165
			header = 0;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   166
			iBuffer->iBufDes->Append((TUint8*)&header, 4);	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   167
			iBuffer->iDataSize += 4;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   168
		    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   169
	    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   170
	return KErrNone;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   171
    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   172
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   173
// ----------------------------------------------------------------------------
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   174
// Converts given descriptor into TBool value.
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   175
// ----------------------------------------------------------------------------
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   176
//
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   177
inline void CSamplerPluginInterface::Str2Bool(const TDesC8& aBuf, TBool& aValue)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   178
    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   179
    if (aBuf.CompareF(KFalse) == 0)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   180
        aValue = EFalse;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   181
    else
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   182
        aValue = ETrue;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   183
    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   184
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   185
// ----------------------------------------------------------------------------
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   186
// Converts given descriptor into TInt value.
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   187
// ----------------------------------------------------------------------------
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   188
//
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   189
inline void CSamplerPluginInterface::Str2Int(const TDesC8& aBuf, TInt& aValue)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   190
    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   191
    TLex8 conv;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   192
    conv.Assign(aBuf);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   193
    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   194
    if (conv.Val(aValue) != KErrNone)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   195
        aValue = 0;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   196
    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   197
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   198
// ----------------------------------------------------------------------------
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   199
// Converts given descriptor into TInt value.
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   200
// ----------------------------------------------------------------------------
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   201
//
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   202
inline void CSamplerPluginInterface::Str2Int(const TDesC8& aBuf, TUint32& aValue)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   203
    {
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   204
    TInt temp(0);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   205
    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   206
    TLex8 conv;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   207
    conv.Assign(aBuf);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   208
    
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   209
    if (conv.Val(temp) != KErrNone)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   210
        aValue = 0;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   211
    else
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   212
        aValue = (TUint32)temp;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   213
    }
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   214
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   215
// End of file