BonoboXObject

Name

BonoboXObject -- a simplified CORBA server object wrapper

Synopsis



#define     BONOBO_X_SERVANT_GET_OBJECT     (o)
#define     BONOBO_X_OBJECT_GET_SERVANT     (o)
struct      BonoboXObject;
typedef     BonoboXObjectClass;
void        (*BonoboXObjectPOAFn)           (PortableServer_Servant servant,
                                             CORBA_Environment *ev);
BonoboXObject* bonobo_x_object              (gpointer p);
GtkType     bonobo_x_type_unique            (GtkType parent_type,
                                             BonoboXObjectPOAFn init_fn,
                                             BonoboXObjectPOAFn fini_fn,
                                             int epv_struct_offset,
                                             const GtkTypeInfo *info);
gboolean    bonobo_x_type_setup             (GtkType type,
                                             BonoboXObjectPOAFn init_fn,
                                             BonoboXObjectPOAFn fini_fn,
                                             int epv_struct_offset);
#define     BONOBO_X_TYPE_FUNC_FULL         (class_name, corba_name, parent, prefix)
#define     BONOBO_X_TYPE_FUNC              (class_name, parent, prefix)

Description

BonoboXObject provides an easy to use way of writing CORBA servers. It strongly deprecates BonoboObject ( with which it is compatible ). It drastically simplifies the issues of epv and vepv construction by automating these, and automatically instantiates a CORBA_Object on gtk_type_new. This removes clutter from construction time.

The CORBA methods are associated with a Gtk class in the same way that standard Gtk+ methods and signals are. We insert the CORBA generated Entry Point Vector (epv) struct as the first element of the derived class eg.

Example 1. Setting up the GtkClass data

typedef struct {
	BonoboXObject base;

	BonoboControlPrivate *priv;
} BonoboControl;

typedef struct {
	BonoboXObjectClass      parent_class;

	POA_Bonobo_Control__epv epv;

	/* Signals. */
	void (*set_frame)      (BonoboControl *control);
	void (*activate)       (BonoboControl *control, gboolean state);
} BonoboControlClass;
     

Then we set up the type using the bonobo_x_type_unique function instead of gtk_type_unique ( but otherwise in the standard Gtk+ fashion ).

Example 2. Registering the type with bonobo

GtkType
bonobo_control_get_type (void)
{
	GtkType ptype;
	static GtkType type = 0;

	if (type == 0) {
		static GtkTypeInfo info = {
			"BonoboControl",
			sizeof (BonoboControl),
			sizeof (BonoboControlClass),
			(GtkClassInitFunc)bonobo_control_class_init,
			(GtkObjectInitFunc)bonobo_control_init,
			NULL, NULL, (GtkClassInitFunc) NULL
		};
		ptype = (parent);
		type = bonobo_x_type_unique (ptype,
			POA_Bonobo_Control__init, NULL,
			GTK_STRUCT_OFFSET (BonoboControlClass, epv),
			&info);
	}
	return type;
}
     
Alternatively one can use the simpler BONOBO_X_TYPE_FUNC_FULL macros to achieve the same thing thus:

Example 3. Registering the type more simply

BONOBO_X_TYPE_FUNC_FULL (BonoboControl, Bonobo_Control,
                         PARENT_TYPE, bonobo_control);
     
The POA_Bonobo_Control__init function is used to construct the CORBA object and the GTK_STRUCT_OFFSET tells Bonobo where your epv structure is in the Class data, so it can build your epv for you. The fini_fn function is not used in ORBit, so it is faster to use NULL here.

After registering the type in the class initialization function, we must fill out the epv with our entry points, similar to the way we hook up virtual class functions. It may also be necessary to override the parent's epv's; this can be done by accessing the epv pointer for the parent class.

Example 4. Setting up the class' methods

static void
bonobo_control_class_init (BonoboControlClass *klass)
{
	GtkObjectClass *object_class = (GtkObjectClass *)klass;
	POA_Bonobo_Control__epv *epv = &klass->epv;

	bonobo_control_parent_class = gtk_type_class (PARENT_TYPE);

	...

	object_class->destroy  = bonobo_control_destroy;
	object_class->finalize = bonobo_control_finalize;

	epv->activate       = impl_Bonobo_Control_activate;
	epv->setSize        = impl_Bonobo_Control_setSize;
	...
	epv->realize        = impl_Bonobo_Control_realize;
	epv->unrealize      = impl_Bonobo_Control_unrealize;
}
     

Details

BONOBO_X_SERVANT_GET_OBJECT()

#define     BONOBO_X_SERVANT_GET_OBJECT(o)

o : 


BONOBO_X_OBJECT_GET_SERVANT()

#define BONOBO_X_OBJECT_GET_SERVANT(o) ((PortableServer_Servant)&(o)->servant)

o : 


struct BonoboXObject

struct BonoboXObject;


BonoboXObjectClass

typedef struct {
	BonoboObjectClass          parent_class;

	BonoboXObjectPOAFn         poa_init_fn;
	BonoboXObjectPOAFn         poa_fini_fn;

	POA_Bonobo_Unknown__vepv  *vepv;

	/* The offset of this class' additional epv */
	int                        epv_struct_offset;

	POA_Bonobo_Unknown__epv    epv;
} BonoboXObjectClass;


BonoboXObjectPOAFn ()

void        (*BonoboXObjectPOAFn)           (PortableServer_Servant servant,
                                             CORBA_Environment *ev);

servant : 
ev : 


bonobo_x_object ()

BonoboXObject* bonobo_x_object              (gpointer p);

This function can be passed a BonoboXObject * or a PortableServer_Servant, and it will return a BonoboXObject *.

p : a pointer to something
Returns : a BonoboXObject or NULL.


bonobo_x_type_unique ()

GtkType     bonobo_x_type_unique            (GtkType parent_type,
                                             BonoboXObjectPOAFn init_fn,
                                             BonoboXObjectPOAFn fini_fn,
                                             int epv_struct_offset,
                                             const GtkTypeInfo *info);

This function is the main entry point for deriving bonobo server interfaces.

parent_type : the parent Gtk Type
init_fn : a POA initialization function
fini_fn : a POA finialization function or NULL
epv_struct_offset : the offset into the struct that the epv commences at, or 0 if we are inheriting a plain Gtk Object from a BonoboXObject, adding no new CORBA interfaces
info : the standard GtkTypeInfo.
Returns : the constructed Gtk Type.


bonobo_x_type_setup ()

gboolean    bonobo_x_type_setup             (GtkType type,
                                             BonoboXObjectPOAFn init_fn,
                                             BonoboXObjectPOAFn fini_fn,
                                             int epv_struct_offset);

This function initializes a type derived from BonoboXObject, such that when you instantiate a new object of this type with gtk_type_new the CORBA object will be correctly created and embedded.

type : The type to initialize
init_fn : the POA_init function for the CORBA interface or NULL
fini_fn : NULL or a custom POA free fn.
epv_struct_offset : the offset in the class structure where the epv is or 0
Returns : TRUE on success, FALSE on error.


BONOBO_X_TYPE_FUNC_FULL()

#define     BONOBO_X_TYPE_FUNC_FULL(class_name, corba_name, parent, prefix)

class_name : 
corba_name : 
parent : 
prefix : 


BONOBO_X_TYPE_FUNC()

#define     BONOBO_X_TYPE_FUNC(class_name, parent, prefix)

class_name : 
parent : 
prefix : 

See Also

BonoboObject