ncdengine/provider/storage/inc/ncddatabasestorage.h
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Fri, 12 Mar 2010 15:43:14 +0200
branchRCL_3
changeset 18 3ba40be8e484
parent 0 ba25891c3a9e
permissions -rw-r--r--
Revision: 201007 Kit: 201008

/*
* Copyright (c) 2006-2008 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:  
*
*/


#ifndef M_NCDDATABASESTORAGE_H
#define M_NCDDATABASESTORAGE_H


#include <e32base.h>
#include <d32dbms.h>


class MNcdDatabaseStorage;
class MNcdStorageItem;
class RNcdDatabaseItems;

/**
 * Interface for database storages
 * @ Improve comments
 */

class MNcdDatabaseStorage
{
public:

    /**
     * Database size information
     */
    typedef RDbDatabase::TSize TNcdDatabaseSize;
        
public: 


    /**
     * Returns ponter to storage item. If storage item doesn't exist
     * it is created. Ownerhip of the storage item is not transferred
     * to caller.
     */
    virtual MNcdStorageItem* StorageItemL( const TDesC& aUid, TInt aType ) = 0;

    /**
     * Gets all storage items from storage. This method doens't create
     * new items to storage but returns all items being currently stored
     * to it.
     *
     * @param aItems An array where to storage items will be added.
     */
    virtual void StorageItemsL( RPointerArray<MNcdStorageItem>& aItems ) = 0;
    
    
    virtual void RemoveItemsL( 
        const RArray<RNcdDatabaseItems>& aDoNotRemoveItems ) = 0;
        

    /**
     * Begins transaction into storage.
     */
    virtual void Begin() = 0;

    /**
     * Commits changes to storage.
     */
    virtual void CommitL() = 0;

    /**
     * Discards changes and restores storage to state it was before
     * transaction was started.
     */
    virtual void Rollback() = 0;

    /**
     * Ensures that given storage item exists in storage.
     *
     * NOTE: It is possible that storage item is created and exists
     * but it is not stored to storage.
     *
     * @param aStorageItem The item to be checked
     * @return Boolean value indicating whether the item exsists in
     * storage.
     */
    virtual TBool ItemExistsInStorageL( MNcdStorageItem& aStorageItem ) = 0;

    /**
     * Ensures that given storage item exists in storage.
     *
     * NOTE: It is possible that storage item is created and exists
     * but it is not stored to storage.
     *
     * @param aUid Uid of the item to be checked
     * @param aType Type of the item to be checked
     * @return Boolean value indicating whether the item exsists in
     * storage.
     */
    virtual TBool ItemExistsInStorageL( const TDesC& aUid, TInt aType ) = 0;


    /**
     * Storage UID getter
     * @return Storage UID
     */
    virtual const TDesC& Uid() const = 0;
    
    
    /**
     * Database size getter
     */
    virtual TNcdDatabaseSize Size() const = 0;
    
    
    /**
     * Commits and compacts the db
     */
    virtual void Compact() = 0;
    
protected:
    
    virtual ~MNcdDatabaseStorage()
        {
        }
    

};


#endif // M_NCDDATABASESTORAGE_H