howto write an interface



Hi, I want to write an interface with glib-object. The situation is a
parent object implements the interface, but the subclass should
overwrite the function pointers in the interface. The parent class
contains the following code in the function ags_recall_get_type:

...

static const GInterfaceInfo ags_connectable_interface_info = {
  (GInterfaceInitFunc) ags_recall_connectable_interface_init,
  NULL, /* interface_finalize */
  NULL, /* interface_data */
};

...

g_type_add_interface_static(ags_type_recall,
			    AGS_TYPE_CONNECTABLE,
                            &ags_connectable_interface_info);

...

AgsRecall has subclasses which should overwrite the functions, but I
don't know what's the proper way in the subclass to do so. How do I tell
GInterface to call a function of the subclass to overwrite?
One more, is it correct to make an object cast on the interface e.g.
(where AgsConnectable is an interface which is implemented by
AgsRecall):

void
ags_recall_connect(AgsConnectable connectable)
{
  AGS_RECALL(connectable);

  ...
}




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]