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