* src/vm/javaobjects.cpp (java_lang_reflect_Method::invoke): [OPENJDK] stack
[cacao.git] / src / toolbox / list.hpp
1 /* src/toolbox/list.hpp - linked list
2
3    Copyright (C) 1996-2005, 2006, 2007, 2008
4    CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
5
6    This file is part of CACAO.
7
8    This program is free software; you can redistribute it and/or
9    modify it under the terms of the GNU General Public License as
10    published by the Free Software Foundation; either version 2, or (at
11    your option) any later version.
12
13    This program is distributed in the hope that it will be useful, but
14    WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16    General Public License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21    02110-1301, USA.
22
23 */
24
25
26 #ifndef _LIST_HPP
27 #define _LIST_HPP
28
29 #include "config.h"
30
31 #include <stdint.h>
32
33 #ifdef __cplusplus
34
35 #include <list>
36
37 /**
38  * List implementation.
39  */
40 template<class T> class List : protected std::list<T> {
41 public:
42         // make iterator of std::list visible
43         using std::list<T>::iterator;
44         using std::list<T>::reverse_iterator;
45
46         // make functions of std::list visible
47         using std::list<T>::back;
48         using std::list<T>::begin;
49         using std::list<T>::clear;
50         using std::list<T>::empty;
51         using std::list<T>::end;
52         using std::list<T>::front;
53         using std::list<T>::push_back;
54         using std::list<T>::push_front;
55         using std::list<T>::rbegin;
56         using std::list<T>::remove;
57         using std::list<T>::rend;
58         using std::list<T>::size;
59 };
60
61
62 // Required by LockedList.
63 #include "threads/mutex.hpp"
64
65
66 /**
67  * List implementation with a Mutex.
68  */
69 template<class T> class LockedList : public List<T> {
70 private:
71         Mutex _mutex;
72
73 public:
74         virtual ~LockedList() {}
75
76         void lock  () { _mutex.lock(); }
77         void unlock() { _mutex.unlock(); }
78 };
79
80
81 // Required by DumpList.
82 #include "mm/dumpmemory.hpp"
83
84
85 /**
86  * List implementation with dump memory.
87  */
88 template<class T> class DumpList :
89                 public DumpClass,
90                 protected std::list<T, DumpMemoryAllocator<T> > {
91 public:
92         virtual ~DumpList() {}
93
94         // make iterator of std::list visible
95         using std::list<T, DumpMemoryAllocator<T> >::iterator;
96         using std::list<T, DumpMemoryAllocator<T> >::reverse_iterator;
97
98         // make functions of std::list visible
99         using std::list<T, DumpMemoryAllocator<T> >::back;
100         using std::list<T, DumpMemoryAllocator<T> >::begin;
101         using std::list<T, DumpMemoryAllocator<T> >::clear;
102         using std::list<T, DumpMemoryAllocator<T> >::empty;
103         using std::list<T, DumpMemoryAllocator<T> >::end;
104         using std::list<T, DumpMemoryAllocator<T> >::front;
105         using std::list<T, DumpMemoryAllocator<T> >::push_back;
106         using std::list<T, DumpMemoryAllocator<T> >::push_front;
107         using std::list<T, DumpMemoryAllocator<T> >::rbegin;
108         using std::list<T, DumpMemoryAllocator<T> >::remove;
109         using std::list<T, DumpMemoryAllocator<T> >::rend;
110         using std::list<T, DumpMemoryAllocator<T> >::size;
111         using std::list<T, DumpMemoryAllocator<T> >::sort;
112 };
113
114 #else
115
116 typedef struct List List;
117 typedef struct LockedList LockedList;
118 typedef struct DumpList DumpList;
119
120 #endif
121
122 #endif // _LIST_HPP
123
124
125 /*
126  * These are local overrides for various environment variables in Emacs.
127  * Please do not remove this and leave it at the end of the file, where
128  * Emacs will automagically detect them.
129  * ---------------------------------------------------------------------
130  * Local variables:
131  * mode: c++
132  * indent-tabs-mode: t
133  * c-basic-offset: 4
134  * tab-width: 4
135  * End:
136  * vim:noexpandtab:sw=4:ts=4:
137  */