williamr@2: /* williamr@2: * Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies). williamr@2: * All rights reserved. williamr@2: * This component and the accompanying materials are made available williamr@2: * under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members williamr@2: * which accompanies this distribution, and is available williamr@2: * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". williamr@2: * williamr@2: * Initial Contributors: williamr@2: * Nokia Corporation - initial contribution. williamr@2: * williamr@2: * Contributors: williamr@2: * williamr@2: * Description: CPosLmCompositeCriteria class williamr@2: * williamr@2: */ williamr@2: williamr@2: williamr@2: #ifndef CPOSLMCOMPOSITECRITERIA_H williamr@2: #define CPOSLMCOMPOSITECRITERIA_H williamr@2: williamr@2: #include williamr@2: #include "EPos_CPosLmSearchCriteria.h" williamr@2: williamr@2: /** williamr@2: * Class used to combine multiple search criterion. williamr@2: * williamr@2: * For instance, to search for all restaurants in the area, this class can be williamr@2: * used to combine a @ref CPosLmAreaCriteria and a @ref CPosLmCategoryCriteria. williamr@2: * williamr@2: * If a @ref CPosLmNearestCriteria is used and no sort preference is specified, williamr@2: * the result will be sorted by distance. If more than one williamr@2: * @ref CPosLmNearestCriteria are combined using a @ref CPosLmCompositeCriteria, williamr@2: * the sort order will be undefined unless a sort preference is specified. williamr@2: * williamr@2: * Nested @ref CPosLmCompositeCriteria are not allowed. williamr@2: * williamr@2: * This criterion only supports searching for landmarks, e.g. if it is passed williamr@2: * to @p CPosLandmarkSearch::StartCategorySearchL, the function will fail with williamr@2: * error code @p KErrNotSupported. williamr@2: * williamr@2: * @lib eposlmsearchlib.lib williamr@2: * @since S60 3.0 williamr@2: */ williamr@2: class CPosLmCompositeCriteria : public CPosLmSearchCriteria williamr@2: { williamr@2: public: williamr@2: williamr@2: /** williamr@2: * Specifies the type of the composite criterion. williamr@2: * ECompositionOR - is supported only when all the contained critarias are CPosLmTextCriteria. it is not supported for other criteria. williamr@2: */ williamr@2: enum TCompositionType williamr@2: { williamr@2: ECompositionAND = 0, /**< Search results must match all williamr@2: * contained criteria. */ williamr@2: ECompositionOR = 1 /**< Search result must match one of the contained criteria williamr@2: williamr@2: * ECompositionOR - is supported only when all the contained critarias are CPosLmTextCriteria. it is not supported for other criteria*/ williamr@2: }; williamr@2: williamr@2: public: williamr@2: williamr@2: /** williamr@2: * Two-phased constructor. williamr@2: * williamr@2: * @param[in] aType The composition type to use. williamr@2: * @returns A new instance of this class. williamr@2: */ williamr@2: IMPORT_C static CPosLmCompositeCriteria* NewLC( williamr@2: TCompositionType aType williamr@2: ); williamr@2: williamr@2: /** williamr@2: * Destructor. williamr@2: */ williamr@2: virtual ~CPosLmCompositeCriteria(); williamr@2: williamr@2: public: williamr@2: williamr@2: /** williamr@2: * Returns the type of this composite criterion. williamr@2: * williamr@2: * @return The composition type. williamr@2: */ williamr@2: IMPORT_C TCompositionType CompositionType() const; williamr@2: williamr@2: /** williamr@2: * Set the type of this composite criterion. williamr@2: * williamr@2: * @param[in] The composition type to use. williamr@2: */ williamr@2: IMPORT_C void SetCompositionType( TCompositionType aType ); williamr@2: williamr@2: /** williamr@2: * Returns the number of criteria this object contains. williamr@2: * williamr@2: * @return The number of criteria this object contains. williamr@2: */ williamr@2: IMPORT_C TUint NumOfArguments() const; williamr@2: williamr@2: /** williamr@2: * Returns a criterion argument contained in this object. williamr@2: * williamr@2: * This overload returns a const reference to the criterion argument. williamr@2: * There is another overload which returns a non-const reference. williamr@2: * williamr@2: * @param aIndex The argument to read. Must be in the interval williamr@2: * [0, @ref NumOfArguments - 1], or this function will raise a williamr@2: * USER-130 panic. williamr@2: * @return The requested argument. williamr@2: */ williamr@2: IMPORT_C const CPosLmSearchCriteria& Argument( TUint aIndex ) const; williamr@2: williamr@2: /** williamr@2: * Returns a criterion argument contained in this object. williamr@2: * williamr@2: * This overload returns a non-const reference to the criterion williamr@2: * argument. There is another overload which returns a const reference. williamr@2: * williamr@2: * @param aIndex The argument to read. Must be in the interval williamr@2: * [0, @ref NumOfArguments - 1], or this function will raise a williamr@2: * USER-130 panic. williamr@2: * @return The requested argument. williamr@2: */ williamr@2: IMPORT_C CPosLmSearchCriteria& Argument( TUint aIndex ); williamr@2: williamr@2: /** williamr@2: * Adds a criterion to this composition. williamr@2: * williamr@2: * The composite criterion must contain at least one argument, otherwise williamr@2: * @ref CPosLandmarkSearch::StartLandmarkSearchL will fail with error williamr@2: * code @p KErrArgument. williamr@2: * williamr@2: * If this function returns without an error code, ownership of the williamr@2: * added criterion object is transferred to the composite object. williamr@2: * williamr@2: * @ref CPosLmCompositeCriteria are not supported when composition type is @ref ECompositionAND. williamr@2: * @ref Only CPosLmTextCriteria is supported in the case of @ref ECompositionOR williamr@2: * williamr@2: * Searching for landmark categories using @ref CPosLmCompositeCriteria williamr@2: * is not supported in the case of ECompositionAND. williamr@2: * williamr@2: * @param[in] aCriteria The criterion to add to the composition. williamr@2: * @returns - @p KErrNone if successful williamr@2: * - @p KErrNotSupported williamr@2: * - @p if @ref CPosLmCompositeCriteria or @ref CPosLmCatNameCriteria is specified when coposition type is ECompositionAND. williamr@2: * - @p If criteria other than CPosLmTextCriteria is specified with ECompositionOR williamr@2: * - @p otherwise a system wide error code. williamr@2: */ williamr@2: IMPORT_C TInt AddArgument( CPosLmSearchCriteria* aCriteria ); williamr@2: williamr@2: /** williamr@2: * Removes a criterion from this composition. williamr@2: * williamr@2: * Note: This function does not delete the criterion object. Instead, williamr@2: * the ownership of the object is passed to the caller. williamr@2: * williamr@2: * @param aIndex The argument to remove. Must be in the interval williamr@2: * [0, @ref NumOfArguments - 1], or this function will raise a williamr@2: * USER-130 panic. williamr@2: * williamr@2: * @returns The criterion object which was removed from the composition. williamr@2: */ williamr@2: IMPORT_C CPosLmSearchCriteria* RemoveArgument( TUint aIndex ); williamr@2: williamr@2: /** williamr@2: * Removes and deletes all contained criterion objects. williamr@2: * williamr@2: * The composite criterion must contain at least one argument, otherwise williamr@2: * @ref CPosLandmarkSearch::StartLandmarkSearchL will fail with error williamr@2: * code @p KErrArgument. williamr@2: */ williamr@2: IMPORT_C void ClearArguments(); williamr@2: williamr@2: private: williamr@2: williamr@2: CPosLmCompositeCriteria( TCompositionType aType ); williamr@2: williamr@2: void ConstructL(); williamr@2: williamr@2: // Prohibit copy constructor williamr@2: CPosLmCompositeCriteria( const CPosLmCompositeCriteria& ); williamr@2: // Prohibit assigment operator williamr@2: CPosLmCompositeCriteria& operator= ( const CPosLmCompositeCriteria& ); williamr@2: williamr@2: private: williamr@2: williamr@2: TCompositionType iCompositionType; williamr@2: RPointerArray iArguments; williamr@2: williamr@2: }; williamr@2: williamr@2: #endif // CPOSLMCOMPOSITECRITERIA_H williamr@2: williamr@2: