## BonoboXObject

BonoboXObject — a simplified CORBA server object wrapper

## Synopsis

    #define     BONOBO_X_OBJECT_TYPE
    #define     BONOBO_X_OBJECT_HEADER_SIZE
    #define     BONOBO_X_OBJECT_GET_SERVANT     (o)
    #define     BONOBO_X_SERVANT_GET_OBJECT     (o)
    #define     BonoboXObject
    #define     BonoboXObjectClass
    #define     bonobo_x_object
    #define     BonoboXObjectPOAFn
    #define     bonobo_x_type_unique
    #define     bonobo_x_type_setup
    #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. However, for libbonobo-2.0, all its functionality has been merged with BonoboObject, which is the one that should be used for writing Bonobo/CORBA servers.

The CORBA methods are associated with a GObject class in the same way that standard GObject 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 GObjectClass 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 GObject fashion ).

Example 2. Registering the type with bonobo

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

    	if (type == 0) {
    		static GTypeInfo info = {
    			"BonoboControl",
    			NULL, NULL,
    			sizeof (BonoboControlClass),
    			(GClassInitFunc)bonobo_control_class_init,
    			NULL, NULL,
    			sizeof (BonoboControl), 0,
    			(GObjectInitFunc)bonobo_control_init,
    			NULL
    		};
    		ptype = (parent);
    		type = bonobo_x_type_unique (ptype,
    			POA_Bonobo_Control__init, NULL,
    			G_STRUCT_OFFSET (BonoboControlClass, epv),
    			&info, "BonoboControl");
    	}
    	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 G_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)
    {
    	GObjectClass *object_class = (GObjectClass *)klass;
    	POA_Bonobo_Control__epv *epv = &klass->epv;

    	bonobo_control_parent_class = g_type_class_peek (PARENT_TYPE);

    	...

    	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_OBJECT_TYPE

    #define BONOBO_X_OBJECT_TYPE        BONOBO_TYPE_X_OBJECT /* deprecated, you should use BONOBO_TYPE_X_OBJECT */

### BONOBO_X_OBJECT_HEADER_SIZE

    #define BONOBO_X_OBJECT_HEADER_SIZE BONOBO_OBJECT_HEADER_SIZE

### BONOBO_X_OBJECT_GET_SERVANT()

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

`o` : |

### BONOBO_X_SERVANT_GET_OBJECT()

    #define     BONOBO_X_SERVANT_GET_OBJECT(o)

`o` : |

### BonoboXObject

    #define BonoboXObject            BonoboObject

### BonoboXObjectClass

    #define BonoboXObjectClass       BonoboObjectClass

### bonobo_x_object

    #define bonobo_x_object          bonobo_object

Returns : |

### BonoboXObjectPOAFn

    #define BonoboXObjectPOAFn       BonoboObjectPOAFn

### bonobo_x_type_unique

    #define bonobo_x_type_unique     bonobo_type_unique

Returns : |

### bonobo_x_type_setup

    #define bonobo_x_type_setup      bonobo_type_setup

Returns : |

### 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