|
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 psData = &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 psData; |
|
74 } |
|
75 |
|
76 // ---------------------------------------------------------------------------- |
|
77 // CPcsPoolElement::CompareByData |
|
78 // Calls CPsData::CompareByData to compare CPsData objects |
|
79 // |
|
80 // ---------------------------------------------------------------------------- |
|
81 TInt CPcsPoolElement::CompareByData ( const CPcsPoolElement& aObject1, const CPcsPoolElement& aObject2 ) |
|
82 { |
|
83 CPsData *data1 = const_cast<CPcsPoolElement&> (aObject1).GetPsData(); |
|
84 CPsData *data2 = const_cast<CPcsPoolElement&> (aObject2).GetPsData(); |
|
85 return (CPcsAlgorithm1Utils::CompareDataBySortOrderL(*(data1), *(data2))); |
|
86 } |
|
87 |
|
88 // CPcsPoolElement::IsDataMatch |
|
89 // |
|
90 // ---------------------------------------------------------------------------- |
|
91 TBool CPcsPoolElement::IsDataMatch (TInt aIndex) |
|
92 { |
|
93 TReal val; |
|
94 Math::Pow(val, 2, aIndex); |
|
95 |
|
96 return(iDataMatchAttribute & (TUint8)val); |
|
97 } |
|
98 |
|
99 // ---------------------------------------------------------------------------- |
|
100 // CPcsPoolElement::SetDataMatch |
|
101 // |
|
102 // ---------------------------------------------------------------------------- |
|
103 void CPcsPoolElement::SetDataMatch(TInt aIndex) |
|
104 { |
|
105 TReal val; |
|
106 Math::Pow(val, 2, aIndex); |
|
107 |
|
108 iDataMatchAttribute |= (TUint8)val; |
|
109 } |
|
110 |
|
111 // ---------------------------------------------------------------------------- |
|
112 // CPcsPoolElement::ClearDataMatchAttribute |
|
113 // |
|
114 // ---------------------------------------------------------------------------- |
|
115 void CPcsPoolElement::ClearDataMatchAttribute() |
|
116 { |
|
117 iDataMatchAttribute = 0x0; |
|
118 } |
|
119 |
|
120 |
|
121 // End of file |
|
122 |