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