2 #ifndef __BSE_CXX_BASE_H__
3 #define __BSE_CXX_BASE_H__
10 #define BSE_CXX_INSTANCE_OFFSET BSE_CXX_SIZEOF (BseSource)
12 #define BSE_TYPE_CXX_BASE (BSE_CXX_TYPE_GET_REGISTERED (Bse, CxxBase))
16 void add_param (
const char *group,
19 void add_param (guint prop_id,
20 GParamSpec *grouped_pspec);
21 void set_accessors (
void (*get_property) (GObject*, guint, GValue*, GParamSpec*),
22 void (*set_property) (GObject*, guint,
const GValue*, GParamSpec*) = NULL,
23 gboolean (*editable_property) (
BseObject*, guint, GParamSpec*) = NULL,
24 void (*get_candidates) (
BseItem*, guint, BsePropertyCandidates*, GParamSpec*) = NULL,
25 void (*property_updated) (
BseSource*, guint, guint64,
double, GParamSpec*) = NULL);
26 guint add_signal (
const gchar *signal_name,
30 void add_ochannel (
const char *ident,
34 void add_ichannel (
const char *ident,
38 void add_jchannel (
const char *ident,
44 void* cast_to_gobject ();
45 static CxxBase* cast_from_gobject (
void *o);
47 static CxxBase* base_from_gobject (GObject *o) {
return cast_from_gobject (o); }
49 GObject* gobject ()
const;
55 void freeze_notify ();
56 void notify (
const gchar *property);
58 void set (
const gchar *first_property_name,
59 ...) G_GNUC_NULL_TERMINATED;
60 void get (
const gchar *first_property_name,
61 ...) G_GNUC_NULL_TERMINATED;
62 void set_property (guint prop_id,
65 void get_property (guint prop_id,
69 gulong connect (
const gchar *
signal,
72 gulong connect (
const gchar *signal,
73 GClosure *closure) {
return connect (signal, closure,
false); }
75 gulong connect (
const gchar *signal,
78 gulong connect (
const gchar *signal,
79 CxxClosure *closure) {
return connect (signal, closure,
false); }
80 const String tokenize_signal (
const gchar *signal);
82 virtual void compat_setup (guint vmajor,
85 virtual void restore_finished (guint vmajor,
92 static inline bool instance_is_a (
CxxBase *cbase,
97 GObject *gobject = cbase->gobject();
98 return G_TYPE_CHECK_INSTANCE_TYPE (gobject, iface_type);
104 template<
class OType>
static inline OType*
105 value_get_gobject (
const GValue *v)
108 if (SFI_VALUE_HOLDS_PROXY (v))
109 p = bse_object_from_id (sfi_value_get_proxy (v));
111 p = g_value_get_object (v);
114 template<
class CxxType>
static inline CxxType
115 value_get_object (
const GValue *v)
117 assert_derived_from<CxxType, CxxBase*>();
118 GObject *p = value_get_gobject<GObject> (v);
119 CxxBase *b = CxxBase::base_from_gobject (p);
120 CxxType to =
static_cast<CxxType
> (b);
124 value_set_gobject (GValue *value,
127 if (SFI_VALUE_HOLDS_PROXY (value))
128 sfi_value_set_proxy (value, BSE_IS_OBJECT (
object) ? ((
BseObject*)
object)->unique_id : 0);
130 g_value_set_object (value,
object);
133 value_set_object (GValue *value,
136 value_set_gobject (value, self->gobject());
138 template<
class Accepted,
class Casted>
140 value_set_casted (GValue *value,
143 const Casted *
self =
static_cast<const Casted*
> (obj);
144 value_set_object (value,
self);
152 operator GObject* () {
return (GObject*) p->cast_to_gobject (); }
160 static CxxBase* cast (GObject *o) {
return cast_from_gobject (o); }
161 static CxxBase* cast (
BseSource *o) {
return cast_from_gobject (o); }
162 static CxxBase* cast (
BseItem *o) {
return cast_from_gobject (o); }
163 static CxxBase* cast (
BseObject *o) {
return cast_from_gobject (o); }
166 static inline CxxBase::Pointer cast (CxxBase *c) {
return CxxBase::Pointer (c); }
168 template<
class T> CxxBase* cast (T *t) {
return CxxBase::cast (t); }
171 template<
class ObjectType>
static void
172 cxx_class_init_trampoline (CxxBaseClass *klass)
174 ObjectType::class_init (klass);
177 template<
class ObjectType>
static void
178 cxx_instance_init_trampoline (GTypeInstance *instance,
181 if (G_TYPE_FROM_INSTANCE (instance) == G_TYPE_FROM_CLASS (g_class))
182 new (BSE_CXX_INSTANCE_OFFSET + (
char*) instance) ObjectType ();
185 template<
class ObjectType,
typename PropertyID>
static void
186 cxx_get_property_trampoline (GObject *o,
191 CxxBase *cbase = cast (o);
192 Value *v = (Value*) value;
193 ObjectType *instance =
static_cast<ObjectType*
> (cbase);
195 (void)
static_cast<void (ObjectType::*) (PropertyID, Value&, GParamSpec*)
> (&ObjectType::get_property);
196 instance->get_property (static_cast<PropertyID> (prop_id), *v, pspec);
199 template<
class ObjectType,
typename PropertyID>
static void
200 cxx_set_property_trampoline (GObject *o,
205 CxxBase *cbase = cast (o);
206 const Value *v = (
const Value*) value;
207 ObjectType *instance =
static_cast<ObjectType*
> (cbase);
209 (void)
static_cast<void (ObjectType::*) (PropertyID,
const Value&, GParamSpec*)
> (&ObjectType::set_property);
210 instance->set_property (static_cast<PropertyID> (prop_id), *v, pspec);
213 template<
class ObjectType,
typename PropertyID>
static gboolean
214 cxx_editable_property_trampoline (
BseObject *o,
218 CxxBase *cbase = cast (o);
219 ObjectType *instance =
static_cast<ObjectType*
> (cbase);
221 (void)
static_cast<bool (ObjectType::*) (PropertyID, GParamSpec*)
> (&ObjectType::editable_property);
222 return instance->editable_property (static_cast<PropertyID> (prop_id), pspec);
225 template<
class ObjectType,
typename PropertyID>
static void
226 cxx_get_candidates_trampoline (
BseItem *item,
228 BsePropertyCandidates *pc,
231 template<
class ObjectType,
typename PropertyID>
static void
232 cxx_property_updated_trampoline (
BseSource *source,
238 CxxBase *cbase = cast (source);
239 ObjectType *instance =
static_cast<ObjectType*
> (cbase);
241 (void)
static_cast<void (ObjectType::*) (PropertyID, guint64,
double, GParamSpec*)
> (&ObjectType::property_updated);
242 instance->property_updated (static_cast<PropertyID> (prop_id), tick_stamp, prop_value, pspec);
Definition: bsecxxbase.hh:147
Definition: bsecxxvalue.hh:13
Definition: bsecxxbase.hh:43
Definition: bseobject.hh:39
Definition: bsesource.hh:84
Definition: bsesource.hh:92
Definition: bsecxxclosure.hh:10
Definition: bseitem.hh:33
Definition: bsecxxbase.hh:14