ncdengine/provider/storage/inc/ncddatabasestorage.h
changeset 0 ba25891c3a9e
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 2006-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 #ifndef M_NCDDATABASESTORAGE_H
       
    20 #define M_NCDDATABASESTORAGE_H
       
    21 
       
    22 
       
    23 #include <e32base.h>
       
    24 #include <d32dbms.h>
       
    25 
       
    26 
       
    27 class MNcdDatabaseStorage;
       
    28 class MNcdStorageItem;
       
    29 class RNcdDatabaseItems;
       
    30 
       
    31 /**
       
    32  * Interface for database storages
       
    33  * @ Improve comments
       
    34  */
       
    35 
       
    36 class MNcdDatabaseStorage
       
    37 {
       
    38 public:
       
    39 
       
    40     /**
       
    41      * Database size information
       
    42      */
       
    43     typedef RDbDatabase::TSize TNcdDatabaseSize;
       
    44         
       
    45 public: 
       
    46 
       
    47 
       
    48     /**
       
    49      * Returns ponter to storage item. If storage item doesn't exist
       
    50      * it is created. Ownerhip of the storage item is not transferred
       
    51      * to caller.
       
    52      */
       
    53     virtual MNcdStorageItem* StorageItemL( const TDesC& aUid, TInt aType ) = 0;
       
    54 
       
    55     /**
       
    56      * Gets all storage items from storage. This method doens't create
       
    57      * new items to storage but returns all items being currently stored
       
    58      * to it.
       
    59      *
       
    60      * @param aItems An array where to storage items will be added.
       
    61      */
       
    62     virtual void StorageItemsL( RPointerArray<MNcdStorageItem>& aItems ) = 0;
       
    63     
       
    64     
       
    65     virtual void RemoveItemsL( 
       
    66         const RArray<RNcdDatabaseItems>& aDoNotRemoveItems ) = 0;
       
    67         
       
    68 
       
    69     /**
       
    70      * Begins transaction into storage.
       
    71      */
       
    72     virtual void Begin() = 0;
       
    73 
       
    74     /**
       
    75      * Commits changes to storage.
       
    76      */
       
    77     virtual void CommitL() = 0;
       
    78 
       
    79     /**
       
    80      * Discards changes and restores storage to state it was before
       
    81      * transaction was started.
       
    82      */
       
    83     virtual void Rollback() = 0;
       
    84 
       
    85     /**
       
    86      * Ensures that given storage item exists in storage.
       
    87      *
       
    88      * NOTE: It is possible that storage item is created and exists
       
    89      * but it is not stored to storage.
       
    90      *
       
    91      * @param aStorageItem The item to be checked
       
    92      * @return Boolean value indicating whether the item exsists in
       
    93      * storage.
       
    94      */
       
    95     virtual TBool ItemExistsInStorageL( MNcdStorageItem& aStorageItem ) = 0;
       
    96 
       
    97     /**
       
    98      * Ensures that given storage item exists in storage.
       
    99      *
       
   100      * NOTE: It is possible that storage item is created and exists
       
   101      * but it is not stored to storage.
       
   102      *
       
   103      * @param aUid Uid of the item to be checked
       
   104      * @param aType Type of the item to be checked
       
   105      * @return Boolean value indicating whether the item exsists in
       
   106      * storage.
       
   107      */
       
   108     virtual TBool ItemExistsInStorageL( const TDesC& aUid, TInt aType ) = 0;
       
   109 
       
   110 
       
   111     /**
       
   112      * Storage UID getter
       
   113      * @return Storage UID
       
   114      */
       
   115     virtual const TDesC& Uid() const = 0;
       
   116     
       
   117     
       
   118     /**
       
   119      * Database size getter
       
   120      */
       
   121     virtual TNcdDatabaseSize Size() const = 0;
       
   122     
       
   123     
       
   124     /**
       
   125      * Commits and compacts the db
       
   126      */
       
   127     virtual void Compact() = 0;
       
   128     
       
   129 protected:
       
   130     
       
   131     virtual ~MNcdDatabaseStorage()
       
   132         {
       
   133         }
       
   134     
       
   135 
       
   136 };
       
   137 
       
   138 
       
   139 #endif // M_NCDDATABASESTORAGE_H