gfx/skia/trunk/src/core/SkRefDict.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/skia/trunk/src/core/SkRefDict.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,54 @@
     1.4 +
     1.5 +/*
     1.6 + * Copyright 2011 Google Inc.
     1.7 + *
     1.8 + * Use of this source code is governed by a BSD-style license that can be
     1.9 + * found in the LICENSE file.
    1.10 + */
    1.11 +
    1.12 +
    1.13 +#ifndef SkRefDict_DEFINED
    1.14 +#define SkRefDict_DEFINED
    1.15 +
    1.16 +#include "SkRefCnt.h"
    1.17 +
    1.18 +/**
    1.19 + *  A dictionary of string,refcnt pairs. The dictionary is also an owner of the
    1.20 + *  refcnt objects while they are contained.
    1.21 + */
    1.22 +class SK_API SkRefDict : SkNoncopyable {
    1.23 +public:
    1.24 +    SkRefDict();
    1.25 +    ~SkRefDict();
    1.26 +
    1.27 +    /**
    1.28 +     *  Return the data associated with name[], or NULL if no matching entry
    1.29 +     *  is found. The reference-count of the entry is not affected.
    1.30 +     */
    1.31 +    SkRefCnt* find(const char name[]) const;
    1.32 +
    1.33 +    /**
    1.34 +     *  If data is NULL, remove (if present) the entry matching name and call
    1.35 +     *  prev_data->unref() on the data for the matching entry.
    1.36 +     *  If data is not-NULL, replace the existing entry matching name and
    1.37 +     *  call (prev_data->unref()), or add a new one. In either case,
    1.38 +     *  data->ref() is called.
    1.39 +     */
    1.40 +    void set(const char name[], SkRefCnt* data);
    1.41 +
    1.42 +    /**
    1.43 +     *  Remove the matching entry (if found) and unref its data.
    1.44 +     */
    1.45 +    void remove(const char name[]) { this->set(name, NULL); }
    1.46 +
    1.47 +    /**
    1.48 +     *  Remove all entries, and unref() their associated data.
    1.49 +     */
    1.50 +    void removeAll();
    1.51 +
    1.52 +private:
    1.53 +    struct Impl;
    1.54 +    Impl* fImpl;
    1.55 +};
    1.56 +
    1.57 +#endif

mercurial