2011-01-25 23:50:57 +00:00
|
|
|
|
2011-07-28 14:26:00 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2011 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
2011-01-25 23:50:57 +00:00
|
|
|
*/
|
|
|
|
|
2011-07-28 14:26:00 +00:00
|
|
|
|
2011-01-25 23:36:05 +00:00
|
|
|
#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.
|
|
|
|
*/
|
2011-03-15 21:27:08 +00:00
|
|
|
class SK_API SkRefDict : SkNoncopyable {
|
2011-01-25 23:36:05 +00:00
|
|
|
public:
|
|
|
|
SkRefDict();
|
|
|
|
~SkRefDict();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the data associated with name[], or NULL if no matching entry
|
|
|
|
* is found. The reference-count of the entry is not affected.
|
|
|
|
*/
|
|
|
|
SkRefCnt* find(const char name[]) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* If data is NULL, remove (if present) the entry matching name and call
|
|
|
|
* prev_data->unref() on the data for the matching entry.
|
|
|
|
* If data is not-NULL, 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, NULL); }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove all entries, and unref() their associated data.
|
|
|
|
*/
|
|
|
|
void removeAll();
|
|
|
|
|
|
|
|
private:
|
|
|
|
struct Impl;
|
|
|
|
Impl* fImpl;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|