BEAST/BSE - Better Audio System and Sound Engine
0.8.2
|
00001 // Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html 00002 #ifndef __SFI_PARAMS_H__ 00003 #define __SFI_PARAMS_H__ 00004 00005 #include <sfi/sfivalues.hh> 00006 #include <sfi/sfiprimitives.hh> 00007 00008 G_BEGIN_DECLS 00009 00010 00011 /* --- Sfi param spec macros --- */ 00012 #define SFI_TYPE_PARAM_BOOL (G_TYPE_PARAM_BOOLEAN) 00013 #define SFI_IS_PSPEC_BOOL(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), SFI_TYPE_PARAM_BOOL)) 00014 #define SFI_PSPEC_BOOL(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), SFI_TYPE_PARAM_BOOL, SfiParamSpecBool)) 00015 #define SFI_TYPE_PARAM_INT (G_TYPE_PARAM_INT) 00016 #define SFI_IS_PSPEC_INT(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), SFI_TYPE_PARAM_INT)) 00017 #define SFI_PSPEC_INT(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), SFI_TYPE_PARAM_INT, SfiParamSpecInt)) 00018 #define SFI_TYPE_PARAM_NUM (G_TYPE_PARAM_INT64) 00019 #define SFI_IS_PSPEC_NUM(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), SFI_TYPE_PARAM_NUM)) 00020 #define SFI_PSPEC_NUM(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), SFI_TYPE_PARAM_NUM, SfiParamSpecNum)) 00021 #define SFI_TYPE_PARAM_REAL (G_TYPE_PARAM_DOUBLE) 00022 #define SFI_IS_PSPEC_REAL(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), SFI_TYPE_PARAM_REAL)) 00023 #define SFI_PSPEC_REAL(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), SFI_TYPE_PARAM_REAL, SfiParamSpecReal)) 00024 #define SFI_TYPE_PARAM_STRING (G_TYPE_PARAM_STRING) 00025 #define SFI_IS_PSPEC_STRING(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), SFI_TYPE_PARAM_STRING)) 00026 #define SFI_PSPEC_STRING(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), SFI_TYPE_PARAM_STRING, SfiParamSpecString)) 00027 #define SFI_TYPE_PARAM_CHOICE (sfi__param_spec_types[0]) 00028 #define SFI_IS_PSPEC_CHOICE(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), SFI_TYPE_PARAM_CHOICE)) 00029 #define SFI_PSPEC_CHOICE(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), SFI_TYPE_PARAM_CHOICE, SfiParamSpecChoice)) 00030 #define SFI_TYPE_PARAM_BBLOCK (sfi__param_spec_types[1]) 00031 #define SFI_IS_PSPEC_BBLOCK(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), SFI_TYPE_PARAM_BBLOCK)) 00032 #define SFI_PSPEC_BBLOCK(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), SFI_TYPE_PARAM_BBLOCK, SfiParamSpecBBlock)) 00033 #define SFI_TYPE_PARAM_FBLOCK (sfi__param_spec_types[2]) 00034 #define SFI_IS_PSPEC_FBLOCK(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), SFI_TYPE_PARAM_FBLOCK)) 00035 #define SFI_PSPEC_FBLOCK(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), SFI_TYPE_PARAM_FBLOCK, SfiParamSpecFBlock)) 00036 #define SFI_TYPE_PARAM_PSPEC (G_TYPE_PARAM_PARAM) 00037 #define SFI_IS_PSPEC_PSPEC(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), SFI_TYPE_PARAM_PSPEC)) 00038 #define SFI_PSPEC_PSPEC(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), SFI_TYPE_PARAM_PSPEC, SfiParamSpecPSpec)) 00039 #define SFI_TYPE_PARAM_SEQ (sfi__param_spec_types[3]) 00040 #define SFI_IS_PSPEC_SEQ(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), SFI_TYPE_PARAM_SEQ)) 00041 #define SFI_PSPEC_SEQ(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), SFI_TYPE_PARAM_SEQ, SfiParamSpecSeq)) 00042 #define SFI_TYPE_PARAM_REC (sfi__param_spec_types[4]) 00043 #define SFI_IS_PSPEC_REC(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), SFI_TYPE_PARAM_REC)) 00044 #define SFI_PSPEC_REC(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), SFI_TYPE_PARAM_REC, SfiParamSpecRec)) 00045 #define SFI_TYPE_PARAM_PROXY (sfi__param_spec_types[5]) 00046 #define SFI_IS_PSPEC_PROXY(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), SFI_TYPE_PARAM_PROXY)) 00047 #define SFI_PSPEC_PROXY(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), SFI_TYPE_PARAM_PROXY, SfiParamSpecProxy)) 00048 #define SFI_TYPE_PARAM_NOTE (sfi__param_spec_types[6]) 00049 #define SFI_IS_PSPEC_NOTE(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), SFI_TYPE_PARAM_NOTE)) 00050 #define SFI_PSPEC_NOTE(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), SFI_TYPE_PARAM_NOTE, SfiParamSpecNote)) 00051 00052 00053 /* --- Sfi param spec aliases --- */ 00054 typedef GParamSpecBoolean SfiParamSpecBool; 00055 typedef GParamSpecInt SfiParamSpecInt; 00056 typedef GParamSpecInt64 SfiParamSpecNum; 00057 typedef GParamSpecDouble SfiParamSpecReal; 00058 typedef GParamSpecString SfiParamSpecString; 00059 typedef GParamSpecParam SfiParamSpecPSpec; 00060 00061 00062 /* --- Sfi param specs --- */ 00063 typedef struct { 00064 const gchar *choice_ident; 00065 const gchar *choice_label; 00066 const gchar *choice_blurb; 00067 } SfiChoiceValue; // auxillary 00068 typedef struct { 00069 guint n_values; 00070 const SfiChoiceValue *values; 00071 } SfiChoiceValues; // auxillary 00072 typedef struct { 00073 GParamSpecString pspec; 00074 SfiChoiceValues cvalues; 00075 } SfiParamSpecChoice; 00076 typedef struct { 00077 GParamSpecBoxed pspec; 00078 } SfiParamSpecBBlock; 00079 typedef struct { 00080 GParamSpecBoxed pspec; 00081 } SfiParamSpecFBlock; 00082 typedef struct { 00083 GParamSpecBoxed pspec; 00084 GParamSpec *element; 00085 } SfiParamSpecSeq; 00086 typedef struct { 00087 GParamSpecBoxed pspec; 00088 SfiRecFields fields; 00089 } SfiParamSpecRec; 00090 typedef struct { 00091 GParamSpecPointer pspec; 00092 } SfiParamSpecProxy; 00093 typedef struct { 00094 GParamSpecInt pspec; 00095 gboolean allow_void; 00096 } SfiParamSpecNote; 00097 00098 00099 /* --- Sfi GParamSpec constructors --- */ 00100 GParamSpec* sfi_pspec_bool (const gchar *name, 00101 const gchar *nick, 00102 const gchar *blurb, 00103 SfiBool default_value, 00104 const gchar *hints); 00105 GParamSpec* sfi_pspec_int (const gchar *name, 00106 const gchar *nick, 00107 const gchar *blurb, 00108 SfiInt default_value, 00109 SfiInt minimum_value, 00110 SfiInt maximum_value, 00111 SfiInt stepping, 00112 const gchar *hints); 00113 GParamSpec* sfi_pspec_num (const gchar *name, 00114 const gchar *nick, 00115 const gchar *blurb, 00116 SfiNum default_value, 00117 SfiNum minimum_value, 00118 SfiNum maximum_value, 00119 SfiNum stepping, 00120 const gchar *hints); 00121 GParamSpec* sfi_pspec_real (const gchar *name, 00122 const gchar *nick, 00123 const gchar *blurb, 00124 SfiReal default_value, 00125 SfiReal minimum_value, 00126 SfiReal maximum_value, 00127 SfiReal stepping, 00128 const gchar *hints); 00129 GParamSpec* sfi_pspec_log_scale (const gchar *name, 00130 const gchar *nick, 00131 const gchar *blurb, 00132 SfiReal default_value, 00133 SfiReal minimum_value, 00134 SfiReal maximum_value, 00135 SfiReal stepping, 00136 SfiReal center, 00137 SfiReal base, 00138 SfiReal n_steps, 00139 const gchar *hints); 00140 GParamSpec* sfi_pspec_string (const gchar *name, 00141 const gchar *nick, 00142 const gchar *blurb, 00143 const gchar *default_value, 00144 const gchar *hints); 00145 GParamSpec* sfi_pspec_choice (const gchar *name, 00146 const gchar *nick, 00147 const gchar *blurb, 00148 const gchar *default_value, 00149 SfiChoiceValues static_const_evalues, 00150 const gchar *hints); 00151 GParamSpec* sfi_pspec_bblock (const gchar *name, 00152 const gchar *nick, 00153 const gchar *blurb, 00154 const gchar *hints); 00155 GParamSpec* sfi_pspec_fblock (const gchar *name, 00156 const gchar *nick, 00157 const gchar *blurb, 00158 const gchar *hints); 00159 GParamSpec* sfi_pspec_pspec (const gchar *name, 00160 const gchar *nick, 00161 const gchar *blurb, 00162 const gchar *hints); 00163 GParamSpec* sfi_pspec_seq (const gchar *name, 00164 const gchar *nick, 00165 const gchar *blurb, 00166 GParamSpec *element_spec, 00167 const gchar *hints); 00168 GParamSpec* sfi_pspec_rec (const gchar *name, 00169 const gchar *nick, 00170 const gchar *blurb, 00171 SfiRecFields static_const_fields, 00172 const gchar *hints); 00173 GParamSpec* sfi_pspec_rec_generic (const gchar *name, 00174 const gchar *nick, 00175 const gchar *blurb, 00176 const gchar *hints); 00177 GParamSpec* sfi_pspec_proxy (const gchar *name, 00178 const gchar *nick, 00179 const gchar *blurb, 00180 const gchar *hints); 00181 00182 00183 /* --- pspec wrappers --- */ 00184 #define sfi_pspec_ref g_param_spec_ref 00185 #define sfi_pspec_unref g_param_spec_unref 00186 #define sfi_pspec_sink g_param_spec_sink 00187 #define sfi_pspec_get_qdata g_param_spec_get_qdata 00188 #define sfi_pspec_set_qdata g_param_spec_set_qdata 00189 #define sfi_pspec_set_qdata_full g_param_spec_set_qdata_full 00190 #define sfi_pspec_steal_qdata g_param_spec_steal_qdata 00191 #define sfi_pspec_get_name g_param_spec_get_name 00192 #define sfi_pspec_get_nick g_param_spec_get_nick 00193 #define sfi_pspec_get_blurb g_param_spec_get_blurb 00194 00195 00196 /* --- conversion --- */ 00197 typedef SfiChoiceValues (*SfiChoiceValueGetter) (GType enum_type); 00198 GParamSpec* sfi_pspec_to_serializable (GParamSpec *pspec); 00199 GParamSpec* sfi_pspec_choice_from_enum (GParamSpec *enum_pspec); 00200 GParamSpec* sfi_pspec_proxy_from_object (GParamSpec *object_pspec); 00201 void sfi_enum_type_set_choice_value_getter (GType gtype, 00202 SfiChoiceValueGetter cvgetter); 00203 void sfi_boxed_type_set_rec_fields (GType boxed_type, 00204 const SfiRecFields static_const_fields); 00205 SfiRecFields sfi_boxed_type_get_rec_fields (GType boxed_type); 00206 void sfi_boxed_type_set_seq_element (GType boxed_type, 00207 GParamSpec *element); 00208 GParamSpec* sfi_boxed_type_get_seq_element (GType boxed_type); 00209 00210 00211 /* --- Sfi PSpec Options --- */ 00212 /* provide common option combinations: */ 00213 #define SFI_PARAM_READWRITE ":r:w:" 00214 #define SFI_PARAM_STORAGE ":r:w:S:" 00215 #define SFI_PARAM_STANDARD ":r:w:S:G:" 00216 #define SFI_PARAM_STANDARD_RDONLY ":r:w:S:G:ro:" 00217 #define SFI_PARAM_GUI ":r:w:G:" 00218 #define SFI_PARAM_GUI_RDONLY ":r:w:G:ro:" 00219 #define SFI_PARAM_GUI_READABLE ":r:G:" 00220 00221 00222 /* --- serializable categories --- */ 00223 typedef enum /*< skip >*/ 00224 { 00225 SFI_SCAT_INVAL = 0, 00226 SFI_SCAT_BOOL = 'b', 00227 SFI_SCAT_INT = 'i', 00228 SFI_SCAT_NUM = 'n', 00229 SFI_SCAT_REAL = 'r', 00230 SFI_SCAT_STRING = 's', 00231 SFI_SCAT_CHOICE = 'C', 00232 SFI_SCAT_BBLOCK = 'B', 00233 SFI_SCAT_FBLOCK = 'F', 00234 SFI_SCAT_PSPEC = 'P', 00235 SFI_SCAT_SEQ = 'Q', 00236 SFI_SCAT_REC = 'R', 00237 SFI_SCAT_PROXY = 'p', 00238 SFI_SCAT_TYPE_MASK = 0x00ff, 00239 SFI_SCAT_NOTE = 0x0100 | SFI_SCAT_INT, 00240 SFI_SCAT_TIME = 0x0200 | SFI_SCAT_NUM, 00241 } SfiSCategory; 00242 00243 SfiSCategory sfi_categorize_type (GType value_type); 00244 SfiSCategory sfi_categorize_pspec (GParamSpec *pspec); 00245 GType sfi_category_type (SfiSCategory pspec_cat); 00246 GType sfi_category_param_type (SfiSCategory pspec_cat); 00247 00248 00249 /* --- convenience aliases --- */ 00250 GParamSpec* sfi_pspec_note (const gchar *name, 00251 const gchar *nick, 00252 const gchar *blurb, 00253 SfiInt default_value, 00254 SfiInt min_note, 00255 SfiInt max_note, 00256 gboolean allow_void, 00257 const gchar *hints); 00258 #define SFI_IS_PSPEC_TIME SFI_IS_PSPEC_TIME 00259 GParamSpec* sfi_pspec_time (const gchar *name, 00260 const gchar *nick, 00261 const gchar *blurb, 00262 const gchar *hints); 00263 00264 00265 /* --- pspec accessors --- */ 00266 GParamSpec* sfi_pspec_set_group (GParamSpec *pspec, 00267 const gchar *group); 00268 const gchar* sfi_pspec_get_group (GParamSpec *pspec); 00269 void sfi_pspec_set_owner (GParamSpec *pspec, 00270 const gchar *owner); 00271 const gchar* sfi_pspec_get_owner (GParamSpec *pspec); 00272 #define sfi_pspec_set_options(pspec, opts) g_param_spec_set_options (pspec, opts) 00273 #define sfi_pspec_add_option(pspec, opt, val) g_param_spec_add_option (pspec, opt, val) 00274 #define sfi_pspec_check_option(pspec, opt) g_param_spec_check_option (pspec, opt) 00275 #define sfi_pspec_provides_options(pspec, opts) g_param_spec_provides_options (pspec, opts) 00276 #define sfi_pspec_get_options(pspec) g_param_spec_get_options (pspec) 00277 SfiBool sfi_pspec_get_bool_default (GParamSpec *pspec); 00278 SfiInt sfi_pspec_get_int_default (GParamSpec *pspec); 00279 void sfi_pspec_get_int_range (GParamSpec *pspec, 00280 SfiInt *minimum_value, 00281 SfiInt *maximum_value, 00282 SfiInt *stepping); 00283 gboolean sfi_pspec_allows_void_note (GParamSpec *pspec); 00284 #define sfi_pspec_get_note_default sfi_pspec_get_int_default 00285 #define sfi_pspec_get_note_range sfi_pspec_get_int_range 00286 SfiNum sfi_pspec_get_num_default (GParamSpec *pspec); 00287 void sfi_pspec_get_num_range (GParamSpec *pspec, 00288 SfiNum *minimum_value, 00289 SfiNum *maximum_value, 00290 SfiNum *stepping); 00291 SfiReal sfi_pspec_get_real_default (GParamSpec *pspec); 00292 void sfi_pspec_get_real_range (GParamSpec *pspec, 00293 SfiReal *minimum_value, 00294 SfiReal *maximum_value, 00295 SfiReal *stepping); 00296 #define sfi_pspec_set_log_scale(p, c, b, n) g_param_spec_set_log_scale (p, c, b, n) 00297 #define sfi_pspec_get_log_scale(p, c, b, n) g_param_spec_get_log_scale (p, c, b, n) 00298 const gchar* sfi_pspec_get_string_default (GParamSpec *pspec); 00299 const gchar* sfi_pspec_get_choice_default (GParamSpec *pspec); 00300 SfiChoiceValues sfi_pspec_get_choice_values (GParamSpec *pspec); 00301 guint64 sfi_pspec_get_choice_hash (GParamSpec *pspec); 00302 GParamSpec* sfi_pspec_get_seq_element (GParamSpec *pspec); 00303 SfiRecFields sfi_pspec_get_rec_fields (GParamSpec *pspec); 00304 GParamSpec* sfi_pspec_get_rec_field (GParamSpec *pspec, 00305 const gchar *field_name); 00306 00307 00308 /* --- internal --- */ 00309 void _sfi_init_params (void); 00310 extern GType* sfi__param_spec_types; 00311 SfiRec* sfi_pspec_to_rec (GParamSpec *pspec); 00312 GParamSpec* sfi_pspec_from_rec (SfiRec *prec); 00313 00314 00315 G_END_DECLS 00316 00317 #endif /* __SFI_PARAMS_H__ */ 00318 00319 /* vim:set ts=8 sts=2 sw=2: */