dtinfo: remove register keyword
[oweals/cde.git] / cde / programs / dtinfo / dtinfo / src / Basic / OrderList.hh
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these libraries and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 // $XConsortium: OrderList.hh /main/3 1996/06/11 16:21:08 cde-hal $
24 #ifndef _OrderListType_hh
25 #define _OrderListType_hh
26
27
28 // List status definitions
29
30 #define OLIST_ERROR        (int)-1
31 #define OLIST_OK           (int)1
32 #define OLIST_NOOP         (int)0
33 #define OLIST_LAST_REMOVD  (int)100
34 #define OLIST_TAIL_REMOVD  (int)101
35 #define OLIST_HEAD_REMOVD  (int)102
36
37 // Where flags for add
38
39 enum AddCode {
40         addAfter,               // Add after list cursor
41         addBefore,              // Add before list cursor
42         addHead,                // Add at list head
43         addTail                 // Add at list tail
44 };
45
46 class ListEntry;
47
48 class OrderList {
49  public:
50     // Constructor
51     OrderList();
52     // Destructor
53     ~OrderList();
54     // Public methods
55     void       clear();
56     int        add(ListEntry *entry, AddCode where, bool mvcursor = 1);
57     int        remove();
58     ListEntry *extract();
59     bool    isempty();
60     int        size();
61     int        next();
62     int        prev();
63     int        head();
64     int        tail();
65     ListEntry *value();
66     ListEntry *set_cursor(ListEntry *cursor_pos);
67     // NOTE: could just put the OrderList as user data
68     ListEntry *iterate(bool (*fn)(ListEntry *, void *), void *usr_def);
69     ListEntry *iterate(bool (*fn)(OrderList *, ListEntry *, void *), void *usr_def);
70   private:
71     // Private data
72     int                 f_size   ;
73     ListEntry          *f_head   ;
74     ListEntry          *f_tail   ;
75     ListEntry          *f_cursor ;
76     
77     // Private methods
78     void insertNew    (ListEntry *node);
79     void insertAfter  (ListEntry *node);
80     void insertBefore (ListEntry *node);
81     void insertTail   (ListEntry *node);
82     void insertHead   (ListEntry *node);
83 };
84
85 inline OrderList::OrderList()
86 : f_size(0),
87   f_head(NULL),
88   f_tail(NULL),
89   f_cursor(NULL)
90 {
91 }
92
93 inline int
94 OrderList::size()
95 {
96     return f_size ;
97 }
98
99 inline bool
100 OrderList::isempty()
101 {
102     if (f_size)
103       return FALSE;
104     else
105       return TRUE;
106 }
107
108 inline ListEntry    *
109 OrderList::value()
110 {
111     return f_cursor;
112 }
113
114 inline ListEntry *
115 OrderList::set_cursor(ListEntry *value)
116 {
117     assert(value != NULL);
118     f_cursor = value ;
119     return f_cursor ;
120 }
121 // //////////////////////////////////////////////////////////////
122 // List entry class
123 // //////////////////////////////////////////////////////////////
124
125 class ListEntry : public FolioObject {
126 friend class OrderList;
127     
128   public:
129     ListEntry () ;
130     virtual ~ListEntry ();
131     
132   private:
133     ListEntry   *f_prev ;
134     ListEntry   *f_next ;
135 } ;
136
137 inline 
138 ListEntry::ListEntry() 
139 : f_prev(NULL),
140   f_next(NULL)
141 {
142 }
143
144 #endif                          /* _OrderListType_hh */