fix doc build fix autogen
[platform/upstream/gstreamer.git] / gst / gstutils.h
1 /* GStreamer
2  * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3  *                    2000 Wim Taymans <wtay@chello.be>
4  *
5  * gstutils.h: Header for various utility functions
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public
18  * License along with this library; if not, write to the
19  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
22
23
24 #ifndef __GST_UTILS_H__
25 #define __GST_UTILS_H__
26
27 #include <glib.h>
28 #include <gst/gstelement.h>
29
30 G_BEGIN_DECLS
31
32 void            gst_util_set_value_from_string  (GValue *value, const gchar *value_str);
33 void            gst_util_set_object_arg         (GObject *object, const gchar *name, const gchar *value);
34         
35 void            gst_util_dump_mem               (guchar *mem, guint size);
36
37 void            gst_print_pad_caps              (GString *buf, gint indent, GstPad *pad);
38 void            gst_print_element_args          (GString *buf, gint indent, GstElement *element);
39
40
41 /* Macros for defining classes.  Ideas taken from Bonobo, which took theirs 
42    from Nautilus and GOB. */
43
44 /* Define the boilerplate type stuff to reduce typos and code size.  Defines
45    the get_type method and the parent_class static variable.
46    void additional_initializations (GType type) is for initializing interfaces
47    and stuff like that */
48
49 #define GST_BOILERPLATE_FULL(type, type_as_function, parent_type,               \
50     parent_type_macro, additional_initializations)                              \
51                                                                                 \
52 static void type_as_function ## _base_init     (gpointer      g_class);         \
53 static void type_as_function ## _class_init    (type ## Class *g_class);        \
54 static void type_as_function ## _init          (type          *object);         \
55 static parent_type ## Class *parent_class = NULL;                               \
56 static void                                                                     \
57 type_as_function ## _class_init_trampoline (gpointer g_class,                   \
58                                             gpointer data)                      \
59 {                                                                               \
60   parent_class = (parent_type ## Class *) g_type_class_peek_parent (g_class);   \
61   type_as_function ## _class_init ((type ## Class *)g_class);                   \
62 }                                                                               \
63                                                                                 \
64 GType                                                                           \
65 type_as_function ## _get_type (void)                                            \
66 {                                                                               \
67   static GType object_type = 0;                                                 \
68   if (object_type == 0) {                                                       \
69     static const GTypeInfo object_info = {                                      \
70       sizeof (type ## Class),                                                   \
71       type_as_function ## _base_init,                                           \
72       NULL,               /* base_finalize */                                   \
73       type_as_function ## _class_init_trampoline,                               \
74       NULL,               /* class_finalize */                                  \
75       NULL,               /* class_data */                                      \
76       sizeof (type),                                                            \
77       0,                  /* n_preallocs */                                     \
78       (GInstanceInitFunc) type_as_function ## _init                             \
79     };                                                                          \
80     object_type = g_type_register_static (parent_type_macro, #type,             \
81         &object_info, 0);                                                       \
82     additional_initializations (object_type);                                   \
83   }                                                                             \
84   return object_type;                                                           \
85 }
86
87 #define __GST_DO_NOTHING(type)  /* NOP */
88 #define GST_BOILERPLATE(type,type_as_function,parent_type,parent_type_macro)    \
89   GST_BOILERPLATE_FULL (type, type_as_function, parent_type, parent_type_macro, \
90       __GST_DO_NOTHING)
91
92 /* Just call the parent handler.  This assumes that there is a variable
93  * named parent_class that points to the (duh!) parent class.  Note that
94  * this macro is not to be used with things that return something, use
95  * the _WITH_DEFAULT version for that */
96 #define GST_CALL_PARENT(parent_class_cast, name, args)                          \
97         ((parent_class_cast(parent_class)->name != NULL) ?                      \
98          parent_class_cast(parent_class)->name args : (void) 0)
99
100 /* Same as above, but in case there is no implementation, it evaluates
101  * to def_return */
102 #define GST_CALL_PARENT_WITH_DEFAULT(parent_class_cast, name, args, def_return) \
103         ((parent_class_cast(parent_class)->name != NULL) ?                      \
104          parent_class_cast(parent_class)->name args : def_return)
105
106
107 G_END_DECLS
108
109 #endif /* __GST_UTILS_H__ */