| Bonobo API Reference Manual | |||
|---|---|---|---|
| <<< Previous Page | Home | Up | Next Page >>> |
struct BonoboGenericFactory; BonoboObject* (*BonoboGenericFactoryFn) ( |
The vast majority of Bonobo objects are created by the
Most applications when they start up will register their Bonobo object factory with OAF, this can be done like this:
Example 1. How to register a factory with OAF
BonoboGenericFactory *factory;
factory = bonobo_generic_factory_new_multi (
"OAFIID:GNOME_MyApp_myId",
my_factory_function, NULL);
bonobo_running_context_auto_exit_unref (BONOBO_OBJECT (factory));
|
When an object that is created by your factory is demanded from OAF the my_factory_function will be called:
Example 2. A simple factory
static BonoboObject *
my_factory_fn (BonoboGenericFactory *this,
const char *object_id,
void *data)
{
BonoboObject *object = NULL;
g_return_val_if_fail (object_id != NULL, NULL);
if (!strcmp (object_id, "OAFIID:Bonobo_Sample_Clock"))
object = |
The generic factory works in two modes, multi and plain, it is recommended that the multi mode be used. Also, there is a macro that can be used for simple components to remove the burden of writing the main function and getting the initialization correct, see BONOBO_OAF_FACTORY_MULTI.
BonoboObject* (*BonoboGenericFactoryFn) ( |
| Factory : | |
| closure : | |
| Returns : |
|
BonoboObject* (*GnomeFactoryCallback) ( |
| factory : | |
| component_id : | |
| closure : | |
| Returns : |
typedef struct {
BonoboObjectClass parent_class;
/* Virtual methods */
BonoboObject *(*new_generic) (BonoboGenericFactory *c_factory,
const char *component_id);
} BonoboGenericFactoryClass; |
|
This is a helper routine that simplifies the creation of factory objects for GNOME objects. The factory function will be invoked by the CORBA server when a request arrives to create a new instance of an object supporting the Bonobo::Generic interface. The factory callback routine is passed the data pointer to provide the creation function with some state information.
| oaf_iid : | The GOAD id that this factory implements |
| factory : | |
| user_data : | |
| Returns : | A BonoboGenericFactory object that has an activated Bonobo::GenericFactory object that has registered with the GNOME name server. |
|
| oaf_iid : | |
| factory_cb : | |
| data : | |
| Returns : |
|
Initializes c_factory with the command-line arguments and registers the new factory in the name server.
| oaf_iid : | The GOAD id that the new factory will implement. |
| c_factory : | The object to be initialized. |
| corba_factory : | The CORBA object which supports the Bonobo::GenericFactory interface and which will be used to construct this BonoboGenericFactory Gtk object. |
| factory : | A callback which is used to create new GnomeGeneric object instances. |
| factory_cb : | A Multi object factory callback. |
| user_data : | The closure data to be passed to the factory callback routine. |
| Returns : | The initialized BonoboGenericFactory object. |
void bonobo_generic_factory_set ( |
Sets the callback and callback closure for c_factory to factory and data, respectively.
| c_factory : | The BonoboGenericFactory object whose callback will be set. |
| factory : | A callback routine which is used to create new object instances. |
| data : | The closure data to be passed to the factory callback. |
|
| Returns : | The EPV for the default BonoboGenericFactory implementation. |
|
| object : | |
| shlib_id : | |
| Returns : |
|
#define BONOBO_OAF_FACTORY(oafiid, descr, version, fn, data) |
| oafiid : | |
| descr : | |
| version : | |
| fn : | |
| data : |
|