devicediagnosticsfw/diagpluginbase/inc/diagresultdetailbasic.h
branchRCL_3
changeset 26 19bba8228ff0
parent 0 b497e44ab2fc
equal deleted inserted replaced
25:b183ec05bd8c 26:19bba8228ff0
       
     1 /*
       
     2 * Copyright (c) 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:  Basic Diagnostics Test Result Detail class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef DIAGRESULTDETAILBASIC_H
       
    20 #define DIAGRESULTDETAILBASIC_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32base.h>                    // CBase
       
    24 #include <DiagResultDetail.h>           // MDiagResultDetail
       
    25 #include <DiagResultsDatabaseItem.h>    // CDiagResultsDatabaseItem::TResult
       
    26 
       
    27 // FORWARD DECLARATIONS
       
    28 class CDiagResultDetailBasicItem;
       
    29 
       
    30 
       
    31 // CONSTANTS
       
    32 const TInt KDiagResultDetailBasicVersion  = 1;   // verion of data format.
       
    33 
       
    34 /**
       
    35 *  Diagnostics Result Database Detail  class.
       
    36 *
       
    37 *  This  class provides  implementation of MDiagResultDetail 
       
    38 *  with commonly used methods.
       
    39 *
       
    40 *  @since S60 v5.0
       
    41 */
       
    42 class CDiagResultDetailBasic : public CBase,
       
    43                                public MDiagResultDetail
       
    44     {
       
    45 public:
       
    46     /**
       
    47     * Constructor.
       
    48     *
       
    49     * @param aResult - Test Result
       
    50     */
       
    51     IMPORT_C CDiagResultDetailBasic( 
       
    52                     CDiagResultsDatabaseItem::TResult aResult );
       
    53 
       
    54     /**
       
    55     * Destructor.
       
    56     */
       
    57     IMPORT_C virtual ~CDiagResultDetailBasic();
       
    58 
       
    59     /**
       
    60     * Externalize to a stream
       
    61     *
       
    62     * @param aWriteStream - stream to write to.
       
    63     */
       
    64     IMPORT_C void ExternalizeL( RWriteStream& aWriteStream ) const;
       
    65 
       
    66     /**
       
    67     * Update result value
       
    68     * 
       
    69     * @param aResult - Test result
       
    70     */
       
    71     IMPORT_C void SetResult( CDiagResultsDatabaseItem::TResult aResult );
       
    72 
       
    73 protected: // Interface for Derived class
       
    74     /**
       
    75     * Set data to a field.  This function sets a value to a field.
       
    76     * If data already exists at the same field id, new data will 
       
    77     * over write the old value at the same field.
       
    78     *
       
    79     * @param aFieldId - Unique ID to identify the data.
       
    80     * @param aFieldName - Name of the field. This only for a 
       
    81     *   reference.
       
    82     * @param aValue - Value to set. This can be a TInt,
       
    83     *   const TDesC8& or const TDesC16&.
       
    84     */
       
    85     IMPORT_C void SetValueL( TInt aFieldId,
       
    86                              const TDesC8& aFieldName,
       
    87                              TInt aValue );
       
    88     IMPORT_C void SetValueL( TInt aFieldId,
       
    89                              const TDesC8& aFieldName,
       
    90                              const TDesC8& aValue );
       
    91     IMPORT_C void SetValueL( TInt aFieldId,
       
    92                              const TDesC8& aFieldName,
       
    93                              const TDesC16& aValue );
       
    94 
       
    95     /**
       
    96     * Get value. If invalid aFieldId is passed, or type does not 
       
    97     * match, function will leave with KErrArgument. 
       
    98     *
       
    99     * @param aFieldId - Unique id that identifies the data. Same
       
   100     *   value used in SetValueL function.
       
   101     * @param aValue - Output paramater. The data will be stored
       
   102     *   here.
       
   103     * @return KErrNone if successful. If not found KErrNotFound.
       
   104     *   If type does not match, KErrArgument.
       
   105     */
       
   106     IMPORT_C TInt GetValue( TInt aFieldId, TInt& aValue ) const;
       
   107     IMPORT_C TInt GetValue( TInt aFieldId, TPtrC8& aValue ) const;
       
   108     IMPORT_C TInt GetValue( TInt aFieldId, TPtrC16& aValue ) const;
       
   109 
       
   110 public: // from MDiagResultDetail
       
   111     /**
       
   112     * Get list of supported output
       
   113     *
       
   114     * @param aOutputList   - Returns supported output formats
       
   115     */
       
   116     IMPORT_C virtual void GetSupportedOutput(
       
   117                 RArray<TOutputFormat>& aOutputList ) const;
       
   118 
       
   119     /**
       
   120     * Check if a given output format is supported.
       
   121     *
       
   122     * @param aOutputFormat - Possible output formate.
       
   123     * @return ETrue if supported. EFalse otherwise.
       
   124     */
       
   125     IMPORT_C virtual TBool IsOutputSupported( TOutputFormat aOutputFormat ) const;
       
   126 
       
   127     /**
       
   128     * Output current result to a specified format.
       
   129     *
       
   130     * @param aFormat   Format of desired output.
       
   131     * @param aBuffer   Output buffer.
       
   132     */
       
   133     IMPORT_C virtual void GetOutputL( TOutputFormat aFormat, RBuf& aBuffer ) const;
       
   134 
       
   135     /**
       
   136     * Create an icon. Icon can be created based on the results of the test.
       
   137     *
       
   138     * @return An icon that matches the result of the test.
       
   139     **/
       
   140     IMPORT_C virtual CGulIcon* CreateIconL() const;
       
   141 
       
   142     /**
       
   143     * Externalize to a CBufFlat. 
       
   144     *   @see MDiagResultDetail::ExternalizeToBufferL
       
   145     */
       
   146     IMPORT_C CBufFlat* ExternalizeToBufferL() const;
       
   147 
       
   148 protected:
       
   149     /**
       
   150     * BaseConstructL
       
   151     *
       
   152     * @param aReadStream - Initialize from a stream.
       
   153     */
       
   154     IMPORT_C void BaseConstructL( RReadStream& aReadStream );
       
   155 
       
   156     /**
       
   157     * BaseConstructL
       
   158     *
       
   159     * @param aBuffer - Buffer to initialize from
       
   160     */
       
   161     IMPORT_C void BaseConstructL( const CBufFlat& aBuffer );
       
   162 
       
   163 
       
   164 private:  // internal methods
       
   165     /**
       
   166     * InternalizeL
       
   167     *
       
   168     * @param aReadStream - Initialize from a stream.
       
   169     */
       
   170     void InternalizeL( RReadStream& aReadStream );
       
   171 
       
   172     /**
       
   173     * Insert a new item. This function will delete the old item if item with 
       
   174     * same field id already existsed.
       
   175     *
       
   176     * @param aNewItem - new item to set
       
   177     */
       
   178     void SetItemL( CDiagResultDetailBasicItem* aNewItem );
       
   179 
       
   180     /**
       
   181     * Find item by field id
       
   182     *
       
   183     * @param - Field id to look up.
       
   184     * @return - Index in iFields array if look up is successful.
       
   185     *   Return value is negative if look up fails.
       
   186     */
       
   187     TInt FindItem( TInt aFieldId ) const;
       
   188 
       
   189 
       
   190 private: // DATA
       
   191     /**
       
   192     * Test result.
       
   193     */
       
   194     CDiagResultsDatabaseItem::TResult            iResult;
       
   195     
       
   196     /**
       
   197     * List of fields it contains.
       
   198     *   All items are owned by this class.
       
   199     */
       
   200     RPointerArray<CDiagResultDetailBasicItem>    iFields;
       
   201     };
       
   202 
       
   203 
       
   204 
       
   205 #endif // DIAGRESULTDETAILBASIC_H
       
   206 
       
   207 // End of File
       
   208