| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 | 66 |
| 67 class SkRTConfRegistry { | 67 class SkRTConfRegistry { |
| 68 public: | 68 public: |
| 69 SkRTConfRegistry(); | 69 SkRTConfRegistry(); |
| 70 void printAll(const char *fname = NULL) const; | 70 void printAll(const char *fname = NULL) const; |
| 71 void printNonDefault(const char *fname = NULL) const; | 71 void printNonDefault(const char *fname = NULL) const; |
| 72 const char *configFileLocation() const; | 72 const char *configFileLocation() const; |
| 73 void possiblyDumpFile() const; | 73 void possiblyDumpFile() const; |
| 74 void validate() const; | 74 void validate() const; |
| 75 template <typename T> void set(const char *confname, T value); | 75 template <typename T> void set(const char *confname, T value); |
| 76 #ifdef SK_SUPPORT_UNITTEST |
| 77 static void UnitTest(); |
| 78 #endif |
| 76 private: | 79 private: |
| 77 template<typename T> friend class SkRTConf; | 80 template<typename T> friend class SkRTConf; |
| 78 | 81 |
| 79 void registerConf(SkRTConfBase *conf); | 82 void registerConf(SkRTConfBase *conf); |
| 80 template <typename T> bool parse(const char *name, T* value); | 83 template <typename T> bool parse(const char *name, T* value); |
| 81 | 84 |
| 82 SkTDArray<SkString *> fConfigFileKeys, fConfigFileValues; | 85 SkTDArray<SkString *> fConfigFileKeys, fConfigFileValues; |
| 83 typedef SkTDict< SkTDArray<SkRTConfBase *> * > ConfMap; | 86 typedef SkTDict< SkTDArray<SkRTConfBase *> * > ConfMap; |
| 84 ConfMap fConfs; | 87 ConfMap fConfs; |
| 88 #ifdef SK_SUPPORT_UNITTEST |
| 89 SkRTConfRegistry(bool); |
| 90 #endif |
| 85 }; | 91 }; |
| 86 | 92 |
| 87 // our singleton registry | 93 // our singleton registry |
| 88 | 94 |
| 89 SkRTConfRegistry &skRTConfRegistry(); | 95 SkRTConfRegistry &skRTConfRegistry(); |
| 90 | 96 |
| 91 template<typename T> | 97 template<typename T> |
| 92 SkRTConf<T>::SkRTConf(const char *name, const T &defaultValue, const char *descr
iption) | 98 SkRTConf<T>::SkRTConf(const char *name, const T &defaultValue, const char *descr
iption) |
| 93 : SkRTConfBase(name) | 99 : SkRTConfBase(name) |
| 94 , fValue(defaultValue) | 100 , fValue(defaultValue) |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 // static_cast here is okay because there's only one kind of child class. | 169 // static_cast here is okay because there's only one kind of child class. |
| 164 const SkRTConf<T> *child_pointer = static_cast<const SkRTConf<T> *>(conf); | 170 const SkRTConf<T> *child_pointer = static_cast<const SkRTConf<T> *>(conf); |
| 165 return child_pointer && | 171 return child_pointer && |
| 166 fName == child_pointer->fName && | 172 fName == child_pointer->fName && |
| 167 fDescription == child_pointer->fDescription && | 173 fDescription == child_pointer->fDescription && |
| 168 fValue == child_pointer->fValue && | 174 fValue == child_pointer->fValue && |
| 169 fDefault == child_pointer->fDefault; | 175 fDefault == child_pointer->fDefault; |
| 170 } | 176 } |
| 171 | 177 |
| 172 #endif | 178 #endif |
| OLD | NEW |