mulwidgets/mullogging/inc/mullogchunk.h
changeset 0 e83bab7cf002
equal deleted inserted replaced
-1:000000000000 0:e83bab7cf002
       
     1 /*
       
     2 * Copyright (c) 2006-2007 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:  Logging to chunk wrapper for MC Photos
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef T_MULLOGCHUNK_H
       
    20 #define T_MULLOGCHUNK_H
       
    21 
       
    22 // EXTERNAL INCLUDES
       
    23 #include <e32std.h>
       
    24 #include <f32file.h>
       
    25 
       
    26 /**
       
    27  * RMulLogUtility.
       
    28  * Encapsulates the use of RChunk for log writing
       
    29  */
       
    30 NONSHARABLE_CLASS( RMulLogUtility )
       
    31     {
       
    32     public:
       
    33         /**
       
    34          * Opens the log chunk with given name
       
    35          * @param aName, the full name of the chunk
       
    36          * @param aReadOnly, whether to open in readonly or read-write
       
    37          */
       
    38         TInt Open( const TDesC& aName, TBool aReadOnly );
       
    39 
       
    40         /**
       
    41          * Creates the log chunk with given name
       
    42          * @param aName, the full name of the chunk
       
    43          */
       
    44         void CreateL( const TDesC& aName );
       
    45 
       
    46         /**
       
    47          * Closes the opened chunk. This needs to be called
       
    48          * before an object of this class goes out of scope
       
    49          */
       
    50         void Close();
       
    51         
       
    52         /**
       
    53          * @return the size of the log chunk
       
    54          */
       
    55         TInt ChunkSize();
       
    56         
       
    57         /**
       
    58          * @return the chunk unique Id (set by client)
       
    59          */
       
    60         TObjectId Id();
       
    61 
       
    62         /**
       
    63          * Sets the unique id for the log chunk
       
    64          * @param aId the id to set for the chunk
       
    65          */
       
    66         void SetId( TObjectId aId );
       
    67         
       
    68         /**
       
    69          * @return Current chunk write address
       
    70          */
       
    71         TUint8* CurrentAddress();
       
    72 
       
    73         /**
       
    74          * Sets the current write address
       
    75          * @param New write address
       
    76          */
       
    77         void SetCurrentAddress( TUint8* aValue );
       
    78 
       
    79         /**
       
    80          * @return Last address written to file
       
    81          */
       
    82         TUint8* LastLoggedAddress();
       
    83 
       
    84         /**
       
    85          * Sets the last logged address
       
    86          * @param New last logged address
       
    87          */
       
    88         void SetLastLoggedAddress( TUint8* aValue );
       
    89 
       
    90         /**
       
    91          * @return The topmost writable address of the chunk
       
    92          */
       
    93         TUint8* BaseAddress();
       
    94 
       
    95         /**
       
    96          * @return The bottom most writable address of the chunk
       
    97          */
       
    98         TUint8* LastAddress();
       
    99 
       
   100     private:
       
   101 
       
   102         /// Own: chunk to write to
       
   103         RChunk iChunk;
       
   104     };
       
   105 
       
   106 /**
       
   107  * RMulLogClient.
       
   108  * Client API for log writing to chunk
       
   109  */
       
   110 NONSHARABLE_CLASS( RMulLogClient )
       
   111     {
       
   112     public:
       
   113 
       
   114 		/**
       
   115 		 * Opens the log chunk with the given unique id
       
   116 		 * @param aId unique id for the log writing thread
       
   117 		 */
       
   118         IMPORT_C TInt Open( TObjectId aId );
       
   119         
       
   120         /**
       
   121          * Closes the log handle, needs to be called before an
       
   122          * object of this class goes out of scope
       
   123          */
       
   124         IMPORT_C void Close();
       
   125 
       
   126         /**
       
   127          * Writes a descriptor to the log
       
   128          * @param aLogEntry the log entry to write
       
   129          */
       
   130         IMPORT_C void Write( const TDesC8& aLogEntry );
       
   131 
       
   132     private:
       
   133 
       
   134     	/// Own: log utility
       
   135         RMulLogUtility iLogUtility;
       
   136 
       
   137     };
       
   138     
       
   139 /**
       
   140  * RMulLogManager.
       
   141  * Management API for log creation and committing to file
       
   142  */
       
   143 NONSHARABLE_CLASS( RMulLogManager )
       
   144     {
       
   145     public:
       
   146 
       
   147         /**
       
   148          * Creates the log chunks
       
   149          */
       
   150         IMPORT_C void CreateL();
       
   151         
       
   152         /**
       
   153          * Releases the log chunks
       
   154          */
       
   155 		IMPORT_C void Release();
       
   156  
       
   157         /**
       
   158          * Writes the log to a file
       
   159          * One file is created per chunk.
       
   160          * @param aFolder the directory where to store the logs
       
   161          */
       
   162         IMPORT_C void CommitToFileL( const TDesC& aFolder );
       
   163         
       
   164     private:
       
   165 
       
   166 		// helper method to write all descriptors of a chunk to a 
       
   167 		// file
       
   168         void CommitToFileL( RMulLogUtility& aUtility, RFile& aFile );
       
   169         
       
   170     private:
       
   171  
       
   172     	/// Own: log utility
       
   173         RMulLogUtility iLogUtility1;
       
   174     	/// Own: log utility
       
   175         RMulLogUtility iLogUtility2;    
       
   176         /// Own: file server handle
       
   177         RFs iFs;
       
   178 
       
   179     };
       
   180 
       
   181 #endif // T_MULLOGCHUNK_H
       
   182     
       
   183