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