1 | /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ |
---|
2 | /** |
---|
3 | * bonobo-shlib-factory.h: a ShlibFactory object. |
---|
4 | * |
---|
5 | * Author: |
---|
6 | * Michael Meeks (michael@helixcode.com) |
---|
7 | * |
---|
8 | * Copyright 2000 Helix Code, Inc. |
---|
9 | */ |
---|
10 | #ifndef _BONOBO_SHLIB_FACTORY_H_ |
---|
11 | #define _BONOBO_SHLIB_FACTORY_H_ |
---|
12 | |
---|
13 | #include <libgnome/gnome-defs.h> |
---|
14 | #include <gtk/gtkobject.h> |
---|
15 | #include <bonobo/Bonobo.h> |
---|
16 | #include <bonobo/bonobo-object.h> |
---|
17 | #include <liboaf/oaf.h> |
---|
18 | #include <bonobo/bonobo-generic-factory.h> |
---|
19 | #include <bonobo/bonobo-exception.h> |
---|
20 | |
---|
21 | BEGIN_GNOME_DECLS |
---|
22 | |
---|
23 | #define BONOBO_SHLIB_FACTORY_TYPE (bonobo_shlib_factory_get_type ()) |
---|
24 | #define BONOBO_SHLIB_FACTORY(o) (GTK_CHECK_CAST ((o), BONOBO_SHLIB_FACTORY_TYPE, BonoboShlibFactory)) |
---|
25 | #define BONOBO_SHLIB_FACTORY_CLASS(k) (GTK_CHECK_CLASS_CAST((k), BONOBO_SHLIB_FACTORY_TYPE, BonoboShlibFactoryClass)) |
---|
26 | #define BONOBO_IS_SHLIB_FACTORY(o) (GTK_CHECK_TYPE ((o), BONOBO_SHLIB_FACTORY_TYPE)) |
---|
27 | #define BONOBO_IS_SHLIB_FACTORY_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), BONOBO_SHLIB_FACTORY_TYPE)) |
---|
28 | |
---|
29 | #define BONOBO_OAF_SHLIB_FACTORY_MULTI(oafiid, descr, fn, data) \ |
---|
30 | static CORBA_Object \ |
---|
31 | make_factory (PortableServer_POA poa, const char *iid, gpointer impl_ptr, \ |
---|
32 | CORBA_Environment *ev) \ |
---|
33 | { \ |
---|
34 | BonoboShlibFactory *f; \ |
---|
35 | CORBA_Object object_ref; \ |
---|
36 | f = bonobo_shlib_factory_new_multi (oafiid, poa, impl_ptr, fn, data); \ |
---|
37 | object_ref = bonobo_object_corba_objref (BONOBO_OBJECT (f)); \ |
---|
38 | if (BONOBO_EX (ev) || !object_ref) { \ |
---|
39 | g_warning ("cannot get objref: '%s'", \ |
---|
40 | bonobo_exception_get_text (ev)); \ |
---|
41 | return CORBA_OBJECT_NIL; \ |
---|
42 | } \ |
---|
43 | return CORBA_Object_duplicate (object_ref, ev); \ |
---|
44 | } \ |
---|
45 | static OAFPluginObject plugin_list[] = {{oafiid, make_factory}, { NULL } }; \ |
---|
46 | const OAFPlugin OAF_Plugin_info = { plugin_list, descr }; |
---|
47 | |
---|
48 | #define BONOBO_OAF_SHLIB_FACTORY(oafiid, descr, fn, data) \ |
---|
49 | static CORBA_Object \ |
---|
50 | make_factory (PortableServer_POA poa, const char *iid, gpointer impl_ptr, \ |
---|
51 | CORBA_Environment *ev) \ |
---|
52 | { \ |
---|
53 | BonoboShlibFactory *f; \ |
---|
54 | CORBA_Object object_ref; \ |
---|
55 | f = bonobo_shlib_factory_new (oafiid, poa, impl_ptr, fn, data); \ |
---|
56 | object_ref = bonobo_object_corba_objref (BONOBO_OBJECT (f)); \ |
---|
57 | if (BONOBO_EX (ev) || !object_ref) { \ |
---|
58 | g_warning ("cannot get objref: '%s'", \ |
---|
59 | bonobo_exception_get_text (ev)); \ |
---|
60 | return CORBA_OBJECT_NIL; \ |
---|
61 | } \ |
---|
62 | return CORBA_Object_duplicate (object_ref, ev); \ |
---|
63 | } \ |
---|
64 | static OAFPluginObject plugin_list[] = {{oafiid, make_factory}, { NULL } }; \ |
---|
65 | const OAFPlugin OAF_Plugin_info = { plugin_list, descr }; |
---|
66 | |
---|
67 | typedef struct _BonoboShlibFactoryPrivate BonoboShlibFactoryPrivate; |
---|
68 | |
---|
69 | typedef struct { |
---|
70 | BonoboGenericFactory base; |
---|
71 | |
---|
72 | int live_objects; |
---|
73 | gpointer oaf_impl_ptr; |
---|
74 | |
---|
75 | BonoboShlibFactoryPrivate *priv; |
---|
76 | } BonoboShlibFactory; |
---|
77 | |
---|
78 | typedef struct { |
---|
79 | BonoboGenericFactoryClass parent_class; |
---|
80 | } BonoboShlibFactoryClass; |
---|
81 | |
---|
82 | GtkType bonobo_shlib_factory_get_type (void); |
---|
83 | |
---|
84 | BonoboShlibFactory *bonobo_shlib_factory_construct ( |
---|
85 | BonoboShlibFactory *c_factory, |
---|
86 | const char *component_id, |
---|
87 | PortableServer_POA poa, |
---|
88 | gpointer oaf_impl_ptr, |
---|
89 | CORBA_Object corba_factory, |
---|
90 | BonoboGenericFactoryFn factory, |
---|
91 | GnomeFactoryCallback factory_cb, |
---|
92 | void *data); |
---|
93 | |
---|
94 | BonoboShlibFactory *bonobo_shlib_factory_new ( |
---|
95 | const char *component_id, |
---|
96 | PortableServer_POA poa, |
---|
97 | gpointer oaf_impl_ptr, |
---|
98 | BonoboGenericFactoryFn factory, |
---|
99 | gpointer user_data); |
---|
100 | |
---|
101 | BonoboShlibFactory *bonobo_shlib_factory_new_multi ( |
---|
102 | const char *component_id, |
---|
103 | PortableServer_POA poa, |
---|
104 | gpointer oaf_impl_ptr, |
---|
105 | GnomeFactoryCallback factory_cb, |
---|
106 | gpointer user_data); |
---|
107 | |
---|
108 | void bonobo_shlib_factory_track_object ( |
---|
109 | BonoboShlibFactory *factory, |
---|
110 | BonoboObject *object); |
---|
111 | |
---|
112 | void bonobo_shlib_factory_inc_live ( |
---|
113 | BonoboShlibFactory *factory); |
---|
114 | |
---|
115 | void bonobo_shlib_factory_dec_live ( |
---|
116 | BonoboShlibFactory *factory); |
---|
117 | |
---|
118 | END_GNOME_DECLS |
---|
119 | |
---|
120 | #endif |
---|