BEAST/BSE - Better Audio System and Sound Engine  0.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sfiparams.hh
Go to the documentation of this file.
1  // Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
2 #ifndef __SFI_PARAMS_H__
3 #define __SFI_PARAMS_H__
4 
5 #include <sfi/sfivalues.hh>
6 #include <sfi/sfiprimitives.hh>
7 
8 G_BEGIN_DECLS
9 
10 
11 /* --- Sfi param spec macros --- */
12 #define SFI_TYPE_PARAM_BOOL (G_TYPE_PARAM_BOOLEAN)
13 #define SFI_IS_PSPEC_BOOL(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), SFI_TYPE_PARAM_BOOL))
14 #define SFI_PSPEC_BOOL(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), SFI_TYPE_PARAM_BOOL, SfiParamSpecBool))
15 #define SFI_TYPE_PARAM_INT (G_TYPE_PARAM_INT)
16 #define SFI_IS_PSPEC_INT(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), SFI_TYPE_PARAM_INT))
17 #define SFI_PSPEC_INT(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), SFI_TYPE_PARAM_INT, SfiParamSpecInt))
18 #define SFI_TYPE_PARAM_NUM (G_TYPE_PARAM_INT64)
19 #define SFI_IS_PSPEC_NUM(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), SFI_TYPE_PARAM_NUM))
20 #define SFI_PSPEC_NUM(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), SFI_TYPE_PARAM_NUM, SfiParamSpecNum))
21 #define SFI_TYPE_PARAM_REAL (G_TYPE_PARAM_DOUBLE)
22 #define SFI_IS_PSPEC_REAL(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), SFI_TYPE_PARAM_REAL))
23 #define SFI_PSPEC_REAL(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), SFI_TYPE_PARAM_REAL, SfiParamSpecReal))
24 #define SFI_TYPE_PARAM_STRING (G_TYPE_PARAM_STRING)
25 #define SFI_IS_PSPEC_STRING(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), SFI_TYPE_PARAM_STRING))
26 #define SFI_PSPEC_STRING(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), SFI_TYPE_PARAM_STRING, SfiParamSpecString))
27 #define SFI_TYPE_PARAM_CHOICE (sfi__param_spec_types[0])
28 #define SFI_IS_PSPEC_CHOICE(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), SFI_TYPE_PARAM_CHOICE))
29 #define SFI_PSPEC_CHOICE(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), SFI_TYPE_PARAM_CHOICE, SfiParamSpecChoice))
30 #define SFI_TYPE_PARAM_BBLOCK (sfi__param_spec_types[1])
31 #define SFI_IS_PSPEC_BBLOCK(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), SFI_TYPE_PARAM_BBLOCK))
32 #define SFI_PSPEC_BBLOCK(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), SFI_TYPE_PARAM_BBLOCK, SfiParamSpecBBlock))
33 #define SFI_TYPE_PARAM_FBLOCK (sfi__param_spec_types[2])
34 #define SFI_IS_PSPEC_FBLOCK(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), SFI_TYPE_PARAM_FBLOCK))
35 #define SFI_PSPEC_FBLOCK(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), SFI_TYPE_PARAM_FBLOCK, SfiParamSpecFBlock))
36 #define SFI_TYPE_PARAM_PSPEC (G_TYPE_PARAM_PARAM)
37 #define SFI_IS_PSPEC_PSPEC(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), SFI_TYPE_PARAM_PSPEC))
38 #define SFI_PSPEC_PSPEC(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), SFI_TYPE_PARAM_PSPEC, SfiParamSpecPSpec))
39 #define SFI_TYPE_PARAM_SEQ (sfi__param_spec_types[3])
40 #define SFI_IS_PSPEC_SEQ(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), SFI_TYPE_PARAM_SEQ))
41 #define SFI_PSPEC_SEQ(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), SFI_TYPE_PARAM_SEQ, SfiParamSpecSeq))
42 #define SFI_TYPE_PARAM_REC (sfi__param_spec_types[4])
43 #define SFI_IS_PSPEC_REC(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), SFI_TYPE_PARAM_REC))
44 #define SFI_PSPEC_REC(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), SFI_TYPE_PARAM_REC, SfiParamSpecRec))
45 #define SFI_TYPE_PARAM_PROXY (sfi__param_spec_types[5])
46 #define SFI_IS_PSPEC_PROXY(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), SFI_TYPE_PARAM_PROXY))
47 #define SFI_PSPEC_PROXY(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), SFI_TYPE_PARAM_PROXY, SfiParamSpecProxy))
48 #define SFI_TYPE_PARAM_NOTE (sfi__param_spec_types[6])
49 #define SFI_IS_PSPEC_NOTE(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), SFI_TYPE_PARAM_NOTE))
50 #define SFI_PSPEC_NOTE(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), SFI_TYPE_PARAM_NOTE, SfiParamSpecNote))
51 
52 
53 /* --- Sfi param spec aliases --- */
54 typedef GParamSpecBoolean SfiParamSpecBool;
55 typedef GParamSpecInt SfiParamSpecInt;
56 typedef GParamSpecInt64 SfiParamSpecNum;
57 typedef GParamSpecDouble SfiParamSpecReal;
58 typedef GParamSpecString SfiParamSpecString;
59 typedef GParamSpecParam SfiParamSpecPSpec;
60 
61 
62 /* --- Sfi param specs --- */
63 typedef struct {
64  const gchar *choice_ident;
65  const gchar *choice_label;
66  const gchar *choice_blurb;
67 } SfiChoiceValue; // auxillary
68 typedef struct {
69  guint n_values;
70  const SfiChoiceValue *values;
71 } SfiChoiceValues; // auxillary
72 typedef struct {
73  GParamSpecString pspec;
74  SfiChoiceValues cvalues;
76 typedef struct {
77  GParamSpecBoxed pspec;
79 typedef struct {
80  GParamSpecBoxed pspec;
82 typedef struct {
83  GParamSpecBoxed pspec;
84  GParamSpec *element;
86 typedef struct {
87  GParamSpecBoxed pspec;
88  SfiRecFields fields;
90 typedef struct {
91  GParamSpecPointer pspec;
93 typedef struct {
94  GParamSpecInt pspec;
95  gboolean allow_void;
97 
98 
99 /* --- Sfi GParamSpec constructors --- */
100 GParamSpec* sfi_pspec_bool (const gchar *name,
101  const gchar *nick,
102  const gchar *blurb,
103  SfiBool default_value,
104  const gchar *hints);
105 GParamSpec* sfi_pspec_int (const gchar *name,
106  const gchar *nick,
107  const gchar *blurb,
108  SfiInt default_value,
109  SfiInt minimum_value,
110  SfiInt maximum_value,
111  SfiInt stepping,
112  const gchar *hints);
113 GParamSpec* sfi_pspec_num (const gchar *name,
114  const gchar *nick,
115  const gchar *blurb,
116  SfiNum default_value,
117  SfiNum minimum_value,
118  SfiNum maximum_value,
119  SfiNum stepping,
120  const gchar *hints);
121 GParamSpec* sfi_pspec_real (const gchar *name,
122  const gchar *nick,
123  const gchar *blurb,
124  SfiReal default_value,
125  SfiReal minimum_value,
126  SfiReal maximum_value,
127  SfiReal stepping,
128  const gchar *hints);
129 GParamSpec* sfi_pspec_log_scale (const gchar *name,
130  const gchar *nick,
131  const gchar *blurb,
132  SfiReal default_value,
133  SfiReal minimum_value,
134  SfiReal maximum_value,
135  SfiReal stepping,
136  SfiReal center,
137  SfiReal base,
138  SfiReal n_steps,
139  const gchar *hints);
140 GParamSpec* sfi_pspec_string (const gchar *name,
141  const gchar *nick,
142  const gchar *blurb,
143  const gchar *default_value,
144  const gchar *hints);
145 GParamSpec* sfi_pspec_choice (const gchar *name,
146  const gchar *nick,
147  const gchar *blurb,
148  const gchar *default_value,
149  SfiChoiceValues static_const_evalues,
150  const gchar *hints);
151 GParamSpec* sfi_pspec_bblock (const gchar *name,
152  const gchar *nick,
153  const gchar *blurb,
154  const gchar *hints);
155 GParamSpec* sfi_pspec_fblock (const gchar *name,
156  const gchar *nick,
157  const gchar *blurb,
158  const gchar *hints);
159 GParamSpec* sfi_pspec_pspec (const gchar *name,
160  const gchar *nick,
161  const gchar *blurb,
162  const gchar *hints);
163 GParamSpec* sfi_pspec_seq (const gchar *name,
164  const gchar *nick,
165  const gchar *blurb,
166  GParamSpec *element_spec,
167  const gchar *hints);
168 GParamSpec* sfi_pspec_rec (const gchar *name,
169  const gchar *nick,
170  const gchar *blurb,
171  SfiRecFields static_const_fields,
172  const gchar *hints);
173 GParamSpec* sfi_pspec_rec_generic (const gchar *name,
174  const gchar *nick,
175  const gchar *blurb,
176  const gchar *hints);
177 GParamSpec* sfi_pspec_proxy (const gchar *name,
178  const gchar *nick,
179  const gchar *blurb,
180  const gchar *hints);
181 
182 
183 /* --- pspec wrappers --- */
184 #define sfi_pspec_ref g_param_spec_ref
185 #define sfi_pspec_unref g_param_spec_unref
186 #define sfi_pspec_sink g_param_spec_sink
187 #define sfi_pspec_get_qdata g_param_spec_get_qdata
188 #define sfi_pspec_set_qdata g_param_spec_set_qdata
189 #define sfi_pspec_set_qdata_full g_param_spec_set_qdata_full
190 #define sfi_pspec_steal_qdata g_param_spec_steal_qdata
191 #define sfi_pspec_get_name g_param_spec_get_name
192 #define sfi_pspec_get_nick g_param_spec_get_nick
193 #define sfi_pspec_get_blurb g_param_spec_get_blurb
194 
195 
196 /* --- conversion --- */
197 typedef SfiChoiceValues (*SfiChoiceValueGetter) (GType enum_type);
198 GParamSpec* sfi_pspec_to_serializable (GParamSpec *pspec);
199 GParamSpec* sfi_pspec_choice_from_enum (GParamSpec *enum_pspec);
200 GParamSpec* sfi_pspec_proxy_from_object (GParamSpec *object_pspec);
201 void sfi_enum_type_set_choice_value_getter (GType gtype,
202  SfiChoiceValueGetter cvgetter);
203 void sfi_boxed_type_set_rec_fields (GType boxed_type,
204  const SfiRecFields static_const_fields);
205 SfiRecFields sfi_boxed_type_get_rec_fields (GType boxed_type);
206 void sfi_boxed_type_set_seq_element (GType boxed_type,
207  GParamSpec *element);
208 GParamSpec* sfi_boxed_type_get_seq_element (GType boxed_type);
209 
210 
211 /* --- Sfi PSpec Options --- */
212 /* provide common option combinations: */
213 #define SFI_PARAM_READWRITE ":r:w:"
214 #define SFI_PARAM_STORAGE ":r:w:S:"
215 #define SFI_PARAM_STANDARD ":r:w:S:G:"
216 #define SFI_PARAM_STANDARD_RDONLY ":r:w:S:G:ro:"
217 #define SFI_PARAM_GUI ":r:w:G:"
218 #define SFI_PARAM_GUI_RDONLY ":r:w:G:ro:"
219 #define SFI_PARAM_GUI_READABLE ":r:G:"
220 
221 
222 /* --- serializable categories --- */
223 typedef enum /*< skip >*/
224 {
225  SFI_SCAT_INVAL = 0,
226  SFI_SCAT_BOOL = 'b',
227  SFI_SCAT_INT = 'i',
228  SFI_SCAT_NUM = 'n',
229  SFI_SCAT_REAL = 'r',
230  SFI_SCAT_STRING = 's',
231  SFI_SCAT_CHOICE = 'C',
232  SFI_SCAT_BBLOCK = 'B',
233  SFI_SCAT_FBLOCK = 'F',
234  SFI_SCAT_PSPEC = 'P',
235  SFI_SCAT_SEQ = 'Q',
236  SFI_SCAT_REC = 'R',
237  SFI_SCAT_PROXY = 'p',
238  SFI_SCAT_TYPE_MASK = 0x00ff,
239  SFI_SCAT_NOTE = 0x0100 | SFI_SCAT_INT,
240  SFI_SCAT_TIME = 0x0200 | SFI_SCAT_NUM,
241 } SfiSCategory;
242 
243 SfiSCategory sfi_categorize_type (GType value_type);
244 SfiSCategory sfi_categorize_pspec (GParamSpec *pspec);
245 GType sfi_category_type (SfiSCategory pspec_cat);
246 GType sfi_category_param_type (SfiSCategory pspec_cat);
247 
248 
249 /* --- convenience aliases --- */
250 GParamSpec* sfi_pspec_note (const gchar *name,
251  const gchar *nick,
252  const gchar *blurb,
253  SfiInt default_value,
254  SfiInt min_note,
255  SfiInt max_note,
256  gboolean allow_void,
257  const gchar *hints);
258 #define SFI_IS_PSPEC_TIME SFI_IS_PSPEC_TIME
259 GParamSpec* sfi_pspec_time (const gchar *name,
260  const gchar *nick,
261  const gchar *blurb,
262  const gchar *hints);
263 
264 
265 /* --- pspec accessors --- */
266 GParamSpec* sfi_pspec_set_group (GParamSpec *pspec,
267  const gchar *group);
268 const gchar* sfi_pspec_get_group (GParamSpec *pspec);
269 void sfi_pspec_set_owner (GParamSpec *pspec,
270  const gchar *owner);
271 const gchar* sfi_pspec_get_owner (GParamSpec *pspec);
272 #define sfi_pspec_set_options(pspec, opts) g_param_spec_set_options (pspec, opts)
273 #define sfi_pspec_add_option(pspec, opt, val) g_param_spec_add_option (pspec, opt, val)
274 #define sfi_pspec_check_option(pspec, opt) g_param_spec_check_option (pspec, opt)
275 #define sfi_pspec_provides_options(pspec, opts) g_param_spec_provides_options (pspec, opts)
276 #define sfi_pspec_get_options(pspec) g_param_spec_get_options (pspec)
277 SfiBool sfi_pspec_get_bool_default (GParamSpec *pspec);
278 SfiInt sfi_pspec_get_int_default (GParamSpec *pspec);
279 void sfi_pspec_get_int_range (GParamSpec *pspec,
280  SfiInt *minimum_value,
281  SfiInt *maximum_value,
282  SfiInt *stepping);
283 gboolean sfi_pspec_allows_void_note (GParamSpec *pspec);
284 #define sfi_pspec_get_note_default sfi_pspec_get_int_default
285 #define sfi_pspec_get_note_range sfi_pspec_get_int_range
286 SfiNum sfi_pspec_get_num_default (GParamSpec *pspec);
287 void sfi_pspec_get_num_range (GParamSpec *pspec,
288  SfiNum *minimum_value,
289  SfiNum *maximum_value,
290  SfiNum *stepping);
291 SfiReal sfi_pspec_get_real_default (GParamSpec *pspec);
292 void sfi_pspec_get_real_range (GParamSpec *pspec,
293  SfiReal *minimum_value,
294  SfiReal *maximum_value,
295  SfiReal *stepping);
296 #define sfi_pspec_set_log_scale(p, c, b, n) g_param_spec_set_log_scale (p, c, b, n)
297 #define sfi_pspec_get_log_scale(p, c, b, n) g_param_spec_get_log_scale (p, c, b, n)
298 const gchar* sfi_pspec_get_string_default (GParamSpec *pspec);
299 const gchar* sfi_pspec_get_choice_default (GParamSpec *pspec);
300 SfiChoiceValues sfi_pspec_get_choice_values (GParamSpec *pspec);
301 guint64 sfi_pspec_get_choice_hash (GParamSpec *pspec);
302 GParamSpec* sfi_pspec_get_seq_element (GParamSpec *pspec);
303 SfiRecFields sfi_pspec_get_rec_fields (GParamSpec *pspec);
304 GParamSpec* sfi_pspec_get_rec_field (GParamSpec *pspec,
305  const gchar *field_name);
306 
307 
308 /* --- internal --- */
309 void _sfi_init_params (void);
310 extern GType* sfi__param_spec_types;
311 SfiRec* sfi_pspec_to_rec (GParamSpec *pspec);
312 GParamSpec* sfi_pspec_from_rec (SfiRec *prec);
313 
314 
315 G_END_DECLS
316 
317 #endif /* __SFI_PARAMS_H__ */
318 
319 /* vim:set ts=8 sts=2 sw=2: */
Definition: sfiparams.hh:63
Definition: sfiparams.hh:93
Definition: sfitypes.hh:32
Definition: sfiparams.hh:68
Definition: sfiparams.hh:82
Definition: sfiparams.hh:72
Definition: sfiparams.hh:86
Definition: sfiparams.hh:76
Definition: sfiparams.hh:79
Definition: sfiparams.hh:90