63
|
1 |
/*
|
|
2 |
* Copyright (c) 2006-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: Identifies a contact in cache pools
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#ifndef C_PCS_ALGORITHM_2_FILTER_HELPER
|
|
19 |
#define C_PCS_ALGORITHM_2_FILTER_HELPER
|
|
20 |
|
|
21 |
// SYSTEM INCLUDES
|
|
22 |
#include <e32cmn.h>
|
|
23 |
#include <e32math.h>
|
|
24 |
#include <e32hashtab.h>
|
|
25 |
|
|
26 |
// USER INCLUDES
|
|
27 |
#include "CPcsDefs.h"
|
|
28 |
#include "CPsData.h"
|
|
29 |
#include "CPcsAlgorithm2Utils.h"
|
|
30 |
#include "CPsPattern.h"
|
|
31 |
|
|
32 |
/*
|
|
33 |
* Internal structure to store the match patterns
|
|
34 |
* and mapping pool index
|
|
35 |
*/
|
|
36 |
struct TPsSubPattern
|
|
37 |
{
|
|
38 |
HBufC* matchPattern; // match pattern
|
|
39 |
TInt firstOccurenceInThisPattern; // First occurence of this pattern in this patterns
|
|
40 |
|
|
41 |
};
|
|
42 |
|
|
43 |
struct TPsPatternDetails
|
|
44 |
{
|
|
45 |
HBufC* matchPattern; // match pattern
|
|
46 |
TInt firstOccurence; // First occurence of this pattern in result set
|
|
47 |
TInt poolIndex;
|
|
48 |
RPointerArray<TPsSubPattern> subPatternArray;
|
|
49 |
|
|
50 |
};
|
|
51 |
|
|
52 |
// CLASS DECLARATION
|
|
53 |
class CPcsAlgorithm2FilterHelper : public CBase
|
|
54 |
{
|
|
55 |
public:
|
|
56 |
|
|
57 |
/**
|
|
58 |
* Two phase construction
|
|
59 |
*/
|
|
60 |
static CPcsAlgorithm2FilterHelper* NewL(TSortType aSortType);
|
|
61 |
|
|
62 |
/**
|
|
63 |
* Destructor
|
|
64 |
*/
|
|
65 |
virtual ~CPcsAlgorithm2FilterHelper();
|
|
66 |
|
|
67 |
public:
|
|
68 |
|
|
69 |
/**
|
|
70 |
* Adds the result
|
|
71 |
*/
|
|
72 |
void AddL(CPsData* psData, RPointerArray<TDesC>& aPatternSequence);
|
|
73 |
|
|
74 |
/**
|
|
75 |
* Returns the final list of results based on the given sort type
|
|
76 |
*/
|
|
77 |
void GetResults(RPointerArray<CPsData>& aSearchResults);
|
|
78 |
|
|
79 |
/**
|
|
80 |
* Returns the final match sequence list
|
|
81 |
*/
|
|
82 |
void GetPatternsL(RPointerArray<CPsPattern>& aPatternSet);
|
|
83 |
|
|
84 |
private:
|
|
85 |
|
|
86 |
/**
|
|
87 |
* Constructor
|
|
88 |
*/
|
|
89 |
CPcsAlgorithm2FilterHelper();
|
|
90 |
|
|
91 |
/**
|
|
92 |
* 2nd phase construtor
|
|
93 |
*/
|
|
94 |
void ConstructL(TSortType aSortType);
|
|
95 |
|
|
96 |
/**
|
|
97 |
* Adds each result into respective pool based on match pattern
|
|
98 |
*/
|
|
99 |
TInt AddToPoolL(CPsData* psData, RPointerArray<TDesC>& aPatternSequence);
|
|
100 |
|
|
101 |
/**
|
|
102 |
* Searches for for aSeq in iMatchPatternDetails and returns index
|
|
103 |
* where input sequence is found. Returns -1 if not found
|
|
104 |
*/
|
|
105 |
TInt FindSequence(const TDesC& aSeq);
|
|
106 |
|
|
107 |
|
|
108 |
/**
|
|
109 |
* Searches for for seq in subpatterns of iMatchPatternDetails[aPatternIndex]
|
|
110 |
* and returns index where input sequence is found.
|
|
111 |
* Returns -1 if not found
|
|
112 |
*/
|
|
113 |
TInt FindSubSequence(const TDesC& aSeq, TInt aPatternIndex);
|
|
114 |
|
|
115 |
/**
|
|
116 |
* Creates the Matchpattern aSeq in iMatchPatternDetails.
|
|
117 |
* Returns the index of the sequence in iMatchPatternDetails
|
|
118 |
*/
|
|
119 |
TInt CreateMatchPatternDetailsAndPoolsL(const TDesC& aSeq);
|
|
120 |
|
|
121 |
/**
|
|
122 |
* Searches for all the subsequences of aSeq and updates the
|
|
123 |
* aFirstOccrVal in iMatchPatternDetails.
|
|
124 |
*/
|
|
125 |
void UpdateForSubSequencesL(const TDesC& aSeq, TInt aFirstOccrVal);
|
|
126 |
|
|
127 |
private:
|
|
128 |
|
|
129 |
/**
|
|
130 |
* Own. Array of TPsPatternDetails structure
|
|
131 |
*/
|
|
132 |
RPointerArray<TPsPatternDetails> iMatchPatternDetails;
|
|
133 |
|
|
134 |
/**
|
|
135 |
* Keeps track number of results
|
|
136 |
*/
|
|
137 |
TInt32 iResultCount;
|
|
138 |
|
|
139 |
/**
|
|
140 |
* Own. Array of result pools based on match patterns
|
|
141 |
*/
|
|
142 |
RPointerArray<CPSDATA_R_PTR_ARRAY> iMatchPatternPools;
|
|
143 |
|
|
144 |
/**
|
|
145 |
* Sort type, either alphabetical or pattern based
|
|
146 |
*/
|
|
147 |
TSortType iSortType;
|
|
148 |
};
|
|
149 |
|
|
150 |
#endif /* C_PCS_ALGORITHM_2_FILTER_HELPER */
|
|
151 |
|
|
152 |
// END OF FILE
|