epoc32/include/mw/epos_cposlmcompositecriteria.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     1 /*
     2 * Copyright (c) 2005-2006 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:  CPosLmCompositeCriteria class
    15 *
    16 */
    17 
    18 
    19 #ifndef CPOSLMCOMPOSITECRITERIA_H
    20 #define CPOSLMCOMPOSITECRITERIA_H
    21 
    22 #include <e32base.h>
    23 #include "EPos_CPosLmSearchCriteria.h"
    24 
    25 /**
    26 *  Class used to combine multiple search criterion.
    27 *
    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.
    30 *
    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.
    35 *
    36 *  Nested @ref CPosLmCompositeCriteria are not allowed.
    37 *
    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.
    41 *
    42 *  @lib eposlmsearchlib.lib
    43 *  @since S60 3.0
    44 */
    45 class CPosLmCompositeCriteria : public CPosLmSearchCriteria
    46     {
    47     public:
    48 
    49         /**
    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.
    52         */
    53         enum TCompositionType
    54             {
    55             ECompositionAND = 0,     /**< Search results must match all
    56                                     * contained criteria. */
    57             ECompositionOR = 1		/**< Search result must match one of the contained criteria
    58             	
    59             						* ECompositionOR - is supported only when all the contained critarias are CPosLmTextCriteria. it is not supported for other criteria*/
    60             };
    61 
    62     public:
    63 
    64         /**
    65         * Two-phased constructor.
    66         *
    67         * @param[in] aType The composition type to use.
    68         * @returns A new instance of this class.
    69         */
    70         IMPORT_C static CPosLmCompositeCriteria* NewLC(
    71             TCompositionType  aType
    72         );
    73 
    74         /**
    75         * Destructor.
    76         */
    77         virtual ~CPosLmCompositeCriteria();
    78 
    79     public:
    80 
    81         /**
    82         * Returns the type of this composite criterion.
    83         *
    84         * @return The composition type. 
    85         */
    86         IMPORT_C TCompositionType CompositionType() const;
    87 
    88         /**
    89         * Set the type of this composite criterion.
    90         *
    91         * @param[in] The composition type to use. 
    92         */
    93         IMPORT_C void SetCompositionType( TCompositionType  aType );
    94 
    95         /**
    96         * Returns the number of criteria this object contains.
    97         *
    98         * @return The number of criteria this object contains.
    99         */
   100         IMPORT_C TUint NumOfArguments() const;
   101 
   102         /**
   103         * Returns a criterion argument contained in this object.
   104         *
   105         * This overload returns a const reference to the criterion argument.
   106         * There is another overload which returns a non-const reference.
   107         *
   108         * @param aIndex The argument to read. Must be in the interval
   109         *   [0, @ref NumOfArguments - 1], or this function will raise a
   110         *   USER-130 panic.
   111         * @return The requested argument.
   112         */
   113         IMPORT_C const CPosLmSearchCriteria& Argument( TUint aIndex ) const;
   114 
   115         /**
   116         * Returns a criterion argument contained in this object.
   117         *
   118         * This overload returns a non-const reference to the criterion
   119         * argument. There is another overload which returns a const reference.
   120         *
   121         * @param aIndex The argument to read. Must be in the interval
   122         *   [0, @ref NumOfArguments - 1], or this function will raise a
   123         *   USER-130 panic.
   124         * @return The requested argument.
   125         */
   126         IMPORT_C CPosLmSearchCriteria& Argument( TUint aIndex );
   127 
   128         /**
   129         * Adds a criterion to this composition.
   130         *
   131         * The composite criterion must contain at least one argument, otherwise
   132         * @ref CPosLandmarkSearch::StartLandmarkSearchL will fail with error
   133         * code @p KErrArgument.
   134         *
   135         * If this function returns without an error code, ownership of the
   136         * added criterion object is transferred to the composite object.
   137         *
   138         * @ref CPosLmCompositeCriteria are not supported when composition type is @ref ECompositionAND.
   139         * @ref Only CPosLmTextCriteria is supported in the case of @ref ECompositionOR
   140         *
   141         * Searching for landmark categories using @ref CPosLmCompositeCriteria 
   142         * is not supported in the case of ECompositionAND.
   143         *
   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.
   150         */
   151         IMPORT_C TInt AddArgument( CPosLmSearchCriteria* aCriteria );
   152 
   153         /**
   154         * Removes a criterion from this composition.
   155         *
   156         * Note: This function does not delete the criterion object. Instead,
   157         * the ownership of the object is passed to the caller.
   158         *
   159         * @param aIndex The argument to remove. Must be in the interval
   160         *   [0, @ref NumOfArguments - 1], or this function will raise a
   161         *   USER-130 panic.
   162         *
   163         * @returns The criterion object which was removed from the composition.
   164         */
   165         IMPORT_C CPosLmSearchCriteria* RemoveArgument( TUint  aIndex );
   166 
   167         /**
   168         * Removes and deletes all contained criterion objects.
   169         *
   170         * The composite criterion must contain at least one argument, otherwise
   171         * @ref CPosLandmarkSearch::StartLandmarkSearchL will fail with error
   172         * code @p KErrArgument.
   173         */
   174         IMPORT_C void ClearArguments();
   175 
   176     private:
   177 
   178         CPosLmCompositeCriteria( TCompositionType aType );
   179 
   180         void ConstructL();
   181 
   182         // Prohibit copy constructor
   183         CPosLmCompositeCriteria( const CPosLmCompositeCriteria& );
   184         // Prohibit assigment operator
   185         CPosLmCompositeCriteria& operator= ( const CPosLmCompositeCriteria& );
   186 
   187     private:
   188 
   189         TCompositionType                    iCompositionType;
   190         RPointerArray<CPosLmSearchCriteria> iArguments;
   191 
   192     };
   193 
   194 #endif      // CPOSLMCOMPOSITECRITERIA_H
   195 
   196