![]() | ![]() | ![]() | Libbonobo Reference Manual | ![]() |
---|
BonoboGenericFactory — The basic, generic Bonobo object factory implementation
#define BONOBO_GENERIC_FACTORY_TYPE struct BonoboGenericFactoryPrivate; struct BonoboGenericFactory; BonoboObject* (*BonoboFactoryCallback) (BonoboGenericFactory *factory, const char *component_id,gpointer closure); typedef BonoboGenericFactoryClass; BonoboGenericFactory* bonobo_generic_factory_new (const char *act_iid, BonoboFactoryCallback factory_cb,gpointer user_data); BonoboGenericFactory* bonobo_generic_factory_new_closure (const char *act_iid,GClosure *factory_closure); BonoboGenericFactory* bonobo_generic_factory_construct (BonoboGenericFactory *factory, const char *act_iid,GClosure *factory_cb); void bonobo_generic_factory_construct_noreg (BonoboGenericFactory *factory, const char *act_iid,GClosure *factory_cb); int bonobo_generic_factory_main (const char *act_iid, BonoboFactoryCallback factory_cb,gpointer user_data); #define BONOBO_FACTORY_INIT (descr, version, argcp, argv) #define BONOBO_OAF_FACTORY (oafiid, descr, version, callback, data) #define BONOBO_OAF_FACTORY_MULTI (oafiid, descr, version, callback, data) #define BONOBO_ACTIVATION_FACTORY (oafiid, descr, version, callback, data)
The vast majority of Bonobo objects are created by the BonoboGenericFactory implementation. This provides a very simple C sugar wrapper of the GNOME::ObjectFactory IDL interface, used by OAF to instantiate new objects.
Example 5. 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));
Example 6. 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 =bonobo_clock_control_new (); else g_warning ("Unknown OAFIID 's'", object_id); return 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.
#define BONOBO_GENERIC_FACTORY_TYPE BONOBO_TYPE_GENERIC_FACTORY /* deprecated, you should use BONOBO_TYPE_GENERIC_FACTORY */
struct BonoboGenericFactory { BonoboObject base; BonoboGenericFactoryPrivate *priv; };
BonoboObject* (*BonoboFactoryCallback) (BonoboGenericFactory *factory, const char *component_id,gpointer closure);
factory : | |
component_id : | |
closure : | |
Returns : |
typedef struct { BonoboObjectClass parent_class; POA_Bonobo_GenericFactory__epv epv; BonoboObject *(*new_generic) (BonoboGenericFactory *factory, const char *act_iid); } BonoboGenericFactoryClass;
BonoboGenericFactory* bonobo_generic_factory_new (const char *act_iid, BonoboFactoryCallback factory_cb,gpointer user_data);
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.
act_iid : | The GOAD id that this factory implements |
factory_cb : | A callback which is used to create new BonoboObject instances. |
user_data : | The closure data to be passed to the factory callback routine. |
Returns : | A BonoboGenericFactory object that has an activated Bonobo::GenericFactory object that has registered with the GNOME name server. |
BonoboGenericFactory* bonobo_generic_factory_new_closure (const char *act_iid,GClosure *factory_closure);
This is a helper routine that simplifies the creation of factory objects for GNOME objects. The factory_closure closure 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.
act_iid : | The GOAD id that this factory implements |
factory_closure : | A closure which is used to create new BonoboObject instances. |
Returns : | A BonoboGenericFactory object that has an activated Bonobo::GenericFactory object that has registered with the GNOME name server. |
BonoboGenericFactory* bonobo_generic_factory_construct (BonoboGenericFactory *factory, const char *act_iid,GClosure *factory_cb);
Initializes c_factory with and registers the new factory with the name server.
factory : | The object to be initialized. |
act_iid : | The Bonobo activation id that the new factory will implement. Bonobo::GenericFactory interface and which will be used to construct this BonoboGenericFactory Gtk object. |
factory_cb : | |
Returns : | The initialized BonoboGenericFactory object or NULL if already registered. |
void bonobo_generic_factory_construct_noreg (BonoboGenericFactory *factory, const char *act_iid,GClosure *factory_cb);
Initializes c_factory with the supplied closure and iid.
factory : | The object to be initialized. |
act_iid : | The GOAD id that the new factory will implement. |
factory_cb : |
int bonobo_generic_factory_main (const char *act_iid, BonoboFactoryCallback factory_cb,gpointer user_data);
A Generic 'main' routine so we don't stick a load of code inside a public macro.
act_iid : | the oaf iid of the factory |
factory_cb : | the factory callback |
user_data : | a user data pointer |
Returns : | 0 on success, 1 on failure. |
#define BONOBO_FACTORY_INIT(descr, version, argcp, argv)
descr : | |
version : | |
argcp : | |
argv : |
#define BONOBO_OAF_FACTORY(oafiid, descr, version, callback, data)
oafiid : | |
descr : | |
version : | |
callback : | |
data : |
#define BONOBO_OAF_FACTORY_MULTI(oafiid, descr, version, callback, data)
oafiid : | |
descr : | |
version : | |
callback : | |
data : |
<< BonoboXObject | bonobo-shlib-factory >> |