blob: 1f59635ad4797108a2c93d91973b086fa9407f6b [file] [log] [blame]
reed@google.comac10a2d2010-12-22 21:39:39 +00001/*
2 Copyright 2010 Google Inc.
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15 */
16
17
18#ifndef GrTLList_DEFINED
19#define GrTLList_DEFINED
20
21#include "GrNoncopyable.h"
22
23template <typename T> class GrTLList : GrNoncopyable {
24public:
25 class Entry {
26 Entry* fPrev;
27 Entry* fNext;
28 };
29
30 GrTLList() : fHead(NULL), fTail(NULL) {}
31#if GR_DEBUG
32 ~GrTLList() {
33 GrAssert(NULL == fHead);
34 GrAssert(NULL == ftail);
35 }
36#endif
37
38 T* head() const { return fHead; }
39 T* tail() const { return fTail; }
40
41 void addToHead(T*);
42 void addToTail(T*);
43 void removeFromList(T*);
44
45private:
46 Entry* fHead;
47 Entry* fTail;
48
49 friend class Entry;
50};
51
52
53class Parent {
54 GrTDLList<Child> fList;
55};
56
57class Child : public GrTLList::Entry<Child> {
58};
59
60#endif
61