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