homescreenpluginsrv/hspstools/inc/hspslogbus.h
changeset 0 79c6a41cd166
equal deleted inserted replaced
-1:000000000000 0:79c6a41cd166
       
     1 /*
       
     2 * Copyright (c) 2008 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:  Header for Base class for log busses.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef HSPS_LOGBUS_H
       
    20 #define HSPS_LOGBUS_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32std.h>
       
    24 #include <e32base.h>
       
    25 
       
    26 // CLASS DECLARATION
       
    27 
       
    28 /**
       
    29  * Base class for log busses. Not instanciable.
       
    30  * 
       
    31  * @lib hspsTools.lib
       
    32  * @since S60 5.0
       
    33  * @ingroup group_homescreenpluginservice_tools
       
    34  */
       
    35 class ChspsLogBus : public CBase, TDes16Overflow, TDes8Overflow
       
    36     {
       
    37 public:
       
    38     /**
       
    39      * Destructor.
       
    40      */
       
    41     IMPORT_C ~ChspsLogBus();
       
    42 
       
    43     /**
       
    44      * Log formattable 16bit string.
       
    45      * 
       
    46      * @since S60 5.0
       
    47      * @param aFmt  String to be logged. May contain format specifiers, but
       
    48      *              those must match with additional arguments given.
       
    49      *        ...   Data to be inserted to formatted string.
       
    50      */    
       
    51     IMPORT_C void LogText( TRefByValue<const TDesC16> aFmt, ... );
       
    52 
       
    53     /**
       
    54      * Log formattable 8bit string.
       
    55      * 
       
    56      * @since S60 5.0
       
    57      * @param aFmt  String to be logged. May contain format specifiers, but
       
    58      *              those must match with additional arguments given.
       
    59      *        ...   Data to be inserted to formatted string.
       
    60      */    
       
    61     IMPORT_C void LogText( TRefByValue<const TDesC8> aFmt, ... );    
       
    62     
       
    63 protected:
       
    64     /**
       
    65      * This method must be overwritten in inherited class (implementation).
       
    66      * Implementation must log given string using logging channel of
       
    67      * it's choice.
       
    68      * 
       
    69      * @param aMessage Message to be logged.
       
    70      */    
       
    71     virtual void _LogText( const TDesC& aMessage ) = 0;
       
    72 
       
    73     /**
       
    74      * This method is used to query max. line length from inheriting object.
       
    75      * Default implementation returns 128.
       
    76      * This value is used to crop descriptors before _LogText is called.
       
    77      * 
       
    78      * @return  TInt    Max line length supported by this log bus.
       
    79      */    
       
    80     virtual TInt MaxLineLen() const;    
       
    81     
       
    82     /**
       
    83      * Constructor for performing 1st stage construction.
       
    84      */
       
    85     IMPORT_C ChspsLogBus();    
       
    86     
       
    87 private: // Methods.
       
    88     /**
       
    89      * Create a heap descriptor using given arguments.
       
    90      * 
       
    91      * @param   aFmt    Descriptor
       
    92      * @param   aList   Variable length argument list.
       
    93      * @return  HBufC*  Pointer to created heap descriptor. OWNERSHIP TRANSFERRED
       
    94      *                  TO CALLER.
       
    95      */    
       
    96     HBufC* FormatMessage( TRefByValue<const TDesC16> aFmt, VA_LIST aList );
       
    97 
       
    98     /**
       
    99      * From TDes16Overflow.
       
   100      * 
       
   101      * Handles the overflow.
       
   102     
       
   103      * This function is called when the TDes16::AppendFormat() 
       
   104      * variant that takes an overflow handler argument, fails.    
       
   105      * 
       
   106      * @param aDes  The 16-bit modifiable descriptor whose overflow results in the 
       
   107      *              call to this overflow handler.
       
   108      * 
       
   109      */    
       
   110     void Overflow( TDes16& aDes );    
       
   111 
       
   112     /**
       
   113      * Create a heap descriptor using given arguments.
       
   114      * 
       
   115      * @param   aFmt    Descriptor
       
   116      * @param   aList   Variable length argument list.
       
   117      * @return  HBufC*  Pointer to created heap descriptor. OWNERSHIP TRANSFERRED
       
   118      *                  TO CALLER.
       
   119      */    
       
   120     HBufC* FormatMessage( TRefByValue<const TDesC8> aFmt, VA_LIST aList );
       
   121 
       
   122     /**
       
   123      * From TDes8Overflow.
       
   124      * 
       
   125      * Handles the overflow.
       
   126     
       
   127      * This function is called when the TDes16::AppendFormat() 
       
   128      * variant that takes an overflow handler argument, fails.    
       
   129      * 
       
   130      * @param aDes  The 16-bit modifiable descriptor whose overflow results in the 
       
   131      *              call to this overflow handler.
       
   132      * 
       
   133      */    
       
   134     void Overflow( TDes8& aDes );     
       
   135 
       
   136     /**
       
   137      * Crops text according to max line and then calls
       
   138      * inherited class' _LogText. 
       
   139      * 
       
   140      * @param   aText   Message to be logged.
       
   141      */
       
   142     void CropAndLogText( const TDesC& aText );
       
   143     
       
   144 private: // Data.    
       
   145     /**
       
   146      * Internal flag to indicate possible overflow.
       
   147      */
       
   148     TBool iOverflow;
       
   149     };
       
   150 
       
   151 #endif // HSPS_LOGBUS_H