Code

moving trunk for module inkscape
[inkscape.git] / cxxtest / cxxtest / LinkedList.h
1 #ifndef __cxxtest__LinkedList_h__
2 #define __cxxtest__LinkedList_h__
4 #include <cxxtest/Flags.h>
6 namespace CxxTest 
7 {
8     struct List;
9     class Link;
11     struct List
12     {
13         Link *_head;
14         Link *_tail;
16         void initialize();
18         Link *head();
19         const Link *head() const;
20         Link *tail();
21         const Link *tail() const;
23         bool empty() const;
24         unsigned size() const;
25         Link *nth( unsigned n );
27         void activateAll();
28         void leaveOnly( const Link &link );
29     };
31     class Link
32     {       
33     public:
34         Link();
35         virtual ~Link();
37         bool active() const;
38         void setActive( bool value = true );
40         Link *justNext();
41         Link *justPrev();
42         
43         Link *next();
44         Link *prev();
45         const Link *next() const;
46         const Link *prev() const;
48         virtual bool setUp() = 0;
49         virtual bool tearDown() = 0;
51         void attach( List &l );
52         void detach( List &l );
54     private:
55         Link *_next;
56         Link *_prev;
57         bool _active;
59         Link( const Link & );
60         Link &operator=( const Link & );
61     };
62 }
64 #endif // __cxxtest__LinkedList_h__