menufw/hierarchynavigator/hnmetadatamodel/inc/hnqueryresultcollector.h
changeset 0 f72a12da539e
equal deleted inserted replaced
-1:000000000000 0:f72a12da539e
       
     1 /*
       
     2 * Copyright (c) 2007-2008 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:    
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef C_HNQUERYCOLLECTOR_H
       
    21 #define C_HNQUERYCOLLECTOR_H
       
    22 
       
    23 #include <e32base.h>
       
    24 
       
    25 class CLiwGenericParamList;
       
    26 class CHnMdQueries;
       
    27 class CHnServiceHandler;
       
    28 class CHnMdQuery;
       
    29 
       
    30 // CLASS DECLARATION
       
    31 /**
       
    32  * Query Results Collector - Callback Interface 
       
    33  * 
       
    34  * @lib hnmetadatamodel
       
    35  * @since S60 5.0
       
    36  * @ingroup group_hnmetadatamodel
       
    37  */
       
    38 class MHnQueryResultCollectorNotification
       
    39 	{
       
    40 public:
       
    41 	
       
    42 	/**
       
    43 	 * Callback function called after results are collected
       
    44 	 * 
       
    45 	 * 	 
       
    46 	 * @since S60 5.0
       
    47      * @param aResults Results collected for the query.
       
    48 	 */
       
    49 	virtual void ResultsCollectedL( CLiwGenericParamList* aResults ) = 0; 
       
    50 	};
       
    51 
       
    52 
       
    53 // CLASS DECLARATION
       
    54 /**
       
    55  * Query Results Collector.
       
    56  * 
       
    57  * This class is responsible for collecting queries results.
       
    58  * 
       
    59  * @lib hnmetadatamodel
       
    60  * @since S60 5.0
       
    61  * @ingroup group_hnmetadatamodel
       
    62  */
       
    63 NONSHARABLE_CLASS( CHnQueryResultCollector ): public CActive
       
    64 	{
       
    65 public:
       
    66     
       
    67     /**
       
    68      * Two-phase constructor.
       
    69      *
       
    70      * @since S60 5.0
       
    71      * @param aQueries Queries to operate on.
       
    72      * @param aParams Parameters.
       
    73      * @return Fully constructed object.
       
    74      */
       
    75 	static CHnQueryResultCollector* NewL( const CHnMdQueries& aQueries ,
       
    76 	                               const CLiwGenericParamList& aParams);
       
    77 	
       
    78 	/**
       
    79      * Two-phase constructor.
       
    80      *
       
    81      * @since S60 5.0
       
    82      * @param aQueries Queries to operate on.
       
    83      * @param aParams Parameters.
       
    84      * @return Fully constructed object.
       
    85      */
       
    86 	static CHnQueryResultCollector* NewLC( const CHnMdQueries& aQueries,
       
    87                                   const CLiwGenericParamList& aParams );
       
    88 	        
       
    89     /**
       
    90      * Destructor.
       
    91      */
       
    92 	~CHnQueryResultCollector();
       
    93 
       
    94     /**
       
    95      * Starts performing queries asynchronously.
       
    96      *
       
    97      * @since S60 5.0
       
    98      * @param aNotification callback interface - ResultCollectedL method calles
       
    99      *                      when queries results collected.
       
   100      */
       
   101 	void StartAsynchL( MHnQueryResultCollectorNotification* aNotification );
       
   102     
       
   103 protected:
       
   104     // from CActive
       
   105     /**
       
   106      * Resets the current query results.
       
   107      */
       
   108     void DoCancel();
       
   109     
       
   110     /**
       
   111      * Handles query result collection.
       
   112      */
       
   113     void RunL();    
       
   114 
       
   115 private:
       
   116     /**
       
   117      * Standard C++ constructor.
       
   118      * 
       
   119      * @param aQueries Queries for which results are to be executed.
       
   120      * @param aParams Parameters for the queries.
       
   121      */
       
   122 	CHnQueryResultCollector( const CHnMdQueries& aQueries,
       
   123 	                         const CLiwGenericParamList& aParams );
       
   124 	
       
   125     /**
       
   126      * Standard symbian 2nd phase constructor.
       
   127      *
       
   128      */
       
   129 	void ConstructL();
       
   130 	
       
   131     /**
       
   132      * Starts performing next query from a raw.
       
   133      * 
       
   134      */	
       
   135 	void ExecQueryAsynchL();
       
   136 	
       
   137 	/**
       
   138      * Resets iterator and current results.
       
   139      */
       
   140 	void ResetL();
       
   141 	
       
   142 	/**
       
   143      * Check if there is another query waiting.
       
   144      * 
       
   145      * @return ETrue if there is another query waiting.
       
   146      */
       
   147 	TBool NextQuery();
       
   148 		
       
   149     /**
       
   150      * Removes items.
       
   151      * 
       
   152      */
       
   153 	void HandleQueryResultsL();
       
   154     
       
   155     /**
       
   156      * Executes query on Service Handler.
       
   157      * 
       
   158      * @param aQuery Query to be executed.
       
   159      */
       
   160     void ExecQueryL( CHnMdQuery& aQuery );
       
   161     
       
   162 private:
       
   163 	
       
   164 	/**
       
   165      * Queries.
       
   166      * Not Own.
       
   167      */
       
   168 	const CHnMdQueries& iQueries;
       
   169 	
       
   170 	/**
       
   171      * Own.
       
   172      */
       
   173 	CLiwGenericParamList* iResults;
       
   174 	
       
   175 	/**
       
   176      * Not Own.
       
   177      */
       
   178 	const CLiwGenericParamList& iParams;
       
   179 	
       
   180 	/**
       
   181      * Own.
       
   182      */
       
   183 	TInt iQueryIterator;
       
   184 	
       
   185 	/**
       
   186      * Own.
       
   187      */
       
   188 	CLiwGenericParamList* iCurrentQueryResults;
       
   189 	
       
   190 	/**
       
   191      * Not Own.
       
   192      */
       
   193 	MHnQueryResultCollectorNotification* iNotification;
       
   194 	
       
   195 	/**
       
   196      * Service handler.
       
   197      * Own.
       
   198      */
       
   199     CHnServiceHandler* iSh;
       
   200 	
       
   201 	};
       
   202 
       
   203 #endif // C_HNQUERYCOLLECTOR_H