Chromium Code Reviews| Index: include/core/SkTRegistry.h |
| diff --git a/include/core/SkTRegistry.h b/include/core/SkTRegistry.h |
| index 34fcffd5c51374cd422395fa7e547c287666a3b7..1a2558fc6bb0abf03613234d35073fa8b93bba87 100644 |
| --- a/include/core/SkTRegistry.h |
| +++ b/include/core/SkTRegistry.h |
| @@ -13,14 +13,13 @@ |
| #include "SkTypes.h" |
| /** Template class that registers itself (in the constructor) into a linked-list |
| - and provides a function-pointer. This can be used to auto-register a set of |
| + and provides a user-defined type. This can be used to auto-register a set of |
| services, e.g. a set of image codecs. |
| */ |
| -template <typename T, typename P> class SkTRegistry : SkNoncopyable { |
| +template <typename T> class SkTRegistry : SkNoncopyable { |
| public: |
| - typedef T (*Factory)(P); |
| - |
| - SkTRegistry(Factory fact) { |
| + typedef T Data; |
|
scroggo
2013/09/04 15:40:21
Would it make sense to write a partial specializat
|
| + explicit SkTRegistry(T data) { |
|
reed1
2013/09/04 15:15:23
(const T&) so we don't force the caller to make a
mtklein
2013/09/04 16:36:46
As we talked.
|
| #ifdef SK_BUILD_FOR_ANDROID |
| // work-around for double-initialization bug |
| { |
| @@ -33,24 +32,24 @@ public: |
| } |
| } |
| #endif |
| - fFact = fact; |
| + fData = data; |
| fChain = gHead; |
| - gHead = this; |
| + gHead = this; |
| } |
| static const SkTRegistry* Head() { return gHead; } |
| const SkTRegistry* next() const { return fChain; } |
| - Factory factory() const { return fFact; } |
| + Data data() const { return fData; } // fix |
|
reed1
2013/09/04 15:15:23
const Data& data() const { ... } ?
mtklein
2013/09/04 16:36:46
Done.
|
| private: |
| - Factory fFact; |
| + Data fData; |
| SkTRegistry* fChain; |
| static SkTRegistry* gHead; |
| }; |
| // The caller still needs to declare an instance of this somewhere |
| -template <typename T, typename P> SkTRegistry<T, P>* SkTRegistry<T, P>::gHead; |
| +template <typename T> SkTRegistry<T>* SkTRegistry<T>::gHead; |
| #endif |