blob: ea310ac20ec781d0297de50aad039d2f2f66e5c6 [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
reed@google.comac10a2d2010-12-22 21:39:39 +00002/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00003 * Copyright 2010 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
reed@google.comac10a2d2010-12-22 21:39:39 +00007 */
8
9
epoger@google.comec3ed6a2011-07-28 14:26:00 +000010
reed@google.comac10a2d2010-12-22 21:39:39 +000011#ifndef GrTLList_DEFINED
12#define GrTLList_DEFINED
13
14#include "GrNoncopyable.h"
15
16template <typename T> class GrTLList : GrNoncopyable {
17public:
18 class Entry {
19 Entry* fPrev;
20 Entry* fNext;
21 };
22
23 GrTLList() : fHead(NULL), fTail(NULL) {}
24#if GR_DEBUG
25 ~GrTLList() {
26 GrAssert(NULL == fHead);
27 GrAssert(NULL == ftail);
28 }
29#endif
30
31 T* head() const { return fHead; }
32 T* tail() const { return fTail; }
33
34 void addToHead(T*);
35 void addToTail(T*);
36 void removeFromList(T*);
37
38private:
39 Entry* fHead;
40 Entry* fTail;
41
42 friend class Entry;
43};
44
45
46class Parent {
47 GrTDLList<Child> fList;
48};
49
50class Child : public GrTLList::Entry<Child> {
51};
52
53#endif
54