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