dtinfo: remove register keyword
[oweals/cde.git] / cde / programs / dtinfo / dtinfo / src / Basic / List.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 /*
24  * $XConsortium: List.hh /main/7 1996/08/10 11:31:57 cde-hal $
25  *
26  * Copyright (c) 1992 HaL Computer Systems, Inc.  All rights reserved.
27  * UNPUBLISHED -- rights reserved under the Copyright Laws of the United
28  * States.  Use of a copyright notice is precautionary only and does not
29  * imply publication or disclosure.
30  * 
31  * This software contains confidential information and trade secrets of HaL
32  * Computer Systems, Inc.  Use, disclosure, or reproduction is prohibited
33  * without the prior express written permission of HaL Computer Systems, Inc.
34  * 
35  *                         RESTRICTED RIGHTS LEGEND
36  * Use, duplication, or disclosure by the Government is subject to
37  * restrictions as set forth in subparagraph (c)(l)(ii) of the Rights in
38  * Technical Data and Computer Software clause at DFARS 252.227-7013.
39  *                        HaL Computer Systems, Inc.
40  *                  1315 Dell Avenue, Campbell, CA  95008
41  * 
42  */
43
44
45
46 class List : public FolioObject
47 {
48 public: // variables
49   enum grow_method_t { GROW_ADD, GROW_MULTIPLY };
50   // notifications 
51   enum notifications { APPENDED = FolioObject::_LAST, INSERTED, REMOVED };
52
53 public: // functions
54   // increment really defaults to initial_size 
55   List (int initial_size, int increment = 0, grow_method_t method = GROW_ADD,
56         bool delete_elements = FALSE);
57   virtual ~List();
58   u_int length () const
59     { return (f_length); }
60   // NOTE: clean up and use either reference or ptr.  figure this out - DJB 
61   virtual void append (FolioObject &);
62   virtual void append (FolioObject *object)
63     { append (*object); }
64   virtual void remove (FolioObject &);
65   virtual void remove (FolioObject *object)
66     { remove (*object); }
67   virtual void remove (unsigned int);
68   // Change find to return FolioObect * 
69   virtual int  find   (FolioObject &);           // returns -1 on failure 
70   virtual void replace (int, FolioObject &);
71   virtual void replace (int i, FolioObject *obj);
72   virtual void insert (unsigned int, FolioObject *);
73   virtual void remove_all()
74     { f_length = 0; }
75   virtual void remove_all (bool delete_elements);
76
77   virtual FolioObject *operator[](int) const ;
78
79   virtual List *copy() const;   // NOTE: just copies the pointers, not the
80                                 // pointed at objects - jbm 
81
82   void dtor_delete_elements (bool delete_elements)
83     { f_dtor_delete_elements = delete_elements; }
84
85 protected: // functions
86   void check_space (int num_additions = 1);
87
88 protected: // variables
89   FolioObject    **f_list_element;        // array of list elements
90   unsigned short   f_length;
91   unsigned short   f_internal_length;
92   unsigned short   f_increment;
93   grow_method_t    f_grow_method;
94   bool             f_dtor_delete_elements : 1;
95 };
96
97 inline FolioObject *
98 List::operator[] (int position) const
99 {
100   // NOTE: need to be able to "throw" an exception here!!
101   if (position >= f_length)
102     abort ();
103
104   return (f_list_element[position]);
105 }
106
107 inline void
108 List::replace (int /* position */, FolioObject& /* element */)
109
110   // This function is obsolete, do not try to use
111   // someone needs to clean it up.
112   abort();
113 }
114
115 inline void
116 List::replace (int position, FolioObject *element)
117 {
118   replace (position, *element);
119 }
120