|
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 psData = &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 psData; |
|
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 TReal val; |
|
93 Math::Pow(val, 2, aIndex); |
|
94 |
|
95 return(iDataMatchAttribute & (TUint8)val); |
|
96 } |
|
97 |
|
98 // ---------------------------------------------------------------------------- |
|
99 // CPcsPoolElement::SetDataMatch |
|
100 // |
|
101 // ---------------------------------------------------------------------------- |
|
102 void CPcsPoolElement::SetDataMatch(TInt aIndex) |
|
103 { |
|
104 TReal val; |
|
105 Math::Pow(val, 2, aIndex); |
|
106 |
|
107 iDataMatchAttribute |= (TUint8)val; |
|
108 } |
|
109 |
|
110 // ---------------------------------------------------------------------------- |
|
111 // CPcsPoolElement::ClearDataMatchAttribute |
|
112 // |
|
113 // ---------------------------------------------------------------------------- |
|
114 void CPcsPoolElement::ClearDataMatchAttribute() |
|
115 { |
|
116 iDataMatchAttribute = 0x0; |
|
117 } |
|
118 |
|
119 |
|
120 // End of file |
|
121 |