Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / programs / dtappbuilder / src / libABobj / obj_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 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 /*
25  *      $XConsortium: obj_list.h /main/3 1995/11/06 18:36:04 rswiston $
26  *
27  * @(#)template.h       1.6 11 Feb 1994 cde_app_builder/src/libAButil
28  *
29  *      RESTRICTED CONFIDENTIAL INFORMATION:
30  *      
31  *      The information in this document is subject to special
32  *      restrictions in a confidential disclosure agreement between
33  *      HP, IBM, Sun, USL, SCO and Univel.  Do not distribute this
34  *      document outside HP, IBM, Sun, USL, SCO, or Univel without
35  *      Sun's specific written approval.  This document and all copies
36  *      and derivative works thereof must be returned or destroyed at
37  *      Sun's request.
38  *
39  *      Copyright 1993 Sun Microsystems, Inc.  All rights reserved.
40  *
41  */
42
43 #ifndef _ABOBJ_OBJ_LIST_H_
44 #define _ABOBJ_OBJ_LIST_H_
45
46 /*
47  * obj_list.h - define ABObjList data type
48  */
49 #ifndef _POSIX_SOURCE
50 #define _POSIX_SOURCE 1         /* we want to be POSIX-compliant */
51 #endif
52
53 #include <ab_private/AB.h>      /* everybody must include this first! */
54 #include <ab/util_types.h>
55
56 extern struct _AB_OBJ;
57 #define ABObj struct _AB_OBJ *
58
59 typedef enum
60 {
61     OBJLIST_SORT_UNDEF = 0,
62     OBJLIST_SORT_ALPHANUMERIC,
63     OBJLIST_SORT_BEST,
64     OBJLIST_SORT_CLIENT_DEF,
65     OBJLIST_SORT_ORDER_NUM_VALUES       /* must be last */
66 } OBJLIST_SORT_ORDER;
67
68 typedef void (*ABObjListIterFn)(ABObj obj);
69
70 /*
71  * obj list structure.
72  */
73 typedef struct
74 {
75     int                 num_objs;
76     int                 objs_size;
77     ABObj               *objs;
78     void                **user_datas;
79     BOOL                unique;
80     OBJLIST_SORT_ORDER  sort_order;
81     BOOL                indexes_dirty;
82 } ABObjListRec, *ABObjList;
83
84 #undef ABObj
85 #include <ab_private/obj.h>
86
87 /*
88  * ABObjList - lifecycle methods
89  */
90 ABObjList       objlist_create(void);
91 int             objlist_destroy(ABObjList);
92 int             objlist_construct(ABObjList);
93 int             objlist_destruct(ABObjList);
94 ABObjList       objlist_dup(ABObjList);
95
96 /*
97  * ABObjList - methods dealing with entire list
98  */
99 int             objlist_set_sort_order(ABObjList, OBJLIST_SORT_ORDER);
100 OBJLIST_SORT_ORDER      objlist_get_sort_order(ABObjList);
101 int             objlist_set_is_unique(ABObjList, BOOL unique);
102 BOOL            objlist_is_unique(ABObjList);
103 int             objlist_make_empty(ABObjList);
104 int             objlist_is_empty(ABObjList);
105 int             objlist_set_num_objs(ABObjList, int numABObjs);
106 int             objlist_get_num_objs(ABObjList);
107 int             objlist_set_max_size_soft(ABObjList, int maxNumObjs);
108 int             objlist_get_max_size(ABObjList);
109 BOOL            objlist_max_size_is_soft(ABObjList);
110 int             objlist_shrink_mem_to_fit(ABObjList);
111 int             objlist_iterate(ABObjList, ABObjListIterFn);
112
113 /*
114  * Methods dealing with individual objects
115  */
116 int             objlist_remove_obj(ABObjList, ABObj obj);
117 int             objlist_remove_index(ABObjList, int index);
118 int             objlist_add_obj(ABObjList, ABObj obj, void *userData);
119 int             objlist_add_index(ABObjList, 
120                                 int index, ABObj obj, void *userData);
121 BOOL            objlist_obj_exists(ABObjList list, ABObj obj);
122 int             objlist_get_obj_index(ABObjList list, ABObj obj);
123 ABObj           objlist_get_obj(ABObjList, int whichObj, void **userDataOut);
124 void            *objlist_get_obj_data(ABObjList, ABObj obj);
125
126 /*
127  * Debugging methods
128  */
129 #ifdef DEBUG
130 int             objlist_dump(ABObjList list);
131 #endif
132
133
134 /*************************************************************************
135 **************************************************************************
136 **                                                                      **
137 **              Inline definitions                                      **
138 **                                                                      **
139 **************************************************************************
140 *************************************************************************/
141 int     objlist_destroy_impl(ABObjList *listInOut);
142 #define objlist_destroy(list) (objlist_destroy_impl(&(list)))
143
144 #endif /* _ABOBJ_OBJ_LIST_H_ */