piprofiler/engine/inc/SamplerController.h
author hgs
Fri, 27 Aug 2010 11:37:29 +0300
changeset 42 0ff24a8f6ca2
parent 20 a71a3e32a2ae
child 49 7fdc9a71d314
permissions -rw-r--r--
201033
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
20
hgs
parents:
diff changeset
     1
/*
hgs
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
hgs
parents:
diff changeset
     3
* All rights reserved.
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
hgs
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
hgs
parents:
diff changeset
     8
*
hgs
parents:
diff changeset
     9
* Initial Contributors:
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
hgs
parents:
diff changeset
    11
*
hgs
parents:
diff changeset
    12
* Contributors:
hgs
parents:
diff changeset
    13
*
hgs
parents:
diff changeset
    14
* Description:  
hgs
parents:
diff changeset
    15
*
hgs
parents:
diff changeset
    16
*/
hgs
parents:
diff changeset
    17
hgs
parents:
diff changeset
    18
hgs
parents:
diff changeset
    19
#ifndef __SAMPLERCONTROLLER_H__
hgs
parents:
diff changeset
    20
#define __SAMPLERCONTROLLER_H__
hgs
parents:
diff changeset
    21
hgs
parents:
diff changeset
    22
// system includes
hgs
parents:
diff changeset
    23
#include <utf.h>
hgs
parents:
diff changeset
    24
#include <e32cmn.h>
hgs
parents:
diff changeset
    25
hgs
parents:
diff changeset
    26
hgs
parents:
diff changeset
    27
// The user-interface to the sampling device driver sued by the profiling engine
hgs
parents:
diff changeset
    28
// user includes
hgs
parents:
diff changeset
    29
#include <piprofiler/ProfilerConfig.h>
hgs
parents:
diff changeset
    30
#include <piprofiler/ProfilerVersion.h>
hgs
parents:
diff changeset
    31
#include <piprofiler/SamplerPluginInterface.h>
hgs
parents:
diff changeset
    32
hgs
parents:
diff changeset
    33
#include "SamplerPluginLoader.h"
hgs
parents:
diff changeset
    34
hgs
parents:
diff changeset
    35
/*
hgs
parents:
diff changeset
    36
 *	Forward declarations
hgs
parents:
diff changeset
    37
 */
hgs
parents:
diff changeset
    38
class TBapBuf;
hgs
parents:
diff changeset
    39
class CProfilerSampleStream;
hgs
parents:
diff changeset
    40
class CSamplerPluginLoader;
hgs
parents:
diff changeset
    41
class CSamplerPluginInterface;
hgs
parents:
diff changeset
    42
class MSamplerControllerObserver;
hgs
parents:
diff changeset
    43
/**
hgs
parents:
diff changeset
    44
 * The sampler controller for handling the actual sampler plugins.
hgs
parents:
diff changeset
    45
 */
hgs
parents:
diff changeset
    46
hgs
parents:
diff changeset
    47
