sysanadatacapture/piprofiler/piprofiler_api/inc/SamplerPluginInterface.h
changeset 1 3ff3fecb12fe
equal deleted inserted replaced
0:f0f2b8682603 1:3ff3fecb12fe
       
     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:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __SAMPLER_PLUGIN_INTERFACE__
       
    20 #define __SAMPLER_PLUGIN_INTERFACE__
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <ecom/ECom.h>
       
    24 #include <badesca.h>
       
    25 #include <piprofiler/ProfilerAttributes.h>	// internal settings format presentations 
       
    26 
       
    27 
       
    28 // Constant for indexing (iOrder):
       
    29 const TInt KSamplerPluginNotIndexed      = -1;
       
    30 
       
    31 /**
       
    32  * Constant:    KSamplerPluginInterfaceUid
       
    33  *
       
    34  * Description: UID of this ECOM interface. It should be unique in the system.
       
    35  *              It is used to identify this specific custom interface.
       
    36  *              Implementations of this interface will use this ID, when they
       
    37  *              publish the implementation. Clients use this UID to search for
       
    38  *              implementations for this interface (the
       
    39  *              EcomInterfaceDefinition.inl does this).
       
    40  */
       
    41 const TUid KSamplerPluginInterfaceUid = {0x2001E5BC};
       
    42 
       
    43 /**
       
    44  *
       
    45  * Description: UID of this ECOM interface. It should be unique in the system.
       
    46  *
       
    47  */
       
    48 enum TGenericSettingTypes
       
    49 {
       
    50 	EEnablePlugin,
       
    51 	EOutputSettings,
       
    52 	ESaveDrive,
       
    53 	EFilePrefix,
       
    54 	ETracingMode
       
    55 };
       
    56 
       
    57 
       
    58 enum TSamplerCaptionTypes
       
    59 	{
       
    60 	ECaptionLengthShort,
       
    61 	ECaptionLengthMedium,
       
    62 	ECaptionLengthLong,
       
    63     ESettingsCaption
       
    64 	};
       
    65 
       
    66 
       
    67 /**
       
    68 * Used by GetValue(). These are the keys for retrieving a specific
       
    69 * value. This enum can be extended to provide other values as well as
       
    70 * long as the original keys are not changed.
       
    71 */
       
    72 enum TSamplerPluginValueKeys
       
    73     {
       
    74 
       
    75     ESamplerPluginKeySettingsItemValueString = 1,
       
    76     ESamplerPluginSettings,
       
    77     ESamplerPluginEnabled,
       
    78     ESamplerPluginDisabled,
       
    79     ESamplerPluginType,
       
    80     ESamplerPluginVersion
       
    81     };
       
    82  
       
    83 
       
    84 /**
       
    85  * Class:       CSamplerInterfaceDefinition
       
    86  *
       
    87  * Description: Custom ECOM interface definition. This interface is used by
       
    88  *              clients to find specific instance and do corresponding
       
    89  *              calculation operation for given too numbers. Plugin
       
    90  *              implementations implement the Calculate function.
       
    91  */
       
    92 class TBapBuf;
       
    93 class CProfilerSampleStream;
       
    94 
       
    95 class CSamplerPluginInterface : public CBase 
       
    96 {
       
    97 
       
    98     // CSamplerPluginLoader accesses iOrder which should not be accessed outside.
       
    99     friend class CSamplerPluginLoader;
       
   100 
       
   101 public: 
       
   102 	// Wrapper functions to handle ECOM "connectivity".
       
   103     // These are implemented in EComInterfaceDefinition.inl.
       
   104     // These functions are used only by the client.
       
   105     
       
   106 	/**
       
   107      * Function:   NewL
       
   108      *
       
   109      * Description: Wraps ECom object instantitation. Will search for
       
   110      *              interface implementation, which matches to given
       
   111      *              aOperationName.
       
   112      *
       
   113      * Param:       aOperationName name of requested implementation.
       
   114      *              Implementations advertise their "name" as specified
       
   115      *              in their resource file field
       
   116      *                 IMPLEMENTATION_INFO::default_data.
       
   117      *              For details, see EcomInterfaceDefinition.inl comments.
       
   118      *              In this example, the allowed values are "sum" and
       
   119      *              "multiply".
       
   120      *
       
   121      * Note:        This is not a "normal" NewL method, since normally NewL
       
   122      *              methods are only defined for concrete classes.
       
   123      *              Note that also implementations of this interface provide
       
   124      *              NewL methods. They are the familiar NewL's, which create
       
   125      *              instance of classes.
       
   126      */
       
   127     static CSamplerPluginInterface* NewL(const TUid aImplementationUid, TAny* aInitParams);
       
   128 
       
   129     /**
       
   130      * Function:   ~CSamplerPluginInterface
       
   131      *
       
   132      * Description: Wraps ECom object destruction. Notifies the ECOM
       
   133      *              framework that specific instance is being destroyed.
       
   134      *              See EcomInterfaceDefinition.inl for details.
       
   135      */
       
   136     virtual ~CSamplerPluginInterface();
       
   137 protected: // New
       
   138 
       
   139 	/**
       
   140 	* C++ constructor.
       
   141 	*/
       
   142 	CSamplerPluginInterface();
       
   143         
       
   144 public: 
       
   145 	// Public pure virtual functions, which are implemented by
       
   146     // interface implementations (See ..\plugin)
       
   147     
       
   148     /**
       
   149      * Method for initializing and starting of profiling in single plugin implementation
       
   150      * @param aStream is a data stream to store the gathered data, provided by engine
       
   151      * @return TInt if no error KErrNone, else any of system-wide errors
       
   152      */
       
   153 	virtual TInt	ResetAndActivateL(CProfilerSampleStream& aStream) = 0;
       
   154 
       
   155 	/**
       
   156      * Method for stopping of profiling in single plugin implementation
       
   157      * @return TInt if no error KErrNone, else any of system-wide errors
       
   158      */
       
   159 	virtual TInt	StopSampling() = 0;
       
   160     /**
       
   161      * Method for checking if plugin is enabled
       
   162      * @return TBool if enabled return ETrue else EFalse
       
   163      */
       
   164     virtual TBool   Enabled() = 0;
       
   165  	
       
   166     /**
       
   167     * Method for getting an array of sampler attributes, size of an array: 1...n
       
   168     * @return array of settings of one or several sampler plugins
       
   169     */
       
   170     virtual void GetAttributesL(CArrayFixFlat<TSamplerAttributes>* aAttributeArray) = 0;	
       
   171     
       
   172     /**
       
   173     * Method for setting configurations of single sampler attributes
       
   174     * @param aAttributes contains settings of a single sampler plugin 
       
   175     */
       
   176     virtual TInt SetAttributesL(TSamplerAttributes aAttributes) = 0; 
       
   177     
       
   178     /**
       
   179     * Method for parsing text formatted settings block and converting
       
   180     * it to TSamplerAttributes data structure
       
   181     * @param aSingleSettingArray containing setting lines of a single sampler
       
   182     * @return status of conversion, if success KErrNone, else KErrGeneral
       
   183     */
       
   184     virtual TInt ConvertRawSettingsToAttributes(CDesC8ArrayFlat* aSingleSettingArray) = 0;
       
   185  
       
   186     /**
       
   187     * Method for getting caption of this plugin. This should be the
       
   188     * localized name of the settings view to be shown in parent view.
       
   189     * @param aCaption pointer to Caption variable
       
   190     * @param aType caption type; ECaptionLengthShort, ECaptionLengthMedium or ECaptionLengthLong
       
   191     * @param aSubId sub sampler id, if -1 returning main plugin's caption
       
   192     */
       
   193     virtual void 	GetCaption( TDes& aCaption, TInt aType, TInt aSubId) const = 0;
       
   194      
       
   195     /**
       
   196     * Method for getting UID of this plugin.
       
   197     * @param aSubId the implementation id of sub sampler
       
   198     * @returns uid of sampler or sub sampler, if aSubId -1 uid of sampler, else uid of sub sampler
       
   199     */
       
   200     virtual TUid 	Id(TInt aSubId) const = 0;
       
   201     
       
   202     /**
       
   203     * Method for getting locally defined sub ID value inside a specific plug-in.
       
   204     * @param aUid of a specific sampler
       
   205     * @returns local ID of sampler or sub sampler
       
   206     */
       
   207     virtual TInt 	SubId(TUid aUid) const = 0;
       
   208     
       
   209     // subsampler settings, i.e. samplers implemented within a plugin
       
   210     virtual TInt 	GetSamplerUidByName(TDesC8& name) = 0;
       
   211     
       
   212     // sampler type
       
   213     virtual TInt 	GetSamplerType() = 0;
       
   214 	 
       
   215 	 
       
   216 	 // some internal inline methods, used by engine
       
   217     inline TInt     Flush();
       
   218     inline TInt     AddSample(TUint8* sample, TUint32 length, TInt limitSize);  
       
   219     inline void     SetOrder( TInt aOrder );
       
   220     inline static void ListAllImplementationsL(RImplInfoPtrArray& aImplInfoArray);
       
   221 
       
   222     /**
       
   223     * Static methods for getting setting value out of descriptor
       
   224     * 
       
   225     * @param aBuf buffer where to convert the value
       
   226     * @param aValue parameter where to store the requested type of value
       
   227     */
       
   228     inline static void     Str2Bool(const TDesC8& aBuf, TBool& aValue);
       
   229     inline static void     Str2Int(const TDesC8& aBuf, TInt& aValue);
       
   230     inline static void     Str2Int(const TDesC8& aBuf, TUint32& aValue);
       
   231      
       
   232     /** iDtor_ID_Key Instance identifier key. When instance of an
       
   233      *               implementation is created by ECOM framework, the
       
   234      *               framework will assign UID for it. The UID is used in
       
   235      *               destructor to notify framework that this instance is
       
   236      *               being destroyed and resources can be released.
       
   237      */
       
   238     TUid iDtor_ID_Key;
       
   239     
       
   240     /**
       
   241 	* Index of the plugin in listbox. Used for CSamplerPluginLoader. Default
       
   242 	* value is KSamplerPluginNotIndexed which means not ordered. This value is
       
   243 	* read, if defined, from the opaque_data field of the plugin's resource
       
   244 	* definition. Index starts from 0.
       
   245 	*/
       
   246 	TInt iOrder;
       
   247 
       
   248 public:	    
       
   249 	TInt 					iSamplerType;
       
   250 	
       
   251 	// this variable must be defined by the extending classes!!
       
   252 	TInt					iSamplerId;
       
   253 	
       
   254 	CProfilerSampleStream*	iStream;
       
   255     TBool                   iEnabled;
       
   256 		
       
   257 private:
       
   258 	TBapBuf*				iBuffer;
       
   259 };
       
   260 
       
   261 #include <piprofiler/ProfilerGenericClassesUsr.h>
       
   262 #include <piprofiler/SamplerPluginInterface.inl>
       
   263 
       
   264 
       
   265 #endif // __SAMPLER_PLUGIN_INTERFACE__