1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * Copyright (C) 2012-2013 Red Hat, Inc.
4 * Copyright (C) 2015 Richard Hughes <richard@hughsie.com>
5 *
6 * Licensed under the GNU Lesser General Public License Version 2.1
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or(at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23 /**
24 * SECTION:dnf-packageset
25 * @short_description: SHORT DESCRIPTION
26 * @include: libdnf.h
27 * @stability: Unstable
28 *
29 * Long description.
30 *
31 * See also: #DnfContext
32 */
33
34
35 #include "dnf-sack-private.hpp"
36 #include "sack/packageset.hpp"
37
38 /**
39 * dnf_packageset_new:
40 * @sack: A #DnfSack
41 *
42 * Creates a new #DnfPackageSet.
43 *
44 * Returns:(transfer full): a #DnfPackageSet *
45 *
46 * Since: 0.7.0
47 **/
48 DnfPackageSet *
dnf_packageset_new(DnfSack * sack)49 dnf_packageset_new(DnfSack *sack)
50 {
51 return new libdnf::PackageSet(sack);
52 }
53
54 /**
55 * dnf_packageset_from_bitmap: (skip):
56 * @pset: a #DnfPackageSet instance.
57 *
58 * Creates a set from a bitmap.
59 *
60 * Returns: a new #DnfPackageSet
61 *
62 * Since: 0.7.0
63 */
64 DnfPackageSet *
dnf_packageset_from_bitmap(DnfSack * sack,Map * map)65 dnf_packageset_from_bitmap(DnfSack *sack, Map *map)
66 {
67 return new libdnf::PackageSet(sack, map);
68 }
69
70 /**
71 * dnf_packageset_get_map: (skip):
72 * @pset: a #DnfPackageSet instance.
73 *
74 * Gets the map.
75 *
76 * Returns: A #Map, or %NULL
77 *
78 * Since: 0.7.0
79 */
80 Map *
dnf_packageset_get_map(DnfPackageSet * pset)81 dnf_packageset_get_map(DnfPackageSet *pset)
82 {
83 return pset->getMap();
84 }
85
86 /**
87 * dnf_packageset_clone:
88 * @pset: a #DnfPackageSet instance.
89 *
90 * Clones the packageset.
91 *
92 * Returns: a new #DnfPackageSet
93 *
94 * Since: 0.7.0
95 */
96 DnfPackageSet *
dnf_packageset_clone(DnfPackageSet * pset)97 dnf_packageset_clone(DnfPackageSet *pset)
98 {
99 return new libdnf::PackageSet(*pset);
100 }
101
102 /**
103 * dnf_packageset_add:
104 * @pset: a #DnfPackageSet instance.
105 * @pkg: a #DnfPackage
106 *
107 * Adds a new package to the set.
108 *
109 * Returns: %TRUE for success
110 *
111 * Since: 0.7.0
112 */
113 void
dnf_packageset_add(DnfPackageSet * pset,DnfPackage * pkg)114 dnf_packageset_add(DnfPackageSet *pset, DnfPackage *pkg)
115 {
116 pset->set(pkg);
117 }
118
119 /**
120 * dnf_packageset_count:
121 * @pset: a #DnfPackageSet instance.
122 *
123 * Returns the size of the set.
124 *
125 * Returns: size_t, or 0 for empty
126 *
127 * Since: 0.7.0
128 */
129 size_t
dnf_packageset_count(DnfPackageSet * pset)130 dnf_packageset_count(DnfPackageSet *pset)
131 {
132 return pset->size();
133 }
134
135 /**
136 * dnf_packageset_has:
137 * @pset: a #DnfPackageSet instance.
138 * @pkg: a #DnfPackage.
139 *
140 * Finds out if a package is in the set.
141 *
142 * Returns: %TRUE if it exists
143 *
144 * Since: 0.7.0
145 */
146 int
dnf_packageset_has(DnfPackageSet * pset,DnfPackage * pkg)147 dnf_packageset_has(DnfPackageSet *pset, DnfPackage *pkg)
148 {
149 return pset->has(pkg);
150 }
151
152 void
dnf_packageset_free(DnfPackageSet * pset)153 dnf_packageset_free(DnfPackageSet *pset)
154 {
155 delete pset;
156 }
157