|
1 // Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of the License "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Provides classes for holding domain policy data. |
|
15 // |
|
16 // |
|
17 |
|
18 #ifndef __DOMAIN_CFG_H__ |
|
19 #define __DOMAIN_CFG_H__ |
|
20 |
|
21 #include <e32base.h> |
|
22 |
|
23 #include <domainpolicy.h> |
|
24 |
|
25 |
|
26 /** |
|
27 The server's representation of per-transition config settings |
|
28 |
|
29 It is intended to act as a buffer between the server and any |
|
30 future SDmStateSpecV* structs. |
|
31 |
|
32 */ |
|
33 struct TTransitionConfig : public SDmStateSpecV1 |
|
34 { |
|
35 TTransitionConfig(const SDmStateSpecV1& aSpec); |
|
36 // This version of the constructor is used as a key when looking up a |
|
37 // specific actual config. |
|
38 TTransitionConfig(TDmDomainState); |
|
39 TInt CheckValues() const; |
|
40 }; |
|
41 |
|
42 /** |
|
43 Repository for a hierachy's settings |
|
44 */ |
|
45 class CHierarchySettings : public CBase |
|
46 { |
|
47 public: |
|
48 CHierarchySettings(); |
|
49 ~CHierarchySettings(); |
|
50 |
|
51 void StoreConfigL(const TTransitionConfig& aConfig); |
|
52 |
|
53 // Called by CDmHierarchy |
|
54 void SetCurrentTargetTransition(TDmDomainState); |
|
55 |
|
56 // Called by various objects to retrieve settings |
|
57 TBool GetDomainTimeout(TTimeIntervalMicroSeconds32&) const; |
|
58 TBool GetDeferralBudget(TInt&) const; |
|
59 TBool GetFailurePolicy(TDmTransitionFailurePolicy&) const; |
|
60 |
|
61 private: |
|
62 const TTransitionConfig* LookupConfig(TDmDomainState) const; |
|
63 |
|
64 TDmDomainState iCurrentState; |
|
65 |
|
66 RArray<const TTransitionConfig> iConfigs; |
|
67 }; |
|
68 |
|
69 /** |
|
70 This class wraps up the fetching of a data type for which |
|
71 an overridden value may be available from CHierarchySettings |
|
72 |
|
73 Template parameters: |
|
74 T - Type of the value which may be over-ridden. |
|
75 F - Pointer to member function of CHierarchySettings. |
|
76 This will be used to query and fetch an over-ride value. |
|
77 */ |
|
78 template< typename T, TBool (CHierarchySettings::*F)(T&) const> |
|
79 class TOverrideableSetting |
|
80 { |
|
81 public: |
|
82 /** |
|
83 @param aDefault Default value |
|
84 @param aSettings The object from which overrides are fetched |
|
85 */ |
|
86 TOverrideableSetting(T aDefault, const CHierarchySettings* aSettings = NULL) |
|
87 : iSettings(aSettings), iDefault(aDefault) |
|
88 {} |
|
89 |
|
90 void SetSettings(const CHierarchySettings* aSettings) |
|
91 { |
|
92 iSettings = aSettings; |
|
93 } |
|
94 |
|
95 /** |
|
96 Used to access the wrapped value. It will supply an |
|
97 over-ridden value if available, otherwise, the internal |
|
98 default vaule. |
|
99 */ |
|
100 T operator ()() const |
|
101 { |
|
102 T value; |
|
103 const TBool overridden = (iSettings->*F)(value); |
|
104 |
|
105 if(!overridden) |
|
106 { |
|
107 value = iDefault; |
|
108 } |
|
109 return value; |
|
110 } |
|
111 |
|
112 private: |
|
113 const CHierarchySettings* iSettings; |
|
114 const T iDefault; |
|
115 }; |
|
116 #endif |