class CSamplerController : public CBase, MSamplerPluginLoadObserver
hgs
parents:
diff changeset
    48
	{
hgs
parents:
diff changeset
    49
	
hgs
parents:
diff changeset
    50
public:
hgs
parents:
diff changeset
    51
	static CSamplerController* NewL(CProfilerSampleStream& aStream);
hgs
parents:
diff changeset
    52
	void ConstructL();
hgs
parents:
diff changeset
    53
	
hgs
parents:
diff changeset
    54
	CSamplerController(CProfilerSampleStream& aStream);
hgs
parents:
diff changeset
    55
	~CSamplerController();
hgs
parents:
diff changeset
    56
	
hgs
parents:
diff changeset
    57
	/** 
hgs
parents:
diff changeset
    58
	 * 
hgs
parents:
diff changeset
    59
	 * Methods for user mode sampling
hgs
parents:
diff changeset
    60
	 * 
hgs
parents:
diff changeset
    61
	 **/
hgs
parents:
diff changeset
    62
	
hgs
parents:
diff changeset
    63
	/** Initialise the user mode samplers **/					
hgs
parents:
diff changeset
    64
	void InitialiseSamplerListL();
hgs
parents:
diff changeset
    65
		 
hgs
parents:
diff changeset
    66
	/* Overrider of MSamplerPluginLoaderObserver class **/
hgs
parents:
diff changeset
    67
	void HandlePluginLoaded( KSamplerPluginLoaderStatus aStatus );
hgs
parents:
diff changeset
    68
	
hgs
parents:
diff changeset
    69
	/* returns the name matching plugin Uid */
hgs
parents:
diff changeset
    70
	TUid GetPluginUID(TDesC8& name);
hgs
parents:
diff changeset
    71
hgs
parents:
diff changeset
    72
	/** Start enabled samplers **/				
hgs
parents:
diff changeset
    73
	void StartSamplerPluginsL();
hgs
parents:
diff changeset
    74
hgs
parents:
diff changeset
    75
	/** Stop enabled samplers **/				
hgs
parents:
diff changeset
    76
	TInt StopSamplerPlugins();
hgs
parents:
diff changeset
    77
hgs
parents:
diff changeset
    78
public:
hgs
parents:
diff changeset
    79
hgs
parents:
diff changeset
    80
	CSamplerPluginInterface* GetPlugin(TUid aUid);
hgs
parents:
diff changeset
    81
hgs
parents:
diff changeset
    82
	TInt GetPluginList(TDes* aList);
hgs
parents:
diff changeset
    83
	
hgs
parents:
diff changeset
    84
    TInt SetSamplerSettingsL(TInt aUid, TSamplerAttributes aAttributes);
hgs
parents:
diff changeset
    85
hgs
parents:
diff changeset
    86
    void GetSamplerAttributesL(CArrayFixFlat<TSamplerAttributes>* aAttributes);
hgs
parents:
diff changeset
    87
	
hgs
parents:
diff changeset
    88
	TInt UpdateSavedSamplerAttributesL(CDesC8ArrayFlat* aSavedLineArray, CArrayFixFlat<TSamplerAttributes>* aAttributes);
hgs
parents:
diff changeset
    89
	
hgs
parents:
diff changeset
    90
	/*
hgs
parents:
diff changeset
    91
	 * Compose all sampler (sampler or sub-sampler) attributes as text array for saving to settings file, 
hgs
parents:
diff changeset
    92
	 * called by CSamplerController (and Profiler Engine) 
hgs
parents:
diff changeset
    93
	 * 
hgs
parents:
diff changeset
    94
	 * @param aFile settings file where to write the settings 
hgs
parents:
diff changeset
    95
	 */
hgs
parents:
diff changeset
    96
	void ComposeAttributesToSettingsFileFormat(RFile& aFile, CArrayFixFlat<TSamplerAttributes>* aAttributes);
hgs
parents:
diff changeset
    97
	
hgs
parents:
diff changeset
    98
	/*
hgs
parents:
diff changeset
    99
	 * Compose all sampler (sampler or sub-sampler) attributes as text array for saving to settings file, 
hgs
parents:
diff changeset
   100
	 * called by CSamplerController (and Profiler Engine) 
hgs
parents:
diff changeset
   101
	 * 
hgs
parents:
diff changeset
   102
     * @param aFile settings file where to write the settings 
hgs
parents:
diff changeset
   103
	 * @param aAttrArray is container for saving the text to 
hgs
parents:
diff changeset
   104
	 */
hgs
parents:
diff changeset
   105
	void ComposeSettingsText(RFile& aFile, CArrayFixFlat<TSamplerAttributes>* aAttrArray);
hgs
parents:
diff changeset
   106
	
hgs
parents:
diff changeset
   107
	void SetObserver(MSamplerControllerObserver* aObserver);
hgs
parents:
diff changeset
   108
	
hgs
parents:
diff changeset
   109
	void     Str2Bool(const TDesC8& aBuf, TBool& aValue);
hgs
parents:
diff changeset
   110
    
hgs
parents:
diff changeset
   111
    void     Str2Int(const TDesC8& aBuf, TInt& aValue);
hgs
parents:
diff changeset
   112
    
hgs
parents:
diff changeset
   113
    void     Str2Int(const TDesC8& aBuf, TUint32& aValue);
hgs
parents:
diff changeset
   114
    
hgs
parents:
diff changeset
   115
    TBuf8<16> Bool2Str(const TBool& aValue);
hgs
parents:
diff changeset
   116
    
hgs
parents:
diff changeset
   117
    TBuf8<16> Int2Str(const TInt& aValue);
hgs
parents:
diff changeset
   118
public:
hgs
parents:
diff changeset
   119
hgs
parents:
diff changeset
   120
    CArrayPtrFlat<CSamplerPluginInterface>* iPluginArray;
hgs
parents:
diff changeset
   121
    
hgs
parents:
diff changeset
   122
    // Asynchronous loader for the sampler plug-ins.
hgs
parents:
diff changeset
   123
    CSamplerPluginLoader*     iPluginLoader;
hgs
parents:
diff changeset
   124
    
hgs
parents:
diff changeset
   125
    // UID of the selected plugin in the container's lbx.
hgs
parents:
diff changeset
   126
    TUid                      iSelectedPluginUid;
hgs
parents:
diff changeset
   127
    
hgs
parents:
diff changeset
   128
    // shared sample stream for all plugin samplers
hgs
parents:
diff changeset
   129
    CProfilerSampleStream&    iStream;
hgs
parents:
diff changeset
   130
hgs
parents:
diff changeset
   131
private:
hgs
parents:
diff changeset
   132
	MSamplerControllerObserver* iObserver;
hgs
parents:
diff changeset
   133
};
hgs
parents:
diff changeset
   134
hgs
parents:
diff changeset
   135
/**
hgs
parents:
diff changeset
   136
* Interface for SamplerPluginLoader observer. MSamplerPluginLoadObserver gets
hgs
parents:
diff changeset
   137
* notifications when plugins are loaded.
hgs
parents:
diff changeset
   138
*
hgs
parents:
diff changeset
   139
* @lib ProfilerEngine.exe/.lib
hgs
parents:
diff changeset
   140
* @since Series60_30.1
hgs
parents:
diff changeset
   141
*/
hgs
parents:
diff changeset
   142
hgs
parents:
diff changeset
   143
class MSamplerControllerObserver
hgs
parents:
diff changeset
   144
    {
hgs
parents:
diff changeset
   145
    public: // New
hgs
parents:
diff changeset
   146
hgs
parents:
diff changeset
   147
        //CSamplerController calls this function when each plug-in is loaded or
hgs
parents:
diff changeset
   148
        //loading is finished..
hgs
parents:
diff changeset
   149
        
hgs
parents:
diff changeset
   150
        virtual void HandleSamplerControllerReadyL() = 0;
hgs
parents:
diff changeset
   151
        virtual void HandleError(TInt aError) = 0;
hgs
parents:
diff changeset
   152
    };
hgs
parents:
diff changeset
   153
    
hgs
parents:
diff changeset
   154
#endif	// __SAMPLERCONTROLLER_H__