2 * LoopDetectorInfo.h - TaskJuggler
4 * Copyright (c) 2002, 2003, 2004, 2005, 2006 by Chris Schlaeger <cs@kde.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of version 2 of the GNU General Public License as
8 * published by the Free Software Foundation.
13 #ifndef _LoopDetectorInfo_h_
14 #define _LoopDetectorInfo_h_
16 class LoopDetectorInfo;
19 * This class stores information about a waypoint the dependency loop
20 * detector passes when looking for loops.
22 * @short Utility class for the dependency loop detector.
23 * @author Chris Schlaeger <cs@kde.org>
25 class LoopDetectorInfo
36 LoopDetectorInfo(const Task* _t, bool ae) :
43 ~LoopDetectorInfo() { }
45 bool operator==(const LoopDetectorInfo& ldi) const
47 return t == ldi.t && atEnd == ldi.atEnd;
49 bool operator!=(const LoopDetectorInfo& ldi) const
51 return t != ldi.t || atEnd != ldi.atEnd;
53 const Task* getTask() const { return t; }
54 bool getAtEnd() const { return atEnd; }
55 LoopDetectorInfo* next() const { return nextLDI; }
56 LoopDetectorInfo* prev() const { return prevLDI; }
58 LoopDetectorInfo* nextLDI;
59 LoopDetectorInfo* prevLDI;
66 * This class stores the waypoints the dependency loop detector passes when
67 * looking for loops. Since it is very performance critical we use a
68 * handrolled list class instead of a Qt class.
70 * @short Waypoint list of the dependency loop detector.
71 * @author Chris Schlaeger <cs@kde.org>
82 LDIList(LDIList& list) :
87 for (LoopDetectorInfo* p = list.root; p; p = p->nextLDI)
88 append(new LoopDetectorInfo(p->t, p->atEnd));
93 for (LoopDetectorInfo* p = root; p; p = root)
99 LoopDetectorInfo* first() const { return root; }
100 LoopDetectorInfo* last() const { return leaf; }
101 long count() const { return items; }
103 bool find(const LoopDetectorInfo* ref) const
105 for (LoopDetectorInfo* p = root; p; p = p->nextLDI)
112 void append(LoopDetectorInfo* p)
123 leaf = leaf->nextLDI;
137 leaf = leaf->prevLDI;
138 delete leaf->nextLDI;
143 LoopDetectorInfo* popLast()
145 LoopDetectorInfo* lst = leaf;
150 leaf = leaf->prevLDI;
154 lst->prevLDI = lst->nextLDI = 0;
159 LoopDetectorInfo* root;
160 LoopDetectorInfo* leaf;