Beast - Music Synthesizer and Composer  0.11.1+10.g2da35
sfiglue.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_GLUE_H__
3 #define __SFI_GLUE_H__
4 
5 #include <sfi/sfiprimitives.hh>
6 #include <sfi/sfiring.hh>
7 #include <sfi/sfiparams.hh>
8 
9 /* Glue proxy (object handle) description in terms of
10  * supported interfaces and property names
11  */
12 typedef struct {
13  guint ref_count;
14  gchar *type_name; /* interface type name */
15  guint n_ifaces;
16  gchar **ifaces;/*NULL-term*/ /* supported interfaces */
17  guint n_props;
18  gchar **props;/*NULL-term*/ /* property names */
19 } SfiGlueIFace;
20 
21 gchar* sfi_glue_base_iface (void);
22 const gchar** sfi_glue_iface_children (const gchar *iface_name);
23 SfiGlueIFace* sfi_glue_describe_iface (const gchar *iface_name);
24 SfiGlueIFace* sfi_glue_iface_ref (SfiGlueIFace *iface);
25 void sfi_glue_iface_unref (SfiGlueIFace *iface);
26 
27 
28 
29 /* Procedure description in terms of it's parameters
30  */
31 typedef struct {
32  guint ref_count;
33  gchar *name;
34  gchar *help;
35  gchar *authors;
36  gchar *license;
37  GParamSpec *ret_param;
38  guint n_params;
39  GParamSpec **params;
40 } SfiGlueProc;
41 
42 SfiGlueProc* sfi_glue_describe_proc (const gchar *proc_name);
43 SfiGlueProc* sfi_glue_proc_ref (SfiGlueProc *proc);
44 void sfi_glue_proc_unref (SfiGlueProc *proc);
45 const gchar** sfi_glue_list_proc_names (void);
46 const gchar** sfi_glue_list_method_names (const gchar *iface_name);
47 
48 GValue* sfi_glue_call_seq (const gchar *proc_name,
49  SfiSeq *params);
50 GValue* sfi_glue_call_valist (const gchar *proc_name,
51  guint8 first_arg_type,
52  va_list var_args);
53 void sfi_glue_vcall_void (const gchar *proc_name,
54  guint8 first_arg_type,
55  ...);
56 SfiBool sfi_glue_vcall_bool (const gchar *proc_name,
57  guint8 first_arg_type,
58  ...);
59 SfiInt sfi_glue_vcall_int (const gchar *proc_name,
60  guint8 first_arg_type,
61  ...);
62 SfiNum sfi_glue_vcall_num (const gchar *proc_name,
63  guint8 first_arg_type,
64  ...);
65 SfiReal sfi_glue_vcall_real (const gchar *proc_name,
66  guint8 first_arg_type,
67  ...);
68 const gchar* sfi_glue_vcall_string (const gchar *proc_name,
69  guint8 first_arg_type,
70  ...);
71 const gchar* sfi_glue_vcall_choice (const gchar *proc_name,
72  guint8 first_arg_type,
73  ...);
74 SfiProxy sfi_glue_vcall_proxy (const gchar *proc_name,
75  guint8 first_arg_type,
76  ...);
77 SfiSeq* sfi_glue_vcall_seq (const gchar *proc_name,
78  guint8 first_arg_type,
79  ...);
80 SfiRec* sfi_glue_vcall_rec (const gchar *proc_name,
81  guint8 first_arg_type,
82  ...);
83 SfiFBlock* sfi_glue_vcall_fblock (const gchar *proc_name,
84  guint8 first_arg_type,
85  ...);
86 SfiBBlock* sfi_glue_vcall_bblock (const gchar *proc_name,
87  guint8 first_arg_type,
88  ...);
89 GValue* sfi_glue_client_msg (const gchar *msg,
90  GValue *value);
91 
92 
93 /* Glue context table, abstracts middleware implementation */
94 typedef struct _SfiGlueContext SfiGlueContext;
95 typedef struct {
96  /* core functions */
97  SfiGlueIFace* (*describe_iface) (SfiGlueContext *context,
98  const gchar *iface);
99  SfiGlueProc* (*describe_proc) (SfiGlueContext *context,
100  const gchar *proc_name);
101  gchar** (*list_proc_names) (SfiGlueContext *context);
102  gchar** (*list_method_names) (SfiGlueContext *context,
103  const gchar *iface_name);
104  gchar* (*base_iface) (SfiGlueContext *context);
105  gchar** (*iface_children) (SfiGlueContext *context,
106  const gchar *iface_name);
107  GValue* (*exec_proc) (SfiGlueContext *context,
108  const gchar *proc_name,
109  SfiSeq *params);
110  /* proxy functions */
111  gchar* (*proxy_iface) (SfiGlueContext *context,
112  SfiProxy proxy);
113  gboolean (*proxy_is_a) (SfiGlueContext *context,
114  SfiProxy proxy,
115  const gchar *iface);
116  gchar** (*proxy_list_properties) (SfiGlueContext *context,
117  SfiProxy proxy,
118  const gchar *first_ancestor,
119  const gchar *last_ancestor);
120  GParamSpec* (*proxy_get_pspec) (SfiGlueContext *context,
121  SfiProxy proxy,
122  const gchar *prop_name);
123  SfiSCategory (*proxy_get_pspec_scategory) (SfiGlueContext *context,
124  SfiProxy proxy,
125  const gchar *prop_name);
126  void (*proxy_set_property) (SfiGlueContext *context,
127  SfiProxy proxy,
128  const gchar *prop,
129  const GValue *value);
130  GValue* (*proxy_get_property) (SfiGlueContext *context,
131  SfiProxy proxy,
132  const gchar *prop);
133  gboolean (*proxy_watch_release) (SfiGlueContext *context,
134  SfiProxy proxy);
135  gboolean (*proxy_request_notify) (SfiGlueContext *context,
136  SfiProxy proxy,
137  const gchar *signal,
138  gboolean enable_notify);
139  void (*proxy_processed_notify) (SfiGlueContext *context,
140  guint notify_id);
141  /* misc extensions */
142  GValue* (*client_msg) (SfiGlueContext *context,
143  const gchar *msg,
144  GValue *value);
145  /* framework functions */
146  SfiRing* (*fetch_events) (SfiGlueContext *context);
147  SfiRing* (*list_poll_fds) (SfiGlueContext *context);
148  void (*destroy) (SfiGlueContext *context);
150 
151 
152 /* --- Glue Context --- */
154 {
155  /*< private >*/
156  SfiGlueContextTable table;
157  gulong seq_hook_id;
158  GHashTable *gc_hash;
159  SfiUStore *proxies;
160  SfiRing *pending_events;
161 };
162 void sfi_glue_context_push (SfiGlueContext *context);
163 SfiGlueContext* sfi_glue_context_current (void);
164 void sfi_glue_context_pop (void);
165 SfiRing* sfi_glue_context_list_poll_fds (void);
166 void sfi_glue_context_process_fd (void);
167 gboolean sfi_glue_context_pending (void);
168 void sfi_glue_context_dispatch (void);
169 SfiSeq* sfi_glue_context_fetch_event (void);
170 void sfi_glue_context_destroy (SfiGlueContext *context);
171 
172 
173 /* --- Glue utilities --- */
174 #ifdef __cplusplus
175 typedef void (*SfiGlueGcFreeFunc) (void*);
176 #else
177 typedef void *SfiGlueGcFreeFunc; // FIXME: remove C-legacy
178 #endif
179 
180 void sfi_glue_gc_add (gpointer data,
181  SfiGlueGcFreeFunc free_func);
182 void sfi_glue_gc_remove (gpointer data,
183  SfiGlueGcFreeFunc free_func);
184 void sfi_glue_gc_free_now (gpointer data,
185  SfiGlueGcFreeFunc free_func);
186 void sfi_glue_gc_run (void);
187 
188 
189 /* --- internal --- */
190 gboolean _sfi_glue_gc_test (gpointer data,
191  gpointer free_func);
192 SfiGlueIFace* sfi_glue_iface_new (const gchar *iface_name);
193 SfiGlueProc* sfi_glue_proc_new (const gchar *proc_name);
194 void sfi_glue_proc_add_param (SfiGlueProc *proc,
195  GParamSpec *param);
196 void sfi_glue_proc_add_ret_param (SfiGlueProc *proc,
197  GParamSpec *param);
198 gboolean _sfi_glue_proxy_request_notify (SfiProxy proxy,
199  const gchar *signal,
200  gboolean enable_notify);
201 
202 
203 /* --- implementations --- */
204 void _sfi_init_glue (void);
205 void sfi_glue_context_common_init (SfiGlueContext *context,
206  const SfiGlueContextTable *vtable);
207 SfiGlueContext* sfi_glue_fetch_context (const gchar *floc);
208 
209 #endif /* __SFI_GLUE_H__ */
210 
211 /* vim:set ts=8 sts=2 sw=2: */
Definition: sfiglue.hh:153
Definition: sfiglue.hh:31
Definition: sfiglue.hh:95
signal
Definition: sfiring.hh:21
Definition: sfiglue.hh:12