diff -r 000000000000 -r e686773b3f54 predictivesearch/PcsAlgorithm/Algorithm2/src/CPcsPoolElement.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/predictivesearch/PcsAlgorithm/Algorithm2/src/CPcsPoolElement.cpp Tue Feb 02 10:12:17 2010 +0200 @@ -0,0 +1,121 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Represents a pool element in the contacts cache. +* +*/ + +// INCLUDE FILES +#include "CPcsDebug.h" +#include "CPcsPoolElement.h" +#include "CPsData.h" +#include "CPcsAlgorithm2Utils.h" + +// ============================== MEMBER FUNCTIONS ============================ + +// ---------------------------------------------------------------------------- +// CPcsPoolElement::NewL +// Two Phase Construction +// ---------------------------------------------------------------------------- +CPcsPoolElement* CPcsPoolElement::NewL(CPsData& aPsData) +{ + CPcsPoolElement* self = new ( ELeave ) CPcsPoolElement(); + CleanupStack::PushL( self ); + self->ConstructL(aPsData); + CleanupStack::Pop( self ); + return self; +} + +// ---------------------------------------------------------------------------- +// CPcsPoolElement::CPcsPoolElement +// Constructor +// ---------------------------------------------------------------------------- +CPcsPoolElement::CPcsPoolElement() +{ +} + +// ---------------------------------------------------------------------------- +// CPcsPoolElement::ConstructL +// 2nd Phase Constructer +// ---------------------------------------------------------------------------- +void CPcsPoolElement::ConstructL(CPsData& aPsData) +{ + psData = &aPsData; +} + +// ---------------------------------------------------------------------------- +// CPcsPoolElement::~CPcsPoolElement +// Destructor +// ---------------------------------------------------------------------------- +CPcsPoolElement::~CPcsPoolElement() +{ + // Do not delete the PsData in the destructor + // It is deleted separately, since it is used at multiple locations +} + +// ---------------------------------------------------------------------------- +// CPcsPoolElement::GetPsData +// +// ---------------------------------------------------------------------------- +CPsData* CPcsPoolElement::GetPsData() +{ + return psData; +} + +// ---------------------------------------------------------------------------- +// CPcsPoolElement::CompareByData +// Calls CPsData::CompareByData to compare CPsData objects +// +// ---------------------------------------------------------------------------- +TInt CPcsPoolElement::CompareByData ( const CPcsPoolElement& aObject1, const CPcsPoolElement& aObject2 ) +{ + CPsData *data1 = const_cast (aObject1).GetPsData(); + CPsData *data2 = const_cast (aObject2).GetPsData(); + return (CPcsAlgorithm2Utils::CompareDataBySortOrder(*(data1), *(data2))); +} + +// CPcsPoolElement::IsDataMatch +// +// ---------------------------------------------------------------------------- +TBool CPcsPoolElement::IsDataMatch (TInt aIndex) +{ + TReal val; + Math::Pow(val, 2, aIndex); + + return(iDataMatchAttribute & (TUint8)val); +} + +// ---------------------------------------------------------------------------- +// CPcsPoolElement::SetDataMatch +// +// ---------------------------------------------------------------------------- +void CPcsPoolElement::SetDataMatch(TInt aIndex) +{ + TReal val; + Math::Pow(val, 2, aIndex); + + iDataMatchAttribute |= (TUint8)val; +} + +// ---------------------------------------------------------------------------- +// CPcsPoolElement::ClearDataMatchAttribute +// +// ---------------------------------------------------------------------------- +void CPcsPoolElement::ClearDataMatchAttribute() +{ + iDataMatchAttribute = 0x0; +} + + +// End of file +