2 * Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: CPosLmCompositeCriteria class
19 #ifndef CPOSLMCOMPOSITECRITERIA_H
20 #define CPOSLMCOMPOSITECRITERIA_H
23 #include "EPos_CPosLmSearchCriteria.h"
26 * Class used to combine multiple search criterion.
28 * For instance, to search for all restaurants in the area, this class can be
29 * used to combine a @ref CPosLmAreaCriteria and a @ref CPosLmCategoryCriteria.
31 * If a @ref CPosLmNearestCriteria is used and no sort preference is specified,
32 * the result will be sorted by distance. If more than one
33 * @ref CPosLmNearestCriteria are combined using a @ref CPosLmCompositeCriteria,
34 * the sort order will be undefined unless a sort preference is specified.
36 * Nested @ref CPosLmCompositeCriteria are not allowed.
38 * This criterion only supports searching for landmarks, e.g. if it is passed
39 * to @p CPosLandmarkSearch::StartCategorySearchL, the function will fail with
40 * error code @p KErrNotSupported.
42 * @lib eposlmsearchlib.lib
45 class CPosLmCompositeCriteria : public CPosLmSearchCriteria
50 * Specifies the type of the composite criterion.
51 * ECompositionOR - is supported only when all the contained critarias are CPosLmTextCriteria. it is not supported for other criteria.
55 ECompositionAND = 0, /**< Search results must match all
56 * contained criteria. */
57 ECompositionOR = 1 /**< Search result must match one of the contained criteria
59 * ECompositionOR - is supported only when all the contained critarias are CPosLmTextCriteria. it is not supported for other criteria*/
65 * Two-phased constructor.
67 * @param[in] aType The composition type to use.
68 * @returns A new instance of this class.
70 IMPORT_C static CPosLmCompositeCriteria* NewLC(
71 TCompositionType aType
77 virtual ~CPosLmCompositeCriteria();
82 * Returns the type of this composite criterion.
84 * @return The composition type.
86 IMPORT_C TCompositionType CompositionType() const;
89 * Set the type of this composite criterion.
91 * @param[in] The composition type to use.
93 IMPORT_C void SetCompositionType( TCompositionType aType );
96 * Returns the number of criteria this object contains.
98 * @return The number of criteria this object contains.
100 IMPORT_C TUint NumOfArguments() const;
103 * Returns a criterion argument contained in this object.
105 * This overload returns a const reference to the criterion argument.
106 * There is another overload which returns a non-const reference.
108 * @param aIndex The argument to read. Must be in the interval
109 * [0, @ref NumOfArguments - 1], or this function will raise a
111 * @return The requested argument.
113 IMPORT_C const CPosLmSearchCriteria& Argument( TUint aIndex ) const;
116 * Returns a criterion argument contained in this object.
118 * This overload returns a non-const reference to the criterion
119 * argument. There is another overload which returns a const reference.
121 * @param aIndex The argument to read. Must be in the interval
122 * [0, @ref NumOfArguments - 1], or this function will raise a
124 * @return The requested argument.
126 IMPORT_C CPosLmSearchCriteria& Argument( TUint aIndex );
129 * Adds a criterion to this composition.
131 * The composite criterion must contain at least one argument, otherwise
132 * @ref CPosLandmarkSearch::StartLandmarkSearchL will fail with error
133 * code @p KErrArgument.
135 * If this function returns without an error code, ownership of the
136 * added criterion object is transferred to the composite object.
138 * @ref CPosLmCompositeCriteria are not supported when composition type is @ref ECompositionAND.
139 * @ref Only CPosLmTextCriteria is supported in the case of @ref ECompositionOR
141 * Searching for landmark categories using @ref CPosLmCompositeCriteria
142 * is not supported in the case of ECompositionAND.
144 * @param[in] aCriteria The criterion to add to the composition.
145 * @returns - @p KErrNone if successful
146 * - @p KErrNotSupported
147 * - @p if @ref CPosLmCompositeCriteria or @ref CPosLmCatNameCriteria is specified when coposition type is ECompositionAND.
148 * - @p If criteria other than CPosLmTextCriteria is specified with ECompositionOR
149 * - @p otherwise a system wide error code.
151 IMPORT_C TInt AddArgument( CPosLmSearchCriteria* aCriteria );
154 * Removes a criterion from this composition.
156 * Note: This function does not delete the criterion object. Instead,
157 * the ownership of the object is passed to the caller.
159 * @param aIndex The argument to remove. Must be in the interval
160 * [0, @ref NumOfArguments - 1], or this function will raise a
163 * @returns The criterion object which was removed from the composition.
165 IMPORT_C CPosLmSearchCriteria* RemoveArgument( TUint aIndex );
168 * Removes and deletes all contained criterion objects.
170 * The composite criterion must contain at least one argument, otherwise
171 * @ref CPosLandmarkSearch::StartLandmarkSearchL will fail with error
172 * code @p KErrArgument.
174 IMPORT_C void ClearArguments();
178 CPosLmCompositeCriteria( TCompositionType aType );
182 // Prohibit copy constructor
183 CPosLmCompositeCriteria( const CPosLmCompositeCriteria& );
184 // Prohibit assigment operator
185 CPosLmCompositeCriteria& operator= ( const CPosLmCompositeCriteria& );
189 TCompositionType iCompositionType;
190 RPointerArray<CPosLmSearchCriteria> iArguments;
194 #endif // CPOSLMCOMPOSITECRITERIA_H