predictivesearch/PcsAlgorithm/Algorithm1/src/CPcsPoolElement.cpp
branchRCL_3
changeset 63 f4a778e096c2
child 64 c1e8ba0c2b16
child 68 9da50d567e3c
equal deleted inserted replaced
62:5b6f26637ad3 63:f4a778e096c2
       
     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:  Represents a pool element in the contacts cache.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "CPcsDebug.h"
       
    21 #include "CPcsPoolElement.h"
       
    22 #include "CPsData.h"
       
    23 #include "CPcsAlgorithm1Utils.h"
       
    24 
       
    25 // ============================== MEMBER FUNCTIONS ============================
       
    26 
       
    27 // ----------------------------------------------------------------------------
       
    28 // CPcsPoolElement::NewL
       
    29 // Two Phase Construction
       
    30 // ----------------------------------------------------------------------------
       
    31 CPcsPoolElement* CPcsPoolElement::NewL(CPsData& aPsData)
       
    32 {
       
    33 	CPcsPoolElement* self = new ( ELeave ) CPcsPoolElement();
       
    34 	CleanupStack::PushL( self );
       
    35 	self->ConstructL(aPsData);
       
    36 	CleanupStack::Pop( self );
       
    37 	return self;
       
    38 } 
       
    39 
       
    40 // ----------------------------------------------------------------------------
       
    41 // CPcsPoolElement::CPcsPoolElement
       
    42 // Constructor
       
    43 // ----------------------------------------------------------------------------
       
    44 CPcsPoolElement::CPcsPoolElement()
       
    45 {
       
    46 }
       
    47 
       
    48 // ----------------------------------------------------------------------------
       
    49 // CPcsPoolElement::ConstructL
       
    50 // 2nd Phase Constructer
       
    51 // ----------------------------------------------------------------------------
       
    52 void CPcsPoolElement::ConstructL(CPsData& aPsData)
       
    53 {
       
    54      iPsData = &aPsData;
       
    55 }
       
    56 
       
    57 // ----------------------------------------------------------------------------
       
    58 // CPcsPoolElement::~CPcsPoolElement
       
    59 // Destructor
       
    60 // ----------------------------------------------------------------------------
       
    61 CPcsPoolElement::~CPcsPoolElement()
       
    62 {
       
    63 	// Do not delete the PsData in the destructor
       
    64 	// It is deleted separately, since it is used at multiple locations 
       
    65 }
       
    66 
       
    67 // ----------------------------------------------------------------------------
       
    68 // CPcsPoolElement::GetPsData
       
    69 // 
       
    70 // ----------------------------------------------------------------------------
       
    71 CPsData* CPcsPoolElement::GetPsData()
       
    72 {
       
    73 	return iPsData;
       
    74 }
       
    75 
       
    76 // ----------------------------------------------------------------------------
       
    77 // CPcsPoolElement::CompareByData
       
    78 // Calls CPsData::CompareByData to compare CPsData objects
       
    79 // ----------------------------------------------------------------------------
       
    80 TInt CPcsPoolElement::CompareByData ( const CPcsPoolElement& aObject1,  const CPcsPoolElement& aObject2 )
       
    81 {
       
    82     CPsData *data1 = const_cast<CPcsPoolElement&> (aObject1).GetPsData();
       
    83     CPsData *data2 = const_cast<CPcsPoolElement&> (aObject2).GetPsData();  
       
    84     return (CPcsAlgorithm1Utils::CompareDataBySortOrderL(*(data1), *(data2)));
       
    85 }
       
    86 
       
    87 // ----------------------------------------------------------------------------
       
    88 // CPcsPoolElement::IsDataMatch
       
    89 // 
       
    90 // ----------------------------------------------------------------------------		
       
    91 TBool CPcsPoolElement::IsDataMatch(TInt aIndex)
       
    92 {
       
    93     __ASSERT_DEBUG( aIndex < 8, User::Panic( _L("CPcsPoolElement"), KErrOverflow ) );
       
    94     TUint8 val = 1 << aIndex;
       
    95     return (iDataMatchAttribute & val);
       
    96 }
       
    97 
       
    98 // ----------------------------------------------------------------------------
       
    99 // CPcsPoolElement::SetDataMatch
       
   100 // 
       
   101 // ----------------------------------------------------------------------------
       
   102 void CPcsPoolElement::SetDataMatch(TInt aIndex)
       
   103 {
       
   104     __ASSERT_DEBUG( aIndex < 8, User::Panic( _L("CPcsPoolElement"), KErrOverflow ) );
       
   105     TUint8 val = 1 << aIndex;
       
   106     iDataMatchAttribute |= val;
       
   107 }
       
   108 
       
   109 // ----------------------------------------------------------------------------
       
   110 // CPcsPoolElement::ClearDataMatchAttribute
       
   111 // 
       
   112 // ----------------------------------------------------------------------------
       
   113 void CPcsPoolElement::ClearDataMatchAttribute()
       
   114 {
       
   115 	iDataMatchAttribute = 0x0;
       
   116 }
       
   117 
       
   118 
       
   119 // End of file
       
   120