Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1217)

Side by Side Diff: include/utils/SkRTConf.h

Issue 54503007: New SkRTConf macro SK_CONF_TRY_SET: no complaint on missing configuration (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: whitespace change for ifdefs Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « gyp/tests.gyp ('k') | src/utils/SkRTConf.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 protected: 45 protected:
46 void doPrint(char *s) const; 46 void doPrint(char *s) const;
47 47
48 T fValue; 48 T fValue;
49 T fDefault; 49 T fDefault;
50 SkString fDescription; 50 SkString fDescription;
51 }; 51 };
52 52
53 #ifdef SK_DEVELOPER 53 #ifdef SK_DEVELOPER
54 #define SK_CONF_DECLARE(confType, varName, confName, defaultValue, description) static SkRTConf<confType> varName(confName, defaultValue, description) 54 #define SK_CONF_DECLARE(confType, varName, confName, defaultValue, description) static SkRTConf<confType> varName(confName, defaultValue, description)
55 #define SK_CONF_SET(confname, value) skRTConfRegistry().set(confname, value) 55 #define SK_CONF_SET(confname, value) \
reed1 2013/11/06 15:02:21 at some point we should clean-up the readability o
56 skRTConfRegistry().set(confname, value, true)
57 /* SK_CONF_TRY_SET() is like SK_CONF_SET(), but doesn't complain if
58 confname can't be found. This is useful if the SK_CONF_DECLARE is
59 inside a source file whose linkage is dependent on the system. */
60 #define SK_CONF_TRY_SET(confname, value) \
61 skRTConfRegistry().set(confname, value, false)
56 #else 62 #else
57 #define SK_CONF_DECLARE(confType, varName, confName, defaultValue, description) static confType varName = defaultValue 63 #define SK_CONF_DECLARE(confType, varName, confName, defaultValue, description) static confType varName = defaultValue
58 #define SK_CONF_SET(confname, value) (void) confname, (void) value 64 #define SK_CONF_SET(confname, value) (void) confname, (void) value
65 #define SK_CONF_TRY_SET(confname, value) (void) confname, (void) value
59 #endif 66 #endif
60 67
61 /** \class SkRTConfRegistry 68 /** \class SkRTConfRegistry
62 A class that maintains a systemwide registry of all runtime configuration 69 A class that maintains a systemwide registry of all runtime configuration
63 parameters. Mainly used for printing them out and handling multiply-defined 70 parameters. Mainly used for printing them out and handling multiply-defined
64 knobs. 71 knobs.
65 */ 72 */
66 73
67 class SkRTConfRegistry { 74 class SkRTConfRegistry {
68 public: 75 public:
69 SkRTConfRegistry(); 76 SkRTConfRegistry();
70 void printAll(const char *fname = NULL) const; 77 void printAll(const char *fname = NULL) const;
71 void printNonDefault(const char *fname = NULL) const; 78 void printNonDefault(const char *fname = NULL) const;
72 const char *configFileLocation() const; 79 const char *configFileLocation() const;
73 void possiblyDumpFile() const; 80 void possiblyDumpFile() const;
74 void validate() const; 81 void validate() const;
75 template <typename T> void set(const char *confname, T value); 82 template <typename T> void set(const char *confname,
83 T value,
84 bool warnIfNotFound = true);
76 #ifdef SK_SUPPORT_UNITTEST 85 #ifdef SK_SUPPORT_UNITTEST
77 static void UnitTest(); 86 static void UnitTest();
78 #endif 87 #endif
79 private: 88 private:
80 template<typename T> friend class SkRTConf; 89 template<typename T> friend class SkRTConf;
81 90
82 void registerConf(SkRTConfBase *conf); 91 void registerConf(SkRTConfBase *conf);
83 template <typename T> bool parse(const char *name, T* value); 92 template <typename T> bool parse(const char *name, T* value);
84 93
85 SkTDArray<SkString *> fConfigFileKeys, fConfigFileValues; 94 SkTDArray<SkString *> fConfigFileKeys, fConfigFileValues;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 // static_cast here is okay because there's only one kind of child class. 184 // static_cast here is okay because there's only one kind of child class.
176 const SkRTConf<T> *child_pointer = static_cast<const SkRTConf<T> *>(conf); 185 const SkRTConf<T> *child_pointer = static_cast<const SkRTConf<T> *>(conf);
177 return child_pointer && 186 return child_pointer &&
178 fName == child_pointer->fName && 187 fName == child_pointer->fName &&
179 fDescription == child_pointer->fDescription && 188 fDescription == child_pointer->fDescription &&
180 fValue == child_pointer->fValue && 189 fValue == child_pointer->fValue &&
181 fDefault == child_pointer->fDefault; 190 fDefault == child_pointer->fDefault;
182 } 191 }
183 192
184 #endif 193 #endif
OLDNEW
« no previous file with comments | « gyp/tests.gyp ('k') | src/utils/SkRTConf.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698