remove ultrix support
[oweals/cde.git] / cde / lib / tt / lib / util / tt_object_list.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 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 /*%%  (c) Copyright 1993, 1994 Hewlett-Packard Company                   */
24 /*%%  (c) Copyright 1993, 1994 International Business Machines Corp.     */
25 /*%%  (c) Copyright 1993, 1994 Sun Microsystems, Inc.                    */
26 /*%%  (c) Copyright 1993, 1994 Novell, Inc.                              */
27 /*%%  $XConsortium: tt_object_list.h /main/3 1995/10/23 10:42:45 rswiston $                                                      */
28 /*
29  *
30  * tt_object_list.h
31  *
32  * Copyright (c) 1990 by Sun Microsystems, Inc.
33  */
34 #ifndef _TT_OBJECT_LIST_H
35 #define _TT_OBJECT_LIST_H
36 #include <stdio.h>
37 #include <rpc/rpc.h>
38 #include <util/tt_ptr.h>
39 #include <util/tt_object.h>
40 #if defined(OPT_BUG_HPUX) || defined(OPT_BUG_AIX)
41 #       undef remove
42 #endif
43
44 class _Tt_object_list_element;
45 class _Tt_object_list_ptr;
46 class _Tt_object_list: public _Tt_object {
47         friend class _Tt_object_list_cursor;
48       public:
49         _Tt_object_list();
50         _Tt_object_list(const _Tt_object_list &t);
51         virtual ~_Tt_object_list();
52         void flush();
53         _Tt_object_list &push(const _Tt_object_ptr &e);
54         _Tt_object_list &pop();
55         _Tt_object_list &append(const _Tt_object_ptr &e);
56         _Tt_object_list &append(_Tt_object_list_ptr l);
57         _Tt_object_list &append_destructive(_Tt_object_list_ptr l);
58         _Tt_object_list &dequeue();
59         _Tt_object_ptr &top() const;
60         _Tt_object_ptr &bot() const;
61         _Tt_object_ptr &operator[] (int n) const;
62         int is_empty() const;
63         int count() const {
64                 return _count;
65         }
66         bool_t xdr(XDR * /* xdrs */) {
67                 fprintf(stderr,"Warning: _Tt_object_list::xdr called");
68                 return 0;
69         }
70         bool_t xdr(XDR *xdrs, _Tt_new_xdrfn xdrfn, _Tt_object *(*make_new)());
71         void print(_Tt_object_printfn print_elt, const _Tt_ostream &os) const;
72         int verify(int (*verifier)(const _Tt_object *));
73       public:
74         int _count;
75         _Tt_object_list_element *first, *last;
76 };
77 declare_ptr_to(_Tt_object_list)
78
79 class _Tt_object_list_element : public _Tt_allocated {
80         friend class _Tt_object_list;
81         friend class _Tt_object_list_cursor;
82       private:
83         _Tt_object_list_element();
84         ~_Tt_object_list_element();
85         _Tt_object_ptr data;
86         _Tt_object_list_element *next, *prev;
87 };
88
89 class _Tt_object_list_cursor : public _Tt_allocated {
90       public:
91         _Tt_object_list_cursor();
92         ~_Tt_object_list_cursor();
93         _Tt_object_list_cursor(const _Tt_object_list_cursor &c);
94         _Tt_object_list_cursor(const _Tt_object_list_ptr &l);
95         _Tt_object_ptr &operator *() const;
96         _Tt_object_ptr &operator->() const;
97         _Tt_object_list_cursor &reset();
98         _Tt_object_list_cursor &reset(const _Tt_object_list_ptr &l);
99         int next();
100         int prev();
101         _Tt_object_list_cursor &insert(const _Tt_object_ptr &p);
102         _Tt_object_list_cursor &remove();
103         int is_valid() const;
104       private:
105         _Tt_object_list_element *current;
106         _Tt_object_list_ptr listhdr;
107         enum { DELETED, INIT };
108         int flags;
109 };
110
111 #endif                          /* _TT_OBJECT_LIST_H */