radioengine/utils/api/cradiorepositoryentity.h
changeset 41 3a6b55c6390c
parent 33 11b6825f0862
child 48 e14766a36cdc
equal deleted inserted replaced
33:11b6825f0862 41:3a6b55c6390c
     1 /*
       
     2 * Copyright (c) 2009 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 #ifndef C_RADIOREPOSITORYENTITY_H
       
    19 #define C_RADIOREPOSITORYENTITY_H
       
    20 
       
    21 // User includes
       
    22 #include "cradiorepositoryentitybase.h"
       
    23 #include "mradiorepositoryentityobserver.h"
       
    24 #include "cradioenginelogger.h"
       
    25 
       
    26 // Forward declarations
       
    27 class CRepository;
       
    28 
       
    29 /**
       
    30  * Templated class to listen to a single key within the central repository.
       
    31  *
       
    32  * Notifies the observer of changes in the key, and provides caching for the key's value.
       
    33  */
       
    34 template <typename T>
       
    35 NONSHARABLE_CLASS( CRadioRepositoryEntity ) : public CRadioRepositoryEntityBase
       
    36     {
       
    37 
       
    38 public:
       
    39 
       
    40     IMPORT_C static CRadioRepositoryEntity<T>* NewL( const TUid& aUid, 
       
    41                                             TUint32 aKey, 
       
    42                                             MRadioRepositoryEntityObserver& aObserver, 
       
    43                                             CActive::TPriority aPriority = CActive::EPriorityStandard );
       
    44 
       
    45     IMPORT_C ~CRadioRepositoryEntity();
       
    46 
       
    47     /**
       
    48      * Sets the value of the entity.
       
    49      * The value is written into the central repository immediately.
       
    50      *
       
    51      * @param   aValue  The value to set.
       
    52      * @param   aSavingEnabled If ETrue, saving to central repository file is enabled
       
    53      */
       
    54     TInt SetValue( const T& aValue, TBool aSavingEnabled );
       
    55 
       
    56     /**
       
    57      * Returns a cached reference to the value of the entity.
       
    58      *
       
    59      * @return  The cached value of the entity.
       
    60      */
       
    61     const T& Value() const;
       
    62 
       
    63     /**
       
    64      * Forcibly updates the key's value from the central repository and caches it.
       
    65      */
       
    66     void UpdateL();
       
    67 
       
    68 // from base class CActive
       
    69 
       
    70     void RunL();
       
    71     void DoCancel();
       
    72 
       
    73 private:
       
    74 
       
    75     CRadioRepositoryEntity( const TUid& aUid, 
       
    76                             TUint32 aKey, 
       
    77                             MRadioRepositoryEntityObserver& aObserver, 
       
    78                             CActive::TPriority aPriority );
       
    79 
       
    80     void ConstructL();
       
    81 
       
    82 protected:
       
    83 
       
    84     /** The central repository client. */
       
    85     CRepository*    iRepository;
       
    86     
       
    87     /** The cached value of the key. */
       
    88     T               iValue;
       
    89 
       
    90     };
       
    91 
       
    92 #include "cradiorepositoryentity.inl"
       
    93 
       
    94 #endif // C_RADIOREPOSITORYENTITY_H