OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google, Inc. | 2 * Copyright 2013 Google, Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 | 8 |
9 #ifndef SkRTConf_DEFINED | 9 #ifndef SkRTConf_DEFINED |
10 #define SkRTConf_DEFINED | 10 #define SkRTConf_DEFINED |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 ~SkRTConfRegistry(); | 77 ~SkRTConfRegistry(); |
78 void printAll(const char *fname = NULL) const; | 78 void printAll(const char *fname = NULL) const; |
79 bool hasNonDefault() const; | 79 bool hasNonDefault() const; |
80 void printNonDefault(const char *fname = NULL) const; | 80 void printNonDefault(const char *fname = NULL) const; |
81 const char *configFileLocation() const; | 81 const char *configFileLocation() const; |
82 void possiblyDumpFile() const; | 82 void possiblyDumpFile() const; |
83 void validate() const; | 83 void validate() const; |
84 template <typename T> void set(const char *confname, | 84 template <typename T> void set(const char *confname, |
85 T value, | 85 T value, |
86 bool warnIfNotFound = true); | 86 bool warnIfNotFound = true); |
87 #ifdef SK_SUPPORT_UNITTEST | 87 |
88 static void UnitTest(); | |
89 #endif | |
90 private: | 88 private: |
91 template<typename T> friend class SkRTConf; | 89 template<typename T> friend class SkRTConf; |
92 | 90 |
93 void registerConf(SkRTConfBase *conf); | 91 void registerConf(SkRTConfBase *conf); |
| 92 |
94 template <typename T> bool parse(const char *name, T* value); | 93 template <typename T> bool parse(const char *name, T* value); |
95 | 94 |
96 SkTDArray<SkString *> fConfigFileKeys, fConfigFileValues; | 95 SkTDArray<SkString *> fConfigFileKeys, fConfigFileValues; |
97 typedef SkTDict< SkTDArray<SkRTConfBase *> * > ConfMap; | 96 typedef SkTDict< SkTDArray<SkRTConfBase *> * > ConfMap; |
98 ConfMap fConfs; | 97 ConfMap fConfs; |
99 #ifdef SK_SUPPORT_UNITTEST | 98 |
100 SkRTConfRegistry(bool); | 99 template <typename T> |
101 #endif | 100 friend bool test_rt_conf_parse(SkRTConfRegistry*, const char* name, T* value
); |
102 }; | 101 }; |
103 | 102 |
104 // our singleton registry | 103 // our singleton registry |
105 | 104 |
106 SkRTConfRegistry &skRTConfRegistry(); | 105 SkRTConfRegistry &skRTConfRegistry(); |
107 | 106 |
108 template<typename T> | 107 template<typename T> |
109 SkRTConf<T>::SkRTConf(const char *name, const T &defaultValue, const char *descr
iption) | 108 SkRTConf<T>::SkRTConf(const char *name, const T &defaultValue, const char *descr
iption) |
110 : SkRTConfBase(name) | 109 : SkRTConfBase(name) |
111 , fValue(defaultValue) | 110 , fValue(defaultValue) |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 // static_cast here is okay because there's only one kind of child class. | 185 // static_cast here is okay because there's only one kind of child class. |
187 const SkRTConf<T> *child_pointer = static_cast<const SkRTConf<T> *>(conf); | 186 const SkRTConf<T> *child_pointer = static_cast<const SkRTConf<T> *>(conf); |
188 return child_pointer && | 187 return child_pointer && |
189 fName == child_pointer->fName && | 188 fName == child_pointer->fName && |
190 fDescription == child_pointer->fDescription && | 189 fDescription == child_pointer->fDescription && |
191 fValue == child_pointer->fValue && | 190 fValue == child_pointer->fValue && |
192 fDefault == child_pointer->fDefault; | 191 fDefault == child_pointer->fDefault; |
193 } | 192 } |
194 | 193 |
195 #endif | 194 #endif |
OLD | NEW |