Disable all code related to libXp
[oweals/cde.git] / cde / programs / dtinfo / DtMmdb / dti_cc / CC_Listbase.h
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 librararies 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 /*
24  * $XConsortium: CC_Listbase.h /main/4 1996/08/21 15:48:41 drk $
25  *
26  * Copyright (c) 1993 HAL Computer Systems International, Ltd.
27  * All rights reserved.  Unpublished -- rights reserved under
28  * the Copyright Laws of the United States.  USE OF A COPYRIGHT
29  * NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
30  * OR DISCLOSURE.
31  * 
32  * THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
33  * SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.  USE,
34  * DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
35  * PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
36  * INTERNATIONAL, LTD.
37  * 
38  *                         RESTRICTED RIGHTS LEGEND
39  * Use, duplication, or disclosure by the Government is subject
40  * to the restrictions as set forth in subparagraph (c)(l)(ii)
41  * of the Rights in Technical Data and Computer Software clause
42  * at DFARS 252.227-7013.
43  *
44  *          HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
45  *                  1315 Dell Avenue
46  *                  Campbell, CA  95008
47  * 
48  */
49
50 #ifndef _CC_Listbase_hh
51 #define _CC_Listbase_hh
52
53 #include <stdio.h>
54 #include "dti_cc/types.h"
55
56 #ifndef NULL
57 #define NULL 0
58 #endif
59
60 // forward declaration
61 class CC_List_Iterator_base;
62 class CC_Listbase;
63
64 // Base classes for List template. 
65 // Link_base can be used by both doubly and singly linked list
66 class CC_Link_base
67 {
68 friend class CC_Listbase;
69 friend class CC_List_Iterator_base;
70 public:
71   CC_Link_base():f_next(NULL),f_prev(NULL) {}
72
73 private:
74
75   CC_Link_base *f_next;
76   CC_Link_base *f_prev;
77 };
78
79
80
81 class CC_Listbase
82 {
83 friend class CC_List_Iterator_base;
84
85 protected:
86   CC_Link_base *remove(CC_List_Iterator_base &);
87
88 public:
89   CC_Listbase()
90     : f_head (NULL), f_tail (NULL), f_length (0)
91     { }
92
93   void insert (CC_Link_base *);  /* both insert and append is the same,
94                                * throw ccException() if element is NULL
95                                */
96
97   void append (CC_Link_base *e)  // in order to be Rogue Wave compatible
98   { insert(e); }
99
100   void prepend (CC_Link_base *); /*
101                                * throw ccException() if element is NULL
102                                */
103
104
105
106   size_t entries() const        // RW compatible
107     { return (f_length); }
108
109   CC_Link_base *first() const
110   { return (f_head); }
111
112   CC_Link_base *last() const
113   { return (f_tail); }
114
115   CC_Link_base *removeLast();
116   CC_Link_base *removeFirst();
117
118 protected:
119   CC_Link_base    *f_head;
120   CC_Link_base    *f_tail;
121   size_t        f_length;
122 };
123
124
125 class CC_List_Iterator_base
126 {
127 friend class CC_Listbase;
128 public:
129
130   CC_List_Iterator_base (CC_Listbase *list); /* will throw ccException if 
131                                                * list == NULL 
132                                                */
133   // Obtain the current link entry.
134   CC_Link_base *item() const
135     { return (f_current); }
136
137   // Reset the iterator to the first list element. 
138   void reset();
139
140   // Increment the iterator. 
141   CC_Boolean operator++();
142   CC_Boolean operator--();
143
144 protected:
145   const CC_Listbase *f_list;
146   CC_Link_base       *f_previous;
147   CC_Link_base       *f_current;
148 };
149
150 #endif /* _CC_Listbasehh */
151 /* DO NOT ADD ANY LINES AFTER THIS #endif */