locationdataharvester/mylocationsengine/inc/lookupmaptiledb.h
branchRCL_3
changeset 17 1fc85118c3ae
equal deleted inserted replaced
16:8173571d354e 17:1fc85118c3ae
       
     1 /*
       
     2 * Copyright (c) 2010 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: Maptile database lookup table header.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef __LOOKUPMAPTILEDB_H__
       
    19 #define __LOOKUPMAPTILEDB_H__
       
    20 
       
    21 //Headers needed
       
    22 #include <f32file.h> //RFs
       
    23 #include <d32dbms.h>  //RDbNamedDatabase,RDbView 
       
    24 
       
    25 #include "mylocationsdefines.h"
       
    26  
       
    27 /**
       
    28  * CLookupMapTileDatabase class.
       
    29  * This class handles all the operations related to maptile lookup database.
       
    30  *
       
    31  */
       
    32  
       
    33 class CLookupMapTileDatabase : public CBase
       
    34 {
       
    35 public:
       
    36     // Two phase constructors
       
    37  
       
    38     /**
       
    39     * This is a static function, which creates and returns an instance of this class.
       
    40     */
       
    41     static CLookupMapTileDatabase* NewL( const TDesC& aLookupTableName );
       
    42 
       
    43     /**
       
    44     * This is a static function, which creates and returns an instance of this class. Pushes the created object 
       
    45     * to the cleanup stack.
       
    46     */
       
    47     static CLookupMapTileDatabase* NewLC( const TDesC& aLookupTableName );
       
    48 
       
    49     /**
       
    50     * Destructor
       
    51     */
       
    52     ~CLookupMapTileDatabase();
       
    53 
       
    54 public:
       
    55     
       
    56     /**
       
    57     * Opens the lookup database.
       
    58     */
       
    59     TInt Open();
       
    60 
       
    61     /**
       
    62     * Closes the lookup database.
       
    63     */
       
    64     void Close();
       
    65 
       
    66     /**
       
    67     * Creates an entry in the lookup table.
       
    68     * @param[in] aLookupItem The lookup item to be created in the database.
       
    69     */
       
    70     void CreateEntryL( const TLookupItem& aLookupItem );
       
    71 
       
    72     /**
       
    73     * Updates an entry in the lookup table.
       
    74     * @param[in] aLookupItem The lookup item to be updated in the database.
       
    75     */
       
    76     void UpdateEntryL( const TLookupItem& aLookupItem );
       
    77 
       
    78     /**
       
    79     * Deletes an entry from the lookup table.
       
    80     * @param[in] aLookupItem The lookup item to be deleted from the database.
       
    81     */
       
    82     void DeleteEntryL( TLookupItem& aLookupItem );
       
    83     
       
    84     /**
       
    85     * Deletes maptile from the repository if the ref to that maptile in the db reaches one
       
    86     * @param[in] aLookupItem The lookup item containing the path to the maptile
       
    87     */
       
    88     void DeleteMapTileL( const TLookupItem& aLookupItem );
       
    89 
       
    90     /**
       
    91     * Finds an entry in the lookup table.
       
    92     * @param[in/out] aLookupItem The lookup item to be found in the database. The source iUid is passed
       
    93     * in the lookup item
       
    94     * @return ETrue if found, else EFalse
       
    95     */
       
    96     TBool FindEntryL( TLookupItem& aLookupItem);
       
    97     
       
    98     /**
       
    99     * Finds an entry in the lookup table for the given maptile name.
       
   100     * @param[in] aFilePath The lookup item to be found in the database. maptile file path is passed
       
   101     * @return ETrue if found, else EFalse
       
   102     */
       
   103     TBool FindEntryByFilePathL(const TDesC& aFilePath);
       
   104 
       
   105     void FindEntriesByMapTileFetchingStateL(const TUint32 aFetchingState,
       
   106             RArray<TLookupItem>& aLookupItemArray);
       
   107 
       
   108     /**
       
   109     * Gets the list of calendar ids.
       
   110     * @param[out] aIdArray Calendar id list
       
   111     */
       
   112     void GetAllCalendarIdsL( RArray<TUint32>& aIdArray );
       
   113     
       
   114     /**
       
   115     * ReSet the entry in the lookup table , with null value 
       
   116     * @param aLookupItem The lookup item entry to be reseted in the database,
       
   117     * get the used maptile path as part of lookupItem filepath , to free the resource 
       
   118     */
       
   119     void ReSetEntryL( TLookupItem &aLookupItem );
       
   120 private:
       
   121     
       
   122     // default constructor
       
   123     CLookupMapTileDatabase();
       
   124     
       
   125     // Second phase constructor
       
   126     void ConstructL( const TDesC& aLookupTableName );
       
   127     
       
   128     // Creates a lookup table in the lookup database.
       
   129     void CreateTableL(RDbDatabase& aDatabase);
       
   130           
       
   131 private:
       
   132     
       
   133     // Handle to the items database
       
   134     RDbNamedDatabase iItemsDatabase;
       
   135     
       
   136     // handle to the file session
       
   137     RFs iFsSession;
       
   138         
       
   139     // holds the database file name
       
   140     TFileName iDbFileName;
       
   141 
       
   142 };
       
   143 
       
   144 
       
   145 #endif  // __LOOKUPMAPTILEDB_H__
       
   146 
       
   147 // End of file
       
   148