blob: 8fa126b52777fa5fdbe3880cd7785ad0e6249ec3 (
about) (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
/*
list.hh -- part of flowerlib
(c) 1996 Han-Wen Nienhuys & Jan Nieuwenhuizen
*/
#ifndef PLIST_HH
#define PLIST_HH
#include "list.hh"
/// Use for list of pointers, e.g. PointerList<AbstractType*>.
template<class T>
class PointerList : public List<T>
{
public:
PointerList(PointerList&) { set_empty(); }
PointerList( const T& thing ) : List<T>( thing ) { }
PointerList() {}
///
virtual ~PointerList();
/**
This function deletes deletes the allocated pointers of all links.
#\Ref{~List}# is used to delete the links themselves.
*/
protected:
virtual void remove( Cursor<T> me );
};
/**
NOTE:
The copy constructor doesn't do what you'd want:
Since T might have a virtual ctor, we don't try to do a
new T(*cursor)
You have to copy this yourself, or use the macro PointerList__copy
*/
#define PointerList__copy(T, to, from, op) \
for (PCursor<T> _pc_(from); _pc_.ok(); _pc_++)\
to.bottom().add(_pc_->op)\
\
template<class T>
void PL_copy(PointerList<T*> &dst,PointerList<T*> const&src);
#define PL_instantiate(a) L_instantiate(a *); template class PointerList<a*>
#include "plist.inl"
#endif
|