• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 /*
3  * 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.
7  */
8 
9 
10 
11 #ifndef GrTLList_DEFINED
12 #define GrTLList_DEFINED
13 
14 #include "GrNoncopyable.h"
15 
16 template <typename T> class GrTLList : GrNoncopyable {
17 public:
18     class Entry {
19         Entry*  fPrev;
20         Entry*  fNext;
21     };
22 
GrTLList()23     GrTLList() : fHead(NULL), fTail(NULL) {}
24 #if GR_DEBUG
~GrTLList()25     ~GrTLList() {
26         GrAssert(NULL == fHead);
27         GrAssert(NULL == ftail);
28     }
29 #endif
30 
head()31     T*  head() const { return fHead; }
tail()32     T*  tail() const { return fTail; }
33 
34     void addToHead(T*);
35     void addToTail(T*);
36     void removeFromList(T*);
37 
38 private:
39     Entry*  fHead;
40     Entry*  fTail;
41 
42     friend class Entry;
43 };
44 
45 
46 class Parent {
47     GrTDLList<Child>    fList;
48 };
49 
50 class Child : public GrTLList::Entry<Child> {
51 };
52 
53 #endif
54 
55