diff options
author | Zeeshan Ali (Khattak) <zeeshanak@gnome.org> | 2011-07-29 00:38:02 +0300 |
---|---|---|
committer | Zeeshan Ali (Khattak) <zeeshanak@gnome.org> | 2011-08-04 20:46:57 +0300 |
commit | a030d590545b5e8c43b027b6a9576cb4613a065d (patch) | |
tree | d0af2d731a904ac101b83855ba994f9b715da7f5 | |
parent | fd72284953fa8fc010dc03a61c9d118a65205aa3 (diff) |
Add MediaList class
Add special list class to hold Media instances.
-rw-r--r-- | docs/reference/Libosinfo-sections.txt | 21 | ||||
-rw-r--r-- | docs/reference/Libosinfo.types | 1 | ||||
-rw-r--r-- | osinfo/Makefile.am | 4 | ||||
-rw-r--r-- | osinfo/osinfo.h | 1 | ||||
-rw-r--r-- | osinfo/osinfo_medialist.c | 167 | ||||
-rw-r--r-- | osinfo/osinfo_medialist.h | 82 |
6 files changed, 275 insertions, 1 deletions
diff --git a/docs/reference/Libosinfo-sections.txt b/docs/reference/Libosinfo-sections.txt index 8c1100b..f8c7afd 100644 --- a/docs/reference/Libosinfo-sections.txt +++ b/docs/reference/Libosinfo-sections.txt @@ -416,6 +416,27 @@ OSINFO_MEDIA_GET_CLASS </SECTION> <SECTION> +<FILE>osinfo_medialist</FILE> +<TITLE>OsinfoMediaList</TITLE> +OsinfoMediaList +OsinfMediaListoClass +OsinfMediaListoPrivate +osinfo_medialist_new +osinfo_medialist_new_copy +osinfo_medialist_new_filtered +osinfo_medialist_new_intersection +osinfo_medialist_new_union +<SUBSECTION Standard> +OSINFO_MEDIALIST +OSINFO_IS_MEDIALIST +OSINFO_TYPE_MEDIALIST +osinfo_medialist_get_type +OSINFO_MEDIALIST_CLASS +OSINFO_IS_MEDIALIST_CLASS +OSINFO_MEDIALIST_GET_CLASS +</SECTION> + +<SECTION> <FILE>osinfo_devicelink</FILE> <TITLE>OsinfoDeviceLink</TITLE> OsinfoDeviceLink diff --git a/docs/reference/Libosinfo.types b/docs/reference/Libosinfo.types index dc60a54..37f3075 100644 --- a/docs/reference/Libosinfo.types +++ b/docs/reference/Libosinfo.types @@ -18,3 +18,4 @@ osinfo_devicelink_get_type osinfo_devicelinklist_get_type osinfo_devicelinkfilter_get_type osinfo_media_get_type +osinfo_medialist_get_type diff --git a/osinfo/Makefile.am b/osinfo/Makefile.am index 122e6dc..5982923 100644 --- a/osinfo/Makefile.am +++ b/osinfo/Makefile.am @@ -62,7 +62,8 @@ libosinfo_1_0_include_HEADERS = \ osinfo_oslist.h \ osinfo_deployment.h \ osinfo_deploymentlist.h \ - osinfo_media.h + osinfo_media.h \ + osinfo_medialist.h libosinfo_1_0_la_SOURCES = \ osinfo_entity.c \ @@ -83,6 +84,7 @@ libosinfo_1_0_la_SOURCES = \ osinfo_deployment.c \ osinfo_deploymentlist.c \ osinfo_media.c \ + osinfo_medialist.c \ osinfo_db.c \ osinfo_loader.c diff --git a/osinfo/osinfo.h b/osinfo/osinfo.h index 72986ed..6836c9c 100644 --- a/osinfo/osinfo.h +++ b/osinfo/osinfo.h @@ -43,6 +43,7 @@ #include <osinfo/osinfo_deploymentlist.h> #include <osinfo/osinfo_deployment.h> #include <osinfo/osinfo_media.h> +#include <osinfo/osinfo_medialist.h> #include <osinfo/osinfo_db.h> #include <osinfo/osinfo_loader.h> diff --git a/osinfo/osinfo_medialist.c b/osinfo/osinfo_medialist.c new file mode 100644 index 0000000..8534abd --- /dev/null +++ b/osinfo/osinfo_medialist.c @@ -0,0 +1,167 @@ +/* + * libosinfo: + * + * Copyright (C) 2009-2011 Red Hat, Inc + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Authors: + * Arjun Roy <arroy@redhat.com> + * Daniel P. Berrange <berrange@redhat.com> + */ + +#include <osinfo/osinfo.h> + +G_DEFINE_TYPE (OsinfoMediaList, osinfo_medialist, OSINFO_TYPE_LIST); + +#define OSINFO_MEDIALIST_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), OSINFO_TYPE_MEDIALIST, OsinfoMediaListPrivate)) + +/** + * SECTION:osinfo_medialist + * @short_description: A list of installation media + * @see_also: #OsinfoList, #OsinfoMedia + * + * #OsinfoMediaList is a list specialization that stores + * only #OsinfoMedia objects. + */ + +struct _OsinfoMediaListPrivate +{ + gboolean unused; +}; + +static void +osinfo_medialist_finalize (GObject *object) +{ + /* Chain up to the parent class */ + G_OBJECT_CLASS (osinfo_medialist_parent_class)->finalize (object); +} + +/* Init functions */ +static void +osinfo_medialist_class_init (OsinfoMediaListClass *klass) +{ + GObjectClass *g_klass = G_OBJECT_CLASS (klass); + + g_klass->finalize = osinfo_medialist_finalize; + g_type_class_add_private (klass, sizeof (OsinfoMediaListPrivate)); +} + +static void +osinfo_medialist_init (OsinfoMediaList *list) +{ + OsinfoMediaListPrivate *priv; + list->priv = priv = OSINFO_MEDIALIST_GET_PRIVATE(list); + +} + +/** + * osinfo_medialist_new: + * + * Construct a new media list that is initially empty. + * + * Returns: (transfer full): an empty media list + */ +OsinfoMediaList *osinfo_medialist_new(void) +{ + return g_object_new(OSINFO_TYPE_MEDIALIST, + "element-type", OSINFO_TYPE_MEDIA, + NULL); +} + +/** + * osinfo_medialist_new_copy: + * @source: the media list to copy + * + * Construct a new media list that is filled with medias + * from @source + * + * Returns: (transfer full): a copy of the media list + */ +OsinfoMediaList *osinfo_medialist_new_copy(OsinfoMediaList *source) +{ + OsinfoMediaList *newList = osinfo_medialist_new(); + osinfo_list_add_all(OSINFO_LIST(newList), + OSINFO_LIST(source)); + return newList; +} + +/** + * osinfo_medialist_new_filtered: + * @source: the media list to copy + * @filter: the filter to apply + * + * Construct a new media list that is filled with medias + * from @source that match @filter + * + * Returns: (transfer full): a filtered copy of the media list + */ +OsinfoMediaList *osinfo_medialist_new_filtered(OsinfoMediaList *source, + OsinfoFilter *filter) +{ + OsinfoMediaList *newList = osinfo_medialist_new(); + osinfo_list_add_filtered(OSINFO_LIST(newList), + OSINFO_LIST(source), + filter); + return newList; +} + +/** + * osinfo_medialist_new_intersection: + * @sourceOne: the first media list to copy + * @sourceTwo: the second media list to copy + * + * Construct a new media list that is filled with only the + * medias that are present in both @sourceOne and @sourceTwo. + * + * Returns: (transfer full): an intersection of the two media lists + */ +OsinfoMediaList *osinfo_medialist_new_intersection(OsinfoMediaList *sourceOne, + OsinfoMediaList *sourceTwo) +{ + OsinfoMediaList *newList = osinfo_medialist_new(); + osinfo_list_add_intersection(OSINFO_LIST(newList), + OSINFO_LIST(sourceOne), + OSINFO_LIST(sourceTwo)); + return newList; +} + +/** + * osinfo_medialist_new_union: + * @sourceOne: the first media list to copy + * @sourceTwo: the second media list to copy + * + * Construct a new media list that is filled with all the + * medias that are present in either @sourceOne and @sourceTwo. + * + * Returns: (transfer full): a union of the two media lists + */ +OsinfoMediaList *osinfo_medialist_new_union(OsinfoMediaList *sourceOne, + OsinfoMediaList *sourceTwo) +{ + OsinfoMediaList *newList = osinfo_medialist_new(); + osinfo_list_add_union(OSINFO_LIST(newList), + OSINFO_LIST(sourceOne), + OSINFO_LIST(sourceTwo)); + return newList; +} + +/* + * Local variables: + * indent-tabs-mode: nil + * c-indent-level: 4 + * c-basic-offset: 4 + * End: + */ diff --git a/osinfo/osinfo_medialist.h b/osinfo/osinfo_medialist.h new file mode 100644 index 0000000..4c6a13a --- /dev/null +++ b/osinfo/osinfo_medialist.h @@ -0,0 +1,82 @@ +/* + * libosinfo: a list of installation media + * + * Copyright (C) 2009-2011 Red Hat, Inc + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Authors: + * Zeeshan Ali <zeenix@redhat.com> + * Arjun Roy <arroy@redhat.com> + * Daniel P. Berrange <berrange@redhat.com> + */ + +#include <glib-object.h> +#include <osinfo/osinfo_list.h> + +#ifndef __OSINFO_MEDIALIST_H__ +#define __OSINFO_MEDIALIST_H__ + +/* + * Type macros. + */ +#define OSINFO_TYPE_MEDIALIST (osinfo_medialist_get_type ()) +#define OSINFO_MEDIALIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), OSINFO_TYPE_MEDIALIST, OsinfoMediaList)) +#define OSINFO_IS_MEDIALIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), OSINFO_TYPE_MEDIALIST)) +#define OSINFO_MEDIALIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), OSINFO_TYPE_MEDIALIST, OsinfoMediaListClass)) +#define OSINFO_IS_MEDIALIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), OSINFO_TYPE_MEDIALIST)) +#define OSINFO_MEDIALIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), OSINFO_TYPE_MEDIALIST, OsinfoMediaListClass)) + +typedef struct _OsinfoMediaList OsinfoMediaList; + +typedef struct _OsinfoMediaListClass OsinfoMediaListClass; + +typedef struct _OsinfoMediaListPrivate OsinfoMediaListPrivate; + +/* object */ +struct _OsinfoMediaList +{ + OsinfoList parent_instance; + + /* public */ + + /* private */ + OsinfoMediaListPrivate *priv; +}; + +/* class */ +struct _OsinfoMediaListClass +{ + OsinfoListClass parent_class; + + /* class members */ +}; + +GType osinfo_medialist_get_type(void); + +OsinfoMediaList *osinfo_medialist_new(void); +OsinfoMediaList *osinfo_medialist_new_copy(OsinfoMediaList *source); +OsinfoMediaList *osinfo_medialist_new_filtered(OsinfoMediaList *source, OsinfoFilter *filter); +OsinfoMediaList *osinfo_medialist_new_intersection(OsinfoMediaList *sourceOne, OsinfoMediaList *sourceTwo); +OsinfoMediaList *osinfo_medialist_new_union(OsinfoMediaList *sourceOne, OsinfoMediaList *sourceTwo); + +#endif /* __OSINFO_MEDIALIST_H__ */ +/* + * Local variables: + * indent-tabs-mode: nil + * c-indent-level: 4 + * c-basic-offset: 4 + * End: + */ |