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 #endif | 66 #endif |
67 | 67 |
68 /** \class SkRTConfRegistry | 68 /** \class SkRTConfRegistry |
69 A class that maintains a systemwide registry of all runtime configuration | 69 A class that maintains a systemwide registry of all runtime configuration |
70 parameters. Mainly used for printing them out and handling multiply-defined | 70 parameters. Mainly used for printing them out and handling multiply-defined |
71 knobs. | 71 knobs. |
72 */ | 72 */ |
73 | 73 |
74 class SkRTConfRegistry { | 74 class SkRTConfRegistry { |
75 public: | 75 public: |
76 SkRTConfRegistry(); | 76 SkRTConfRegistry(); |
mtklein
2014/08/07 12:26:14
SK_SUPPORT_UNITTEST is not defined anywhere. This
tfarina
2014/08/07 14:11:27
Done.
| |
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 template <typename T> bool parse(const char *name, T* value); |
tfarina
2014/08/07 03:05:40
I know you won't like this ;/
mtklein
2014/08/07 12:26:14
Seems fine, but let's keep it private and instead
tfarina
2014/08/07 14:11:27
Hum, who do I do that?
| |
88 static void UnitTest(); | 88 |
89 #endif | |
90 private: | 89 private: |
91 template<typename T> friend class SkRTConf; | 90 template<typename T> friend class SkRTConf; |
92 | 91 |
92 #ifdef SK_SUPPORT_UNITTEST | |
93 SkRTConfRegistry(); | |
tfarina
2014/08/07 03:05:40
you will probably want me to keep the bool paramet
mtklein
2014/08/07 12:26:14
I don't think so? If this test works as written,
tfarina
2014/08/07 14:11:27
Done.
| |
94 #endif | |
95 | |
93 void registerConf(SkRTConfBase *conf); | 96 void registerConf(SkRTConfBase *conf); |
94 template <typename T> bool parse(const char *name, T* value); | |
95 | 97 |
96 SkTDArray<SkString *> fConfigFileKeys, fConfigFileValues; | 98 SkTDArray<SkString *> fConfigFileKeys, fConfigFileValues; |
97 typedef SkTDict< SkTDArray<SkRTConfBase *> * > ConfMap; | 99 typedef SkTDict< SkTDArray<SkRTConfBase *> * > ConfMap; |
98 ConfMap fConfs; | 100 ConfMap fConfs; |
99 #ifdef SK_SUPPORT_UNITTEST | |
100 SkRTConfRegistry(bool); | |
101 #endif | |
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 |