piprofiler/plugins/DiskWriterPlugin/inc/DiskWriterPlugin.h
changeset 22 a009639409f5
equal deleted inserted replaced
17:67c6ff54ec25 22:a009639409f5
       
     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 __DISKWRITERPLUGIN_H__
       
    20 #define __DISKWRITERPLUGIN_H__
       
    21 
       
    22 //  Include Files
       
    23 #include <w32std.h>
       
    24 #include <piprofiler/WriterPluginInterface.h>
       
    25 #include <piprofiler/ProfilerGenericClassesUsr.h>
       
    26 #include <e32base.h>	// CBase
       
    27 #include <e32std.h>	 // TBuf
       
    28 #include <e32property.h>
       
    29 
       
    30 _LIT(KFileOutShortName, "dsw");
       
    31 
       
    32 // forward declarations
       
    33 class CDiskWriterHandler;
       
    34 class CProfilerSampleStream;
       
    35 
       
    36 //  Class Definitions
       
    37 
       
    38 class CDiskWriterPlugin : public CWriterPluginInterface
       
    39 	{
       
    40 public:
       
    41 	// new function
       
    42 	static CDiskWriterPlugin* NewL(const TUid aImplementationUid, TAny* aInitParams);
       
    43 	~CDiskWriterPlugin();
       
    44 
       
    45 	void	DoCancel();
       
    46 
       
    47 	
       
    48 public: // new functions
       
    49 	
       
    50 	TInt 	Start();
       
    51 
       
    52 	void 	Stop();
       
    53     
       
    54 	void 	GetValue( const TWriterPluginValueKeys aKey, TDes& aValue );
       
    55 	
       
    56 	void 	SetValue( const TWriterPluginValueKeys aKey, TDes& aValue ); 
       
    57     
       
    58 	TUid 	Id() const;
       
    59 		 
       
    60 	void 	GetWriterVersion(TDes* aDes);
       
    61 	
       
    62 	TUint32 GetWriterType();
       
    63 
       
    64 	void   HandleError(TInt aError);
       
    65 	
       
    66 	void   WriteData();
       
    67 	
       
    68 	void   SetStream(CProfilerSampleStream& aStream) { iStream = &aStream; }
       
    69 	
       
    70 private: // new functions
       
    71 	CDiskWriterPlugin(const TUid aImplementationUid);
       
    72 	void 	ConstructL();
       
    73 
       
    74 	void 	GetValueL( const TWriterPluginValueKeys aKey, TDes& aValue );
       
    75 	void 	SetValueL( const TWriterPluginValueKeys aKey, TDes& aValue );
       
    76     TBool   GetEnabled();
       
    77 	
       
    78 	TInt   DisplayNotifier(const TDesC& aLine1, const TDesC& aLine2, const TDesC& aButton1, const TDesC& aButton2);
       
    79 public: 
       
    80     CProfilerSampleStream*          iStream;
       
    81 private: // data
       
    82 
       
    83     TBuf<256>                       iFileName;
       
    84 	TInt 							iWriterType;
       
    85 	TInt							iWriterId;
       
    86 	CDiskWriterHandler*				iWriterHandler;
       
    87 	RProperty                       iErrorStatus;
       
    88 	};
       
    89 
       
    90 /*
       
    91  * 
       
    92  * Definition of class CDiskWriterHandler
       
    93  * 
       
    94  */
       
    95 class CDiskWriterHandler : public CActive //CBase
       
    96 	{
       
    97 public:
       
    98  
       
    99 
       
   100 	static CDiskWriterHandler* NewL(CDiskWriterPlugin* aWriter);
       
   101 	~CDiskWriterHandler();
       
   102 
       
   103 	void StartL();
       
   104 
       
   105 	void Stop();
       
   106 	void RunL();
       
   107 	TInt RunError(TInt aError);
       
   108 	
       
   109 	void DoCancel();
       
   110 	void WriteBufferToOutput(TBapBuf* aBuf);
       
   111 	void Reset();
       
   112 	   
       
   113     TInt TestFile(const TDesC& totalPrefix);
       
   114 private:
       
   115 	CDiskWriterHandler(CDiskWriterPlugin* aWriter); 
       
   116 	
       
   117 	void ConstructL();
       
   118     void WriteMemBufferToFile(TDesC8& aDes, TRequestStatus& aStatus);
       
   119 	static TInt Write(TAny* aObject);
       
   120 	void HandleFullBuffers();
       
   121 	void DoWrite();
       
   122 	
       
   123 private:
       
   124     RFile                           iFile;
       
   125     RFs                             iFs;
       
   126     TBuf<256>                       iFileName;
       
   127 	CDiskWriterPlugin* 				iWriter;
       
   128     TBapBuf*                        iBufferBeingWritten;
       
   129     TBool                           iStopping;
       
   130 	};
       
   131 
       
   132 #endif  // __DEBOUTWRITERPLUGIN_H__
       
   133