XMMS2
xmms_collection.h
Go to the documentation of this file.
1 /* XMMS2 - X Music Multiplexer System
2  * Copyright (C) 2003-2011 XMMS2 Team
3  *
4  * PLUGINS ARE NOT CONSIDERED TO BE DERIVED WORK !!!
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  */
16 
17 #ifndef __XMMS_COLLECTION_H__
18 #define __XMMS_COLLECTION_H__
19 
20 #include <glib.h>
21 
22 
23 /*
24  * Public definitions
25  */
26 
27 #define XMMS_COLLECTION_NUM_NAMESPACES 2
28 
29 typedef enum {
35 
36 
37 /*
38  * Private defintions
39  */
40 
41 struct xmms_coll_dag_St;
42 typedef struct xmms_coll_dag_St xmms_coll_dag_t;
43 
44 #include "xmms/xmms_error.h"
45 #include "xmmsc/xmmsv_coll.h"
46 #include "xmmspriv/xmms_playlist.h"
47 #include "xmmspriv/xmms_medialib.h"
48 
49 typedef void (*FuncApplyToColl)(xmms_coll_dag_t *dag, xmmsv_coll_t *coll, xmmsv_coll_t *parent, void *udata);
50 
51 
52 /*
53  * Public functions
54  */
55 
57 
59 GList * xmms_collection_query_ids (xmms_coll_dag_t *dag, xmmsv_coll_t *coll, gint32 lim_start, gint32 lim_len, xmmsv_t *order, xmms_error_t *err);
60 
61 
62 void xmms_collection_foreach_in_namespace (xmms_coll_dag_t *dag, guint nsid, GHFunc f, void *udata);
65 
66 xmmsv_coll_t * xmms_collection_get_pointer (xmms_coll_dag_t *dag, const gchar *collname, guint namespace);
67 void xmms_collection_update_pointer (xmms_coll_dag_t *dag, const gchar *name, guint nsid, xmmsv_coll_t *newtarget);
68 const gchar * xmms_collection_find_alias (xmms_coll_dag_t *dag, guint nsid, xmmsv_coll_t *value, const gchar *key);
71 
74 
75 gboolean xmms_collection_get_int_attr (xmmsv_coll_t *coll, const gchar *attrname, gint *val);
76 gboolean xmms_collection_set_int_attr (xmmsv_coll_t *coll, const gchar *attrname, gint newval);
77 
78 GTree *xmms_collection_changed_msg_new (xmms_collection_changed_actions_t type, const gchar *plname, const gchar *namespace);
79 void xmms_collection_changed_msg_send (xmms_coll_dag_t *colldag, GTree *dict);
80 
81 void bind_all_references (xmms_coll_dag_t *dag, xmmsv_coll_t *coll, xmmsv_coll_t *parent, void *udata);
82 
83 #define XMMS_COLLECTION_PLAYLIST_CHANGED_MSG(dag, name) xmms_collection_changed_msg_send (dag, xmms_collection_changed_msg_new (XMMS_COLLECTION_CHANGED_UPDATE, name, XMMS_COLLECTION_NS_PLAYLISTS))
84 
85 
86 #endif
G_BEGIN_DECLS typedef gint32 xmms_medialib_entry_t
Definition: xmms_medialib.h:86
xmms_medialib_entry_t xmms_collection_get_random_media(xmms_coll_dag_t *dag, xmmsv_coll_t *source)
Get a random media entry from the given collection.
Definition: collection.c:978
struct xmmsv_St xmmsv_t
Definition: xmmsv_general.h:48
const gchar * xmms_collection_get_namespace_string(xmms_collection_namespace_id_t nsid)
Find the namespace name (string) corresponding to a namespace id.
Definition: collection.c:1320
void xmms_collection_apply_to_collection(xmms_coll_dag_t *dag, xmmsv_coll_t *coll, FuncApplyToColl f, void *udata)
Apply a function of type FuncApplyToColl to the given collection.
Definition: collection.c:1412
void(* FuncApplyToColl)(xmms_coll_dag_t *dag, xmmsv_coll_t *coll, xmmsv_coll_t *parent, void *udata)
xmmsv_coll_t * xmms_collection_get_pointer(xmms_coll_dag_t *dag, const gchar *collname, guint namespace)
Find the collection structure corresponding to the given name in the given namespace.
Definition: collection.c:873
void bind_all_references(xmms_coll_dag_t *dag, xmmsv_coll_t *coll, xmmsv_coll_t *parent, void *udata)
If a reference, add the operator of the pointed collection as an operand.
Definition: collection.c:1503
gboolean xmms_collection_get_int_attr(xmmsv_coll_t *coll, const gchar *attrname, gint *val)
Extract an attribute from a collection as an integer.
Definition: collection.c:898
GList * xmms_collection_query_ids(xmms_coll_dag_t *dag, xmmsv_coll_t *coll, gint32 lim_start, gint32 lim_len, xmmsv_t *order, xmms_error_t *err)
Find the ids of the media matched by a collection.
Definition: collection.c:731
xmms_collection_namespace_id_t
void xmms_collection_apply_to_all_collections(xmms_coll_dag_t *dag, FuncApplyToColl f, void *udata)
Apply a function of type FuncApplyToColl to all the collections in all namespaces.
Definition: collection.c:1393
struct xmmsv_coll_St xmmsv_coll_t
Definition: xmmsv_coll.h:28
struct xmms_playlist_St xmms_playlist_t
Definition: xmms_playlist.h:41
void xmms_collection_update_pointer(xmms_coll_dag_t *dag, const gchar *name, guint nsid, xmmsv_coll_t *newtarget)
Update a reference to point to a new collection.
Definition: collection.c:849
GTree * xmms_collection_changed_msg_new(xmms_collection_changed_actions_t type, const gchar *plname, const gchar *namespace)
Definition: collection.c:147
xmms_collection_changed_actions_t
gboolean xmms_collection_set_int_attr(xmmsv_coll_t *coll, const gchar *attrname, gint newval)
Set the attribute of a collection as an integer.
Definition: collection.c:926
void xmms_collection_dag_replace(xmms_coll_dag_t *dag, xmms_collection_namespace_id_t nsid, gchar *key, xmmsv_coll_t *newcoll)
Update the DAG to update the value of the pair with the given key.
Definition: collection.c:858
const gchar * xmms_collection_find_alias(xmms_coll_dag_t *dag, guint nsid, xmmsv_coll_t *value, const gchar *key)
Reverse-search the list of collections in the given namespace to find the first pair whose value matc...
Definition: collection.c:955
xmms_collection_namespace_id_t xmms_collection_get_namespace_id(const gchar *namespace)
Find the namespace id corresponding to a namespace string.
Definition: collection.c:1297
xmms_coll_dag_t * xmms_collection_init(xmms_playlist_t *playlist)
Initializes a new xmms_coll_dag_t.
Definition: collection.c:214
void xmms_collection_changed_msg_send(xmms_coll_dag_t *colldag, GTree *dict)
Definition: collection.c:163
G_BEGIN_DECLS struct xmms_error_St xmms_error_t
void xmms_collection_sync(xmms_coll_dag_t *dag)
Synchronize collection data to the database (i.e.
Definition: collection.c:539
struct xmms_coll_dag_St xmms_coll_dag_t
void xmms_collection_foreach_in_namespace(xmms_coll_dag_t *dag, guint nsid, GHFunc f, void *udata)
Apply a function to all the collections in a given namespace.
Definition: collection.c:1373