--- /dev/null
+/*
+ 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
--- /dev/null
+/* -*-c++-*-
+ plist.inl -- part of flowerlib
+
+ (c) 1996 Han-Wen Nienhuys& Jan Nieuwenhuizen
+*/
+
+#ifndef PLIST_INL
+#define PLIST_INL
+
+
+
+template<class T>
+inline
+PointerList<T>::~PointerList()
+{
+ Cursor<T> next(*this);
+ for ( Cursor<T> c( *this ); c.ok(); c = next ) {
+ next = c;
+ next++;
+ remove( c ); // PointerList::remove deletes the real data
+ }
+}
+
+template<class T>
+inline void
+PointerList_print( PointerList<T> const & l )
+{
+ List<T>& promises_to_be_const = (List<T>&) l;
+ for ( Cursor<T> c( promises_to_be_const ); c.ok(); c++ )
+ (*c)->print();
+}
+
+template<class T>
+inline void
+PL_copy(PointerList<T> &to,PointerList<T> const&src)
+{
+ for (PCursor<T> pc(src); pc.ok(); pc++) {
+ T q = pc;
+ T p=new typeof(*q) (*q) ; // argh, how do i do this in ANSI-C++
+ to.bottom().add(p);
+ }
+}
+#endif