1 /* libcomps - C alternative to yum.comps library
2  * Copyright (C) 2013 Jindrich Luza
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to  Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
17  * USA
18  */
19 
20 #ifndef COMPS_DOCCATEGORY_H
21 #define COMPS_DOCCATEGORY_H
22 
23 #include "comps_obj.h"
24 #include "comps_objdict.h"
25 #include "comps_objlist.h"
26 #include "comps_utils.h"
27 #include "comps_docgroupid.h"
28 #include "comps_validate.h"
29 #include "comps_radix.h"
30 #include "comps_log.h"
31 #include "comps_default.h"
32 
33 #include <stddef.h>
34 #include <assert.h>
35 
36 /** \file comps_doccategory.h
37  * \brief COMPS_DocCategory header file
38  * @see COMPS_DocCategory_prop_setters
39  * @see COMPS_DocCategory_prop_getters
40  * @see COMPS_DocCategory_list_setters
41  * @see COMPS_DocCategory_list_getters
42  *
43  * COMPS_DocCategory object support union operation. Read more about
44  * @link doc_unioning Libcomps objects unioning
45  * @endlink
46  */
47 
48 /** COMPS_Object derivate representing category element in comps.xml structure*/
49 typedef struct {
50     COMPS_Object_HEAD;
51     COMPS_ObjDict *properties; /**< properties of category */
52     COMPS_ObjDict *name_by_lang; /**<language localization of name attribute*/
53     COMPS_ObjDict *desc_by_lang;
54     /**<language localization of description attribute */
55     COMPS_ObjList *group_ids;
56     /**< list of group_ids */
57 } COMPS_DocCategory;
58 COMPS_Object_TAIL(COMPS_DocCategory);
59 
60 
61 //HEAD_COMPS_CREATE_u(doccategory, COMPS_DocCategory)  /*comps_utils.h macro*/
62 //HEAD_COMPS_COPY_u(doccategory, COMPS_DocCategory)  /*comps_utils.h macro*/
63 //HEAD_COMPS_DESTROY_u(doccategory, COMPS_DocCategory)  /*comps_utils.h macro*/
64 
65 /**
66  * \defgroup COMPS_DocCategory_prop_setters COMPS_DocCategory properties setters
67  * @{
68  **/
69 
70 /** COMPS_DocCategory id setter
71  * @param obj COMPS_DocCategory object
72  * @param id COMPS_Str object representing id
73  * \warning setter doesn't increment reference counter of id object
74  */
75 HEAD_COMPS_STRPROP_SETTER(category, COMPS_DocCategory, id) /*comps_utils.h macro*/
76 
77 /** COMPS_DocCategory name setter
78  * @param obj COMPS_DocCategory object
79  * @param name COMPS_Str object representing name
80  * \warning setter doesn't increment reference counter of name object
81  */
82 HEAD_COMPS_STRPROP_SETTER(category, COMPS_DocCategory, name) /*comps_utils.h macro*/
83 
84 /** COMPS_DocCategory description setter
85  * @param obj COMPS_DocCategory object
86  * @param desc COMPS_Str object representing description
87  * \warning setter doesn't increment reference counter of desc object
88  */
89 HEAD_COMPS_STRPROP_SETTER(category, COMPS_DocCategory, desc) /*comps_utils.h macro*/
90 
91 /** COMPS_DocCategory display order setter
92  * @param obj COMPS_DocCategory object
93  * @param display_order COMPS_Num object representing display order
94  * \warning setter doesn't increment reference counter of display_order object
95  */
96 HEAD_COMPS_NUMPROP_SETTER(category, COMPS_DocCategory,
97                           display_order) /*comps_utils.h macro*/
98 /**@}*/
99 
100 /**
101  * \defgroup COMPS_DocCategory_prop_getters COMPS_CategoryGroup properties getters
102  * @{
103  **/
104 
105 /** COMPS_DocCategory id getter
106  * @param obj COMPS_DocCategory object
107  * @return COMPS_Str object representing category id with incremented reference
108  * count
109  */
110 HEAD_COMPS_PROP_GETTER(category, COMPS_DocCategory, id) /*comps_utils.h macro*/
111 HEAD_COMPS_PROP_GETTER_OBJ(category, id) /*comps_utils.h macro*/
112 
113 /** COMPS_DocCategory name getter
114  * @param obj COMPS_DocCategory object
115  * @return COMPS_Str object representing category name with incremented
116  * reference count
117  */
118 HEAD_COMPS_PROP_GETTER(category, COMPS_DocCategory, name) /*comps_utils.h macro*/
119 
120 /** COMPS_DocCategory description getter
121  * @param obj COMPS_DocCategory object
122  * @return COMPS_Str object representing category description with incremented
123  * reference count
124  */
125 HEAD_COMPS_PROP_GETTER(category, COMPS_DocCategory, desc) /*comps_utils.h macro*/
126 
127 /** COMPS_DocCategory display order getter
128  * @param obj COMPS_DocCategory object
129  * @return COMPS_Str object representing category display order with
130  * incremented reference count
131  */
132 HEAD_COMPS_PROP_GETTER(category, COMPS_DocCategory, display_order) /*comps_utils.h macro*/
133 /**@}*/
134 
135 /**
136  * \defgroup COMPS_DocCategory_list_getters COMPS_DocCategory list getters
137  * @{
138  **/
139 
140 /** COMPS_DocCategory group_ids list getter
141  * @param obj COMPS_DocCategory object
142  * @return COMPS_ObjList object with group_ids items. Reference of object isn't
143  * incremented
144  */
145 HEAD_COMPS_DOCOBJ_GETOBJLIST(doccategory, COMPS_DocCategory, group_ids, group_ids)
146 /**@}*/
147 
148 /**
149  * \defgroup COMPS_DocCategory_list_setters COMPS_DocCategory list setters
150  * @{
151  **/
152 
153 /** COMPS_DocCategory group_ids list setter
154  * @param obj COMPS_DocCategory object
155  * @param list COMPS_ObjList object with group_ids items
156  * \warning existing group_ids list object reference count will be decremented.
157  * Setter doesn't provides any additional items type checking
158  */
159 HEAD_COMPS_DOCOBJ_SETOBJLIST(doccategory, COMPS_DocCategory, group_ids, group_ids)
160 /**@}*/
161 
162 HEAD_COMPS_DOCOBJ_GETARCHES(doccategory, COMPS_DocCategory)
163 HEAD_COMPS_DOCOBJ_SETARCHES(doccategory, COMPS_DocCategory)
164 
165 char __comps_doccategory_idcmp(void *c1, void *c2);
166 
167 /** COMPS_DocCategory compare callback
168  * @param cat1 COMPS_DocCategory object
169  * @param cat2 COMPS_DocCategory object
170  * @return non-zero if objects are equal, otherwise 0
171  */
172 signed char comps_doccategory_cmp_u(COMPS_Object *cat1, COMPS_Object *cat2);
173 
174 /** add group_id to group_ids list in category
175  * @param cat COMPS_DocCategory object
176  * @param gid COMPS_DocGroupId object
177  * \warning COMPS_DocGroupId reference counter isn't incremented
178  */
179 void comps_doccategory_add_groupid(COMPS_DocCategory *cat,
180                                    COMPS_DocGroupId *gid);
181 
182 /** union two categories into one and return new COMPS_DocCategory object
183  * @param c1 COMPS_DocCategory object
184  * @param c2 COMPS_DocCategory object
185  * @return new COMPS_DocCategory object
186  */
187 COMPS_DocCategory* comps_doccategory_union(COMPS_DocCategory *c1,
188                                            COMPS_DocCategory *c2);
189 
190 /** intersect two categories into one and return new COMPS_DocCategory object
191  * @param c1 COMPS_DocCategory object
192  * @param c2 COMPS_DocCategory object
193  * @return new COMPS_DocCategory object
194  */
195 COMPS_DocCategory* comps_doccategory_intersect(COMPS_DocCategory *c1,
196                                                COMPS_DocCategory *c2);
197 
198 signed char comps_doccategory_xml(COMPS_DocCategory *category,
199                                   xmlTextWriterPtr writer, COMPS_Log *log,
200                                   COMPS_XMLOptions *xml_options,
201                                   COMPS_DefaultsOptions *def_options);
202 COMPS_DocCategory* comps_doccategory_arch_filter(COMPS_DocCategory *source,
203                                                  COMPS_ObjList *arches);
204 
205 extern COMPS_ValRuleGeneric* COMPS_DocCategory_ValidateRules[];
206 #endif
207