OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #ifndef SkRefDict_DEFINED | 10 #ifndef SkRefDict_DEFINED |
11 #define SkRefDict_DEFINED | 11 #define SkRefDict_DEFINED |
12 | 12 |
13 #include "SkRefCnt.h" | 13 #include "SkRefCnt.h" |
14 | 14 |
15 /** | 15 /** |
16 * A dictionary of string,refcnt pairs. The dictionary is also an owner of the | 16 * A dictionary of string,refcnt pairs. The dictionary is also an owner of the |
17 * refcnt objects while they are contained. | 17 * refcnt objects while they are contained. |
18 */ | 18 */ |
19 class SK_API SkRefDict : SkNoncopyable { | 19 class SK_API SkRefDict : SkNoncopyable { |
20 public: | 20 public: |
21 SkRefDict(); | 21 SkRefDict(); |
22 ~SkRefDict(); | 22 ~SkRefDict(); |
23 | 23 |
24 /** | 24 /** |
25 * Return the data associated with name[], or NULL if no matching entry | 25 * Return the data associated with name[], or nullptr if no matching entry |
26 * is found. The reference-count of the entry is not affected. | 26 * is found. The reference-count of the entry is not affected. |
27 */ | 27 */ |
28 SkRefCnt* find(const char name[]) const; | 28 SkRefCnt* find(const char name[]) const; |
29 | 29 |
30 /** | 30 /** |
31 * If data is NULL, remove (if present) the entry matching name and call | 31 * If data is nullptr, remove (if present) the entry matching name and call |
32 * prev_data->unref() on the data for the matching entry. | 32 * prev_data->unref() on the data for the matching entry. |
33 * If data is not-NULL, replace the existing entry matching name and | 33 * If data is not-nullptr, replace the existing entry matching name and |
34 * call (prev_data->unref()), or add a new one. In either case, | 34 * call (prev_data->unref()), or add a new one. In either case, |
35 * data->ref() is called. | 35 * data->ref() is called. |
36 */ | 36 */ |
37 void set(const char name[], SkRefCnt* data); | 37 void set(const char name[], SkRefCnt* data); |
38 | 38 |
39 /** | 39 /** |
40 * Remove the matching entry (if found) and unref its data. | 40 * Remove the matching entry (if found) and unref its data. |
41 */ | 41 */ |
42 void remove(const char name[]) { this->set(name, NULL); } | 42 void remove(const char name[]) { this->set(name, nullptr); } |
43 | 43 |
44 /** | 44 /** |
45 * Remove all entries, and unref() their associated data. | 45 * Remove all entries, and unref() their associated data. |
46 */ | 46 */ |
47 void removeAll(); | 47 void removeAll(); |
48 | 48 |
49 private: | 49 private: |
50 struct Impl; | 50 struct Impl; |
51 Impl* fImpl; | 51 Impl* fImpl; |
52 }; | 52 }; |
53 | 53 |
54 #endif | 54 #endif |
OLD | NEW |