testexecfw/stf/stffw/logger/STFLoggingServer/inc/FileOutput.h
changeset 2 8bb370ba6d1d
equal deleted inserted replaced
1:bbd31066657e 2:8bb370ba6d1d
       
     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: This file contains the header file of the CFileOutput.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef FILEOUTPUT_H
       
    19 #define FILEOUTPUT_H
       
    20 
       
    21 //  INCLUDES
       
    22 #include <f32file.h>
       
    23 
       
    24 #include "Output.h"
       
    25 
       
    26 // CONSTANTS
       
    27 // None
       
    28 
       
    29 // MACROS
       
    30 // None
       
    31 
       
    32 // DATA TYPES
       
    33 // None
       
    34 
       
    35 // FUNCTION PROTOTYPES
       
    36 // None
       
    37 
       
    38 // FORWARD DECLARATIONS
       
    39 // None
       
    40 
       
    41 // CLASS DECLARATION
       
    42 
       
    43 // DESCRIPTION
       
    44 // CFileOutput is a STIF Test Framework StifLoggerBase class.
       
    45 // Class contains a file logging operations.
       
    46 class CFileOutput 
       
    47             :public COutput
       
    48     {
       
    49     public:     // Enumerations
       
    50 
       
    51     private:    // Enumerations
       
    52 
       
    53     public:     // Constructors and destructor
       
    54 
       
    55         /**
       
    56         * Two-phased constructor.
       
    57         */
       
    58         static CFileOutput* NewL( const TDesC& aTestPath,
       
    59                                     const TDesC& aTestFile,
       
    60                                     CStifLogger::TLoggerType aLoggerType,
       
    61                                     TBool aOverWrite,
       
    62                                     TBool aWithTimeStamp,
       
    63                                     TBool aWithLineBreak,
       
    64                                     TBool aWithEventRanking,
       
    65                                     TBool aThreadIdToLogFile,
       
    66                                     TBool aCreateLogDir,
       
    67                                     TInt  aStaticBufferSize,
       
    68                                     TBool aUnicode,
       
    69                                     TInt  aThreadId);
       
    70 
       
    71         /**
       
    72         * Destructor.
       
    73         */
       
    74         ~CFileOutput();
       
    75 
       
    76     public:     // New functions
       
    77 
       
    78         /**
       
    79         * Create a directory.
       
    80         */
       
    81         void CreateDirectoryL( const TDesC& aTestPath );
       
    82 
       
    83         /**
       
    84         * Open an existing file.
       
    85         */
       
    86         void OpenExistingFileL( const TDesC& aTestPath,
       
    87                                 const TDesC& aTestFile );
       
    88 
       
    89         /**
       
    90         * Create a new file.
       
    91         */
       
    92         void CreateNewFileL( const TDesC& aTestPath, const TDesC& aTestFile );
       
    93 
       
    94         /**
       
    95         * Write log information or data to the file.
       
    96         * 16 bit.
       
    97         */
       
    98         TInt Write( TBool aWithTimeStamp,
       
    99                     TBool aWithLineBreak,
       
   100                     TBool aWithEventRanking,
       
   101                     const TDesC& aData );
       
   102 
       
   103         /**
       
   104         * Write log information or data to the file.
       
   105         * 8 bit.
       
   106         */
       
   107         TInt Write( TBool aWithTimeStamp,
       
   108                     TBool aWithLineBreak,
       
   109                     TBool aWithEventRanking,
       
   110                     const TDesC8& aData );
       
   111 
       
   112         /**
       
   113         * Add event ranking, specify number to line (1-byte version).
       
   114         */
       
   115         void EventRanking( TPtr8& aData );
       
   116 
       
   117         /**
       
   118         * Add event ranking, specify number to line (2-byte version).
       
   119         */
       
   120         void EventRanking( TPtr& aData );
       
   121 
       
   122         /**
       
   123         * Add date, time and line break to data (1-byte version).
       
   124         */
       
   125         void AddTimeStampToData( TPtr8& aData );
       
   126 
       
   127         /**
       
   128         * Add date, time and line break to data (2-byte version).
       
   129         */
       
   130         void AddTimeStampToData( TPtr& aData );
       
   131 
       
   132         /**
       
   133         * Get date and time.
       
   134         */
       
   135         void GetDateAndTime( TStifLoggerTimeStamp& aDataAndTime );
       
   136 
       
   137         /**
       
   138         * Make file type.
       
   139         */
       
   140         void FileType( const TDesC& aTestFile, TFileType& aFileType );
       
   141 
       
   142         /**
       
   143         * Generate thread id to test file name.
       
   144         */
       
   145         void TestFileWithThreadId( const TDesC& aTestFile,
       
   146                                     TFileName& aNewTestFile );
       
   147 
       
   148     public:     // Functions from base classes
       
   149 
       
   150     protected:  // New functions
       
   151 
       
   152     protected:  // Functions from base classes
       
   153 
       
   154     private:
       
   155 
       
   156         /**
       
   157         * C++ default constructor.
       
   158         */
       
   159         CFileOutput( CStifLogger::TLoggerType aLoggerType,
       
   160                         TBool aWithTimeStamp,
       
   161                         TBool aWithLineBreak,
       
   162                         TBool aWithEventRanking,
       
   163                         TBool aThreadIdToLogFile,
       
   164                         TInt  aThreadId);
       
   165 
       
   166         /**
       
   167         * By default Symbian OS constructor is private.
       
   168         */
       
   169         void ConstructL( const TDesC& aTestPath,
       
   170                             const TDesC& aTestFile,
       
   171                             TBool aOverWrite,
       
   172                             TBool aCreateLogDir,
       
   173                             TInt aStaticBufferSize,
       
   174                             TBool aUnicode );
       
   175 
       
   176     public:     // Data
       
   177 
       
   178     protected:  // Data
       
   179 
       
   180     private:    // Data
       
   181 
       
   182         /**
       
   183         * Log file directory name, file name and file type.
       
   184         */
       
   185         TFileName iFileAndDirName;
       
   186 
       
   187         /**
       
   188         * Indicates file type.
       
   189         */
       
   190         CStifLogger::TLoggerType iLoggerType;
       
   191 
       
   192         /**
       
   193         * Time stamp indicator.
       
   194         */
       
   195         TBool iWithTimeStamp;
       
   196 
       
   197         /**
       
   198         * Line break indicator.
       
   199         */
       
   200         TBool iWithLineBreak;
       
   201 
       
   202         /**
       
   203         * Event ranking indicator.
       
   204         */
       
   205         TBool iWithEventRanking;
       
   206 
       
   207         /**
       
   208         * Indicator to thread id adding to end of the log file
       
   209         */
       
   210         TBool iThreadIdToLogFile;
       
   211 
       
   212         /**
       
   213         * Indicator to thread id adding to end of the log file
       
   214         */
       
   215         TBool iCreateLogDir;
       
   216 
       
   217         /**
       
   218         * For the file handling
       
   219         */
       
   220         RFile iFile;
       
   221 
       
   222         /**
       
   223         * For the file session handling
       
   224         */
       
   225         RFs iFileSession;
       
   226 
       
   227         /**
       
   228         * Is file open indicator
       
   229         */
       
   230         TInt iIsFileOpen;
       
   231 
       
   232        /**
       
   233         * DataHBuf for logging purposes
       
   234         */
       
   235         HBufC8 * iDataHBuf8;
       
   236 
       
   237 		// @js
       
   238         TInt iStaticBufferSize;
       
   239 
       
   240        /**
       
   241         * Determines if file has to be in unicode format
       
   242         */
       
   243         TBool iUnicode;
       
   244 
       
   245        /**
       
   246         * DataHBuf for logging purposes
       
   247         */
       
   248         HBufC16* iDataHBuf16;
       
   249 
       
   250        /**
       
   251         * Thread id of test case thread.
       
   252         * Get from client side when creating logger.
       
   253         */
       
   254         TInt iThreadId;
       
   255 
       
   256     public:     // Friend classes
       
   257 
       
   258     protected:  // Friend classes
       
   259 
       
   260     private:    // Friend classes
       
   261 
       
   262     };
       
   263 
       
   264 #endif      // FILEOUTPUT_H
       
   265 
       
   266 // End of File