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