cmmanager/cmmgr/cmmserver/inc/cmmtransactionhandler.h
changeset 20 9c97ad6591ae
equal deleted inserted replaced
18:fcbbe021d614 20:9c97ad6591ae
       
     1 /*
       
     2 * Copyright (c) 2009-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:
       
    15 * Implementation of transaction handler.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef CMMTRANSACTIONHANDLER_H_
       
    21 #define CMMTRANSACTIONHANDLER_H_
       
    22 
       
    23 #include <e32base.h>
       
    24 #include <metadatabase.h>
       
    25 
       
    26 
       
    27 /**
       
    28  * Transaction handler.
       
    29  */
       
    30 NONSHARABLE_CLASS( CCmmTransactionHandler ) : public CBase
       
    31     {
       
    32 public:
       
    33     /**
       
    34      * NewL.
       
    35      * Takes ownership of aDb.
       
    36      */
       
    37     static CCmmTransactionHandler* NewL( CommsDat::CMDBSession& aDb );
       
    38 
       
    39     /**
       
    40      * Destructor.
       
    41      * Intentionally not virtual.
       
    42      */
       
    43     ~CCmmTransactionHandler();
       
    44 
       
    45 private:
       
    46     /**
       
    47      * Constructor.
       
    48      */
       
    49     CCmmTransactionHandler( CommsDat::CMDBSession& aDb );
       
    50 
       
    51     /**
       
    52      * Second phase constructor. Leaves on failure.
       
    53      */
       
    54     void ConstructL();
       
    55 
       
    56 public:
       
    57     /**
       
    58      * Return the CommsDat session.
       
    59      */
       
    60     CommsDat::CMDBSession& Session() const;
       
    61 
       
    62     /**
       
    63      * Opens a CommsDat transaction if it is not already open. Reference
       
    64      * counter is inreased by one.
       
    65      */
       
    66     void OpenTransactionLC();
       
    67 
       
    68     /**
       
    69      * Decreases the reference counter by one. If it reaches zero, commits the
       
    70      * open CommsDat transaction. If an error code is given as argument, the
       
    71      * CommsDat transaction is rolled back instead.
       
    72      */
       
    73     void CommitTransactionL( TInt aError = KErrNone );
       
    74 
       
    75     /**
       
    76      * Performs RollbackTransactionL().
       
    77      */
       
    78     void Close();
       
    79 
       
    80     /**
       
    81      * Return the current reference count. Transaction is currently open if the
       
    82      * count above 0.
       
    83      */
       
    84     TUint32 GetReferenceCount();
       
    85 
       
    86 private:
       
    87     // CommsDat session pointer.
       
    88     CommsDat::CMDBSession& iDb; // Owned.
       
    89 
       
    90     // Reference counter.
       
    91     TUint32 iRefCount;
       
    92     };
       
    93 
       
    94 #endif // CMMTRANSACTIONHANDLER_H_
       
    95 
       
    96 // End of file