devicediagnosticsfw/diagframework/inc/diagresultsdbItembuilder.h
changeset 0 b497e44ab2fc
equal deleted inserted replaced
-1:000000000000 0:b497e44ab2fc
       
     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:  Diagnostics Results Database Item Builder
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef DIAGRESULTSDBITEMBUILDER_H
       
    21 #define DIAGRESULTSDBITEMBUILDER_H
       
    22 
       
    23 // INCLUDES
       
    24 #include <DiagResultsDatabaseItem.h>        // CDiagResultsDatabaseItem::TResult
       
    25 
       
    26 // FORWARD DECLARATIONS
       
    27 namespace DRM
       
    28     {
       
    29     class CDrmServiceApi;
       
    30     }
       
    31 
       
    32 class MDiagResultDetail;
       
    33 
       
    34 
       
    35 /**
       
    36 *  Diagnostics Result Database Item Builder.
       
    37 *
       
    38 *  This class can be used to build CDiagResultsDatabaseItem, without having
       
    39 *  to have all the values avaliable.
       
    40 *
       
    41 *  @since S60 v5.0
       
    42 */
       
    43 NONSHARABLE_CLASS( CDiagResultsDbItemBuilder ) : public CBase
       
    44     {
       
    45 public:  // Constructors and Destructors
       
    46     /**
       
    47     * Two-phase constructor.
       
    48     *
       
    49     * This will set the test started time to now.
       
    50     *
       
    51     * @param aTestUid - Test Uid.
       
    52     * @param aDependencyExecution - Whether thsa was executed as dependency.
       
    53     * @return New instance of CDiagResultsDbItemBuilder
       
    54     */
       
    55     IMPORT_C static CDiagResultsDbItemBuilder* NewL( TUid  aTestUid,
       
    56                                                      TBool aDependencyExecution );
       
    57     IMPORT_C static CDiagResultsDbItemBuilder* NewLC( TUid  aTestUid,
       
    58                                                       TBool aDependencyExecution );
       
    59 
       
    60     /**
       
    61     * Destructor
       
    62     *
       
    63     */
       
    64     virtual ~CDiagResultsDbItemBuilder();
       
    65 
       
    66 public: // New Interface
       
    67 
       
    68     /**
       
    69     * Set Test Uid
       
    70     *
       
    71     * @param aUid - Test uid.
       
    72     */
       
    73     IMPORT_C void SetTestUid( TUid aUid );
       
    74 
       
    75     /**
       
    76     * Get Test Uid
       
    77     *
       
    78     * @return Test uid.
       
    79     */
       
    80     IMPORT_C TUid TestUid() const;
       
    81 
       
    82     /**
       
    83     * Get current time. If DRM clock is available, it will use the DRM clock.
       
    84     *
       
    85     */
       
    86     IMPORT_C TTime GetCurrentTime() const;
       
    87 
       
    88     /**
       
    89     * Set whether test was executed as dependency or not.
       
    90     *
       
    91     * @param aWasDependency
       
    92     */
       
    93     IMPORT_C void SetWasDependency( TBool aWasDependency );
       
    94 
       
    95     /**
       
    96     * Get was dependency value
       
    97     *
       
    98     * @return ETrue if test was executed as a dependency.
       
    99     */
       
   100     IMPORT_C TBool WasDependency() const;
       
   101 
       
   102     /**
       
   103     * Update test result and also set completed time to now
       
   104     *
       
   105     * @param aResult - Test result.
       
   106     */
       
   107     IMPORT_C void SetTestCompleted( CDiagResultsDatabaseItem::TResult aResult );
       
   108 
       
   109     /**
       
   110     * Get Test result
       
   111     *
       
   112     * @return Test result.
       
   113     */
       
   114     IMPORT_C CDiagResultsDatabaseItem::TResult TestResult() const;
       
   115 
       
   116     /**
       
   117     * Set Time Started 
       
   118     *
       
   119     * @param aTime - time started.
       
   120     */
       
   121     IMPORT_C void SetTimeStarted( TTime aTime );
       
   122 
       
   123     /**
       
   124     * Get Time started.
       
   125     *
       
   126     * @return Time started.
       
   127     */
       
   128     IMPORT_C TTime TimeStarted() const;
       
   129 
       
   130     /**
       
   131     * Set Time Completed
       
   132     *
       
   133     * @param aTime - time completed.
       
   134     */
       
   135     IMPORT_C void SetTimeCompleted( TTime aTime );
       
   136 
       
   137     /**
       
   138     * Get Time Completed..
       
   139     *
       
   140     * @return Time Completed.
       
   141     */
       
   142     IMPORT_C TTime TimeCompleted() const;
       
   143 
       
   144     /**
       
   145     * Set result detail object. If it was already set, previous object is deleted.
       
   146     *
       
   147     * @param aResultDetail - Result detail object. Ownership is transferred.
       
   148     */
       
   149     IMPORT_C void SetResultDetail( MDiagResultDetail* aResultDetail );
       
   150 
       
   151     /**
       
   152     * Get result detail object. Use static_cast to change to specific instance.
       
   153     *   If result detail was not set previosuly, it will Panic with 
       
   154     *   EDiagFrameworkInvalidState
       
   155     *
       
   156     * @return Result detail object.
       
   157     */
       
   158     IMPORT_C MDiagResultDetail& ResultDetail() const;
       
   159 
       
   160     /**
       
   161     * Create CDiagResultsDatabaseItem from data available.
       
   162     *
       
   163     */
       
   164     IMPORT_C CDiagResultsDatabaseItem* ToResultsDatabaseItemL() const;
       
   165 
       
   166     /**
       
   167     * Create a simple CDiagResultsDatabaseItem. This function is meant to be
       
   168     * used to create default result data with just with minimal set of information.
       
   169     * It will use current time as both start and end time of test.
       
   170     * If manipulation of other information in needed, either instantiate
       
   171     * CDiagResultsDbItemBuilder or CDiagResultsDatabaseItem
       
   172     *
       
   173     * @param aTestUid - Uid of test plugin.
       
   174     * @param aAsDependency - Whether it was executed as dependency or not.
       
   175     * @param aResultType - Result of the test.
       
   176     * @return Instance of CDiagResultsDatabaseItem* with given info. 
       
   177     *   Ownership is transferred.
       
   178     */
       
   179     IMPORT_C static CDiagResultsDatabaseItem* CreateSimpleDbItemL( 
       
   180         TUid aTestUid,
       
   181         TBool aAsDependency,
       
   182         CDiagResultsDatabaseItem::TResult aResultType );
       
   183 
       
   184 
       
   185 protected:  // constructors
       
   186     /**
       
   187     * C++ Constructor
       
   188     *
       
   189     * @param aTestUid - Uid of the test
       
   190     * @param aDependencyExecution - Whether this is being executed as dependency.
       
   191     */
       
   192     CDiagResultsDbItemBuilder( TUid  aTestUid,
       
   193                                TBool aDependencyExecution );
       
   194     /**
       
   195     * ConstructL
       
   196     *
       
   197     */
       
   198     void ConstructL();
       
   199 
       
   200 private: // Data
       
   201     /**
       
   202     * iTestUid - Uid of the test plug-in that this result is for.
       
   203     */
       
   204     TUid iTestUid;
       
   205 
       
   206     /**
       
   207     * iDependencyExecution - Whether this test is being executed to 
       
   208     *   satisfy dependency or not.
       
   209     */
       
   210     TBool iDependencyExecution;
       
   211 
       
   212     /**
       
   213     * iResut - Actual result of the test.
       
   214     */
       
   215     CDiagResultsDatabaseItem::TResult iResult;
       
   216 
       
   217     /**
       
   218     * iStartTime - Time test started.
       
   219     */
       
   220     TTime iStartTime;
       
   221 
       
   222     /**
       
   223     * iEndTime - Time test finished.
       
   224     */
       
   225     TTime iEndTime;
       
   226 
       
   227     /**
       
   228     * iResultDetail - Extra details data.
       
   229     * Owns.
       
   230     */
       
   231     MDiagResultDetail* iResultDetail;
       
   232 
       
   233     /**
       
   234     * iDrmApi - Used to get accurate clock through DRM.
       
   235     * Owns.
       
   236     */
       
   237     DRM::CDrmServiceApi* iDrmApi;
       
   238     };
       
   239 
       
   240 
       
   241 #endif // DIAGRESULTSDBITEMBUILDER_H
       
   242 
       
   243 // End of File
       
   244