/* * Copyright 2008 The Android Open Source Project * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef SkPtrSet_DEFINED #define SkPtrSet_DEFINED #include "include/core/SkFlattenable.h" #include "include/core/SkRefCnt.h" #include "include/private/base/SkTDArray.h" #include <cstdint> /** * Maintains a set of ptrs, assigning each a unique ID [1...N]. Duplicate ptrs * return the same ID (since its a set). Subclasses can override inPtr() * and decPtr(). incPtr() is called each time a unique ptr is added ot the * set. decPtr() is called on each ptr when the set is destroyed or reset. */ class SkPtrSet : public SkRefCnt { … }; /** * Templated wrapper for SkPtrSet, just meant to automate typecasting * parameters to and from void* (which the base class expects). */ template <typename T> class SkTPtrSet : public SkPtrSet { … }; /** * Subclass of SkTPtrSet specialed to call ref() and unref() when the * base class's incPtr() and decPtr() are called. This makes it a valid owner * of each ptr, which is released when the set is reset or destroyed. */ class SkRefCntSet : public SkTPtrSet<SkRefCnt*> { … }; class SkFactorySet : public SkTPtrSet<SkFlattenable::Factory> { … }; /** * Similar to SkFactorySet, but only allows Factorys that have registered names. * Also has a function to return the next added Factory's name. */ class SkNamedFactorySet : public SkRefCnt { … }; #endif