devicediagnosticsfw/diagresultsdb/server/src/diagresultsdbtestrecord.cpp
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:  Class definition of 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "diagresultsdatabasetestrecordinfo.h"
       
    20 #include "diagresultsdbtestrecord.h"
       
    21 
       
    22 
       
    23 // ---------------------------------------------------------------------------
       
    24 // Constructor. 
       
    25 // ---------------------------------------------------------------------------
       
    26 // 
       
    27 CDiagResultsDbTestRecord::CDiagResultsDbTestRecord( TBool aReadOnly, 
       
    28         TUid aRecordUid ): iRecordUid(aRecordUid), iReadOnly(aReadOnly)
       
    29 	{
       
    30 	/*
       
    31 	RecordInfo().iRecordId = iRecordUid;
       
    32 	RecordInfo().iDbUid = iDbUid;
       
    33 	RecordInfo().iCompleted = EFalse;
       
    34 	*/
       
    35 	}
       
    36 
       
    37 // ---------------------------------------------------------------------------
       
    38 // NewL.
       
    39 // ---------------------------------------------------------------------------
       
    40 // 
       
    41 CDiagResultsDbTestRecord* CDiagResultsDbTestRecord::NewL( TBool aReadOnly, 
       
    42         TUid aRecordUid )
       
    43 	{
       
    44 	CDiagResultsDbTestRecord* testrecord =	
       
    45 	    new (ELeave) CDiagResultsDbTestRecord( aReadOnly, aRecordUid  );
       
    46 	CleanupStack::PushL( testrecord );
       
    47 	testrecord->ConstructL();
       
    48 	CleanupStack::Pop();
       
    49 	return testrecord;
       
    50 	}
       
    51 
       
    52 // ---------------------------------------------------------------------------
       
    53 // ConstructL. Set test record overview's DRM and home times.
       
    54 // ---------------------------------------------------------------------------
       
    55 // 
       
    56 void CDiagResultsDbTestRecord::ConstructL()
       
    57 	{
       
    58 	//Time when this test record was created.
       
    59 //	iTestRecordInfo.iDrmStartTime = 
       
    60 	                            //TDiagResultsDatabaseTestRecordInfo::DRMTimeL();
       
    61 	//iTestRecordInfo.iStartTime.HomeTime();
       
    62 	}
       
    63 
       
    64 // ---------------------------------------------------------------------------
       
    65 // Getter.
       
    66 // ---------------------------------------------------------------------------
       
    67 // 
       
    68 TBool CDiagResultsDbTestRecord::ReadOnly() const
       
    69     {
       
    70     return iReadOnly;
       
    71     }
       
    72 
       
    73 // ---------------------------------------------------------------------------
       
    74 // Destructor. 
       
    75 // ---------------------------------------------------------------------------
       
    76 // 
       
    77 CDiagResultsDbTestRecord::~CDiagResultsDbTestRecord()
       
    78     {
       
    79     iTestArray.ResetAndDestroy();
       
    80     iTestArray.Close();
       
    81     }
       
    82 
       
    83 // ---------------------------------------------------------------------------
       
    84 // AddL. 
       
    85 // ---------------------------------------------------------------------------
       
    86 //     
       
    87 void CDiagResultsDbTestRecord::AddL( CDiagResultsDatabaseItem* aItem )
       
    88     {
       
    89     for (TInt i=0; i < iTestArray.Count(); ++i)
       
    90         {
       
    91         
       
    92         //Found same item inside the array. Delete the found item.
       
    93         if ( aItem->TestUid() == iTestArray[i]->TestUid() )
       
    94             {
       
    95             CDiagResultsDatabaseItem* item = iTestArray[i];
       
    96             iTestArray.Remove( i );
       
    97             delete item;
       
    98             item = 0;
       
    99             break;
       
   100             }
       
   101         }
       
   102         
       
   103     iTestArray.AppendL( aItem );
       
   104     }
       
   105 
       
   106 // ---------------------------------------------------------------------------
       
   107 // Operator [].
       
   108 // ---------------------------------------------------------------------------
       
   109 //     
       
   110 const CDiagResultsDatabaseItem& CDiagResultsDbTestRecord::operator[] (TInt aIndex) const
       
   111     {
       
   112     return *(iTestArray[aIndex]);
       
   113     }
       
   114 
       
   115 // ---------------------------------------------------------------------------
       
   116 // Getter. This can be also NULL.
       
   117 // ---------------------------------------------------------------------------
       
   118 // 
       
   119 CDiagResultsDatabaseItem* CDiagResultsDbTestRecord::GetItem(TInt aIndex) const
       
   120     {
       
   121     return iTestArray[aIndex];
       
   122     }
       
   123 
       
   124 // ---------------------------------------------------------------------------
       
   125 // Count().
       
   126 // ---------------------------------------------------------------------------
       
   127 // 
       
   128 TInt CDiagResultsDbTestRecord::Count() const
       
   129     {
       
   130     return iTestArray.Count();
       
   131     }
       
   132 
       
   133 // ---------------------------------------------------------------------------
       
   134 // RemoveL().
       
   135 // ---------------------------------------------------------------------------
       
   136 //         
       
   137 void CDiagResultsDbTestRecord::RemoveL( TInt aIndex )
       
   138     {
       
   139     iTestArray.Remove( aIndex );
       
   140     }
       
   141 
       
   142 
       
   143 // ---------------------------------------------------------------------------
       
   144 // RemoveL().
       
   145 // ---------------------------------------------------------------------------
       
   146 //  
       
   147 void CDiagResultsDbTestRecord::RemoveL( TUid aTestUid )
       
   148     {
       
   149      for ( TInt i = 0; i < iTestArray.Count(); ++i )
       
   150         {        
       
   151         if ( iTestArray[i]->TestUid() == aTestUid )
       
   152             {
       
   153             iTestArray.Remove( i );
       
   154             }            
       
   155         }
       
   156     }
       
   157 
       
   158 // ---------------------------------------------------------------------------
       
   159 // Find test record
       
   160 // ---------------------------------------------------------------------------
       
   161 //  
       
   162 TInt CDiagResultsDbTestRecord::FindTestRecord( 
       
   163                                 const CDiagResultsDatabaseItem& aItem ) const
       
   164     {
       
   165     TInt index = -1;
       
   166     
       
   167     for (TInt i = 0; i < iTestArray.Count(); ++i)
       
   168         {
       
   169         
       
   170         if ( iTestArray[i]->TestUid() == aItem.TestUid() )
       
   171             {
       
   172             index = i;
       
   173             break;
       
   174             }
       
   175         }
       
   176      
       
   177     return index;
       
   178     }
       
   179 
       
   180 // ---------------------------------------------------------------------------
       
   181 // Find test record
       
   182 // ---------------------------------------------------------------------------
       
   183 //  
       
   184 CDiagResultsDatabaseItem* CDiagResultsDbTestRecord::FindTestRecord( TUid aUid )
       
   185     {
       
   186      for (TInt i = 0; i < iTestArray.Count(); ++i)
       
   187         {        
       
   188         if ( iTestArray[i]->TestUid() == aUid )
       
   189             {
       
   190             return iTestArray[i];
       
   191             }
       
   192         }
       
   193         
       
   194     return NULL;
       
   195     }
       
   196 //End of file