Libbonobo Reference Manual | ||||
---|---|---|---|---|
Top | Description | Object Hierarchy | Properties | Signals |
BonoboObjectBonoboObject — Base object for wrapping Bonobo::Unknown derived objects. Implements Figure 2, “The Bonobo::Unknown interface”. |
Synopsis
#define BONOBO_OBJECT_TYPE #define BONOBO_OBJREF (o) void (*BonoboObjectPOAFn) (PortableServer_Servant servant
,CORBA_Environment *ev
); BonoboObject; BonoboObjectClass; void bonobo_object_add_interface (BonoboObject *object
,BonoboObject *newobj
); BonoboObject * bonobo_object_query_local_interface (BonoboObject *object
,const char *repo_id
); Bonobo_Unknown bonobo_object_query_interface (BonoboObject *object
,const char *repo_id
,CORBA_Environment *opt_ev
); Bonobo_Unknown bonobo_object_query_remote (Bonobo_Unknown unknown
,const char *repo_id
,CORBA_Environment *opt_ev
); Bonobo_Unknown bonobo_object_corba_objref (BonoboObject *object
); Bonobo_Unknown bonobo_object_dup_ref (Bonobo_Unknown object
,CORBA_Environment *opt_ev
); Bonobo_Unknown bonobo_object_release_unref (Bonobo_Unknown object
,CORBA_Environment *opt_ev
); gpointer bonobo_object_ref (gpointer obj
); void bonobo_object_idle_unref (gpointer obj
); gpointer bonobo_object_unref (gpointer obj
); void bonobo_object_set_immortal (BonoboObject *object
,gboolean immortal
); gpointer bonobo_object_trace_refs (gpointer obj
,const char *fn
,int line
,gboolean ref
); void bonobo_object_dump_interfaces (BonoboObject *object
); void bonobo_object_check_env (BonoboObject *object
,CORBA_Object corba_object
,CORBA_Environment *ev
); #define BONOBO_OBJECT_CHECK (o, c, e) gboolean bonobo_unknown_ping (Bonobo_Unknown object
,CORBA_Environment *opt_ev
); void bonobo_object_list_unref_all (GList **list
); void bonobo_object_slist_unref_all (GSList **list
); BonoboObject * bonobo_object (gpointer p
); #define bonobo_object_fast (o) #define bonobo_object_from_servant (s) #define bonobo_object_get_servant (o) PortableServer_POA bonobo_object_get_poa (BonoboObject *object
); GType bonobo_type_unique (GType parent_type
,BonoboObjectPOAFn init_fn
,BonoboObjectPOAFn fini_fn
,int epv_struct_offset
,const GTypeInfo *info
,const gchar *type_name
); gboolean bonobo_type_setup (GType type
,BonoboObjectPOAFn init_fn
,BonoboObjectPOAFn fini_fn
,int epv_struct_offset
); #define BONOBO_TYPE_FUNC_FULL (class_name, corba_name, parent, prefix) #define BONOBO_TYPE_FUNC (class_name, parent, prefix)
Object Hierarchy
GObject +----BonoboObject +----BonoboGenericFactory +----BonoboPersist +----BonoboMonikerExtender +----BonoboItemContainer +----BonoboStreamMem +----BonoboItemHandler +----BonoboListener +----BonoboMoniker
Description
BonoboObject provides an easy to use way of writing CORBA servers. It drastically simplifies the issues of epv and vepv construction by automating these, and automatically instantiates a CORBA_Object on g_object_new. This removes clutter from construction time. For libbonobo-2.0, it strongly deprecates BonoboXObject.
The Bonobo::Unknown
interface (wrapped by
BonoboObject) is the foundation for the component system: it provides
life cycle management for objects as well as service discovery.
The Bonobo interfaces are all based on the
Bonobo::Unknown
interface. This
interface is very simple and provides two basic services:
object lifetime management and object
functionality-discovery. This interface only contains three
methods, here it is:
module Bonobo { interface Unknown { void void ref (); void void unref (); Object query_interface (in string repoid); }; };
The
and ref()
methods are used to control the lifetime of an object. The
unref()
query_interface
method is used to discover
optional functionality provided by the object implementation.
The lifetime management is based on reference counting: when a component is initially launched, it starts life with a reference count of one. This reference is held by the component invoker. Each time a reference is kept to this object (say, you store a copy of the object in an array), the reference count is incremented. Every time a reference goes out of scope, the reference count needs to be decremented. When the reference count reaches zero, the component knows that there are no outstanding references to it, and it is safe to shutdown. At this point, the component shuts down.
It is possible to ask an object which implements the
Bonobo::Unknown
interface if it supports
other CORBA interfaces. For example, it would be possible to
ask an object whether it supports the
"IDL:Bonobo/EmbeddablePrint:1.0" interface to find out if it is
possible to print its contents. If the return value from
invoking the query_interface
method on the
interface is CORBA_OBJECT_NIL, then we know that the requested interface
is not supported. Otherwise, we can invoke
IDL:Bonobo/EmbeddablePrint:1.0 methods on the returned CORBA
Object.
Clients of the query_interface
method use
it to discover dynamically if a component supports a given
interface. Sometimes the client code would require a specific
interface to exist, but many times it is possible to operate in
a "downgraded" mode. You should design your code to be able to
cope with the lack of interfaces in objects. This will allow
your program to deal with more components, and this also allows
components to work in more situations.
For example, a help browser can load an HTML renderer component and ask this component which sort of features are supported by it:
stop_animations (BrowserHTML html) { BrowserControl control control = html->query_interface ("IDL:Browser/Control:1.0"); if (control) control->stop_animations (); }
The return value of the query_interface invocation contains a
reference to a CORBA object that is derived from the
Bonobo::Unknown
interface or
CORBA_OBJECT_NIL if the interface is not supported by the
object. And this interface would have been already
ed before it was returned. It is up
to the caller to call ref()
when they are
done using the interface.
unref()
BonoboObject implements the Bonobo::Unknown interface and exports the implementations of the methods in this class to simplify creating new objects that inherit from Bonobo::Unknown. This base object provides default implementations for the ref, unref and query_interface methods.
Other implementations reuse this implementation by listing on their VEPV tables the bonobo_object_epv entry point vector.
The Bonobo::Unknown
interface is inspired
by the Microsoft COM IUnknown
interface
but it has been translated into the CORBA world.
Details
BONOBO_OBJECT_TYPE
#define BONOBO_OBJECT_TYPE BONOBO_TYPE_OBJECT /* deprecated, you should use BONOBO_TYPE_OBJECT */
Returns the GtkType for the BonoboObject object.
BONOBO_OBJREF()
#define BONOBO_OBJREF(o) (bonobo_object_corba_objref(BONOBO_OBJECT(o)))
This macro returns the CORBA object reference inside a BonoboObject.
|
a BonoboObject |
BonoboObjectPOAFn ()
void (*BonoboObjectPOAFn) (PortableServer_Servant servant
,CORBA_Environment *ev
);
Signature of POA initialization and finalization functions
|
the object's servant |
|
CORBA environment |
BonoboObjectClass
typedef struct { GObjectClass parent_class; /* signals. */ void (*destroy) (BonoboObject *object); void (*system_exception) (BonoboObject *object, CORBA_Object cobject, CORBA_Environment *ev); BonoboObjectPOAFn poa_init_fn; BonoboObjectPOAFn poa_fini_fn; POA_Bonobo_Unknown__vepv *vepv; /* The offset of this class' additional epv */ int epv_struct_offset; PortableServer_ServantBase__epv base_epv; POA_Bonobo_Unknown__epv epv; gpointer dummy[4]; } BonoboObjectClass;
BonoboObject's class.
bonobo_object_add_interface ()
void bonobo_object_add_interface (BonoboObject *object
,BonoboObject *newobj
);
Adds the interfaces supported by newobj
to the list of interfaces
for object
. This function adds the interfaces supported by
newobj
to the list of interfaces support by object
. It should never
be used when the object has been exposed to the world. This is a firm
part of the contract.
|
The BonoboObject to which an interface is going to be added. |
|
The BonoboObject containing the new interface to be added. |
bonobo_object_query_local_interface ()
BonoboObject * bonobo_object_query_local_interface (BonoboObject *object
,const char *repo_id
);
|
A BonoboObject which is the aggregate of multiple objects. |
|
The id of the interface being queried. |
Returns : |
A BonoboObject for the requested interface. |
bonobo_object_query_interface ()
Bonobo_Unknown bonobo_object_query_interface (BonoboObject *object
,const char *repo_id
,CORBA_Environment *opt_ev
);
|
A BonoboObject to be queried for a given interface. |
|
The name of the interface to be queried. |
|
optional exception environment |
Returns : |
The CORBA interface named repo_id for object .
|
bonobo_object_query_remote ()
Bonobo_Unknown bonobo_object_query_remote (Bonobo_Unknown unknown
,const char *repo_id
,CORBA_Environment *opt_ev
);
A helper wrapper for query interface
|
an unknown object ref ( or NIL ) |
|
the interface to query for |
|
an optional exception environment |
Returns : |
the interface or CORBA_OBJECT_NIL |
bonobo_object_corba_objref ()
Bonobo_Unknown bonobo_object_corba_objref (BonoboObject *object
);
|
A BonoboObject whose CORBA object is requested. |
Returns : |
The CORBA interface object for which object is a wrapper.
|
bonobo_object_dup_ref ()
Bonobo_Unknown bonobo_object_dup_ref (Bonobo_Unknown object
,CORBA_Environment *opt_ev
);
This function returns a duplicated CORBA Object reference; it also bumps the ref count on the object. This is ideal to use in any method returning a Bonobo_Object in a CORBA impl. If object is CORBA_OBJECT_NIL it is returned unaffected.
|
a Bonobo_Unknown corba object |
|
an optional exception environment |
Returns : |
duplicated & ref'd corba object reference. |
bonobo_object_release_unref ()
Bonobo_Unknown bonobo_object_release_unref (Bonobo_Unknown object
,CORBA_Environment *opt_ev
);
This function releases a CORBA Object reference; it also decrements the ref count on the bonobo object. This is the converse of bonobo_object_dup_ref. We tolerate object == CORBA_OBJECT_NIL silently.
|
a Bonobo_Unknown corba object |
|
an optional exception environment |
Returns : |
CORBA_OBJECT_NIL .
|
bonobo_object_ref ()
gpointer bonobo_object_ref (gpointer obj
);
Increments the reference count for the aggregate BonoboObject.
|
A BonoboObject you want to ref-count |
Returns : |
object
|
bonobo_object_unref ()
gpointer bonobo_object_unref (gpointer obj
);
Decrements the reference count for the aggregate BonoboObject.
|
A BonoboObject you want to unref. |
Returns : |
NULL .
|
bonobo_object_set_immortal ()
void bonobo_object_set_immortal (BonoboObject *object
,gboolean immortal
);
|
|
|
bonobo_object_trace_refs ()
gpointer bonobo_object_trace_refs (gpointer obj
,const char *fn
,int line
,gboolean ref
);
|
|
|
|
|
|
|
|
Returns : |
bonobo_object_dump_interfaces ()
void bonobo_object_dump_interfaces (BonoboObject *object
);
|
bonobo_object_check_env ()
void bonobo_object_check_env (BonoboObject *object
,CORBA_Object corba_object
,CORBA_Environment *ev
);
This routine verifies the ev
environment for any fatal system
exceptions. If a system exception occurs, the object raises a
"system_exception" signal. The idea is that GObjects which are
used to wrap a CORBA interface can use this function to notify
the user if a fatal exception has occurred, causing the object
to become defunct.
|
The object on which we operate |
|
|
|
CORBA Environment to check |
BONOBO_OBJECT_CHECK()
#define BONOBO_OBJECT_CHECK(o,c,e)
Checks if the exception in e
needs to be signaled. If so, then
the proper exception signal is generated on the BonoboObject object
o
for the CORBA reference c
.
|
|
|
|
|
bonobo_unknown_ping ()
gboolean bonobo_unknown_ping (Bonobo_Unknown object
,CORBA_Environment *opt_ev
);
Pings the object object
using the ref/unref methods from Bonobo::Unknown.
You can use this one to see if a remote object has gone away.
|
a CORBA object reference of type Bonobo::Unknown |
|
optional exception environment |
Returns : |
TRUE if the Bonobo::Unknown object is alive.
|
bonobo_object_list_unref_all ()
void bonobo_object_list_unref_all (GList **list
);
This routine unrefs all valid objects in
the list and then removes them from list
if
they have not already been so removed.
|
A list of BonoboObjects *s |
bonobo_object ()
BonoboObject * bonobo_object (gpointer p
);
This function can be passed a BonoboObject * or a PortableServer_Servant, and it will return a BonoboObject *.
|
a pointer to something |
Returns : |
a BonoboObject or NULL on error. |
bonobo_object_from_servant()
#define bonobo_object_from_servant(s) ((BonoboObject *)(((guchar *) (s)) - BONOBO_OBJECT_HEADER_SIZE))
|
|
Returns : |
bonobo_object_get_servant()
#define bonobo_object_get_servant(o) ((PortableServer_Servant)((guchar *)(o) + BONOBO_OBJECT_HEADER_SIZE))
|
|
Returns : |
bonobo_object_get_poa ()
PortableServer_POA bonobo_object_get_poa (BonoboObject *object
);
Gets the POA associated with this part of the BonoboObject aggregate it is possible to have different POAs per interface.
|
the object associated with an interface |
Returns : |
the poa, never NIL. |
bonobo_type_unique ()
GType bonobo_type_unique (GType parent_type
,BonoboObjectPOAFn init_fn
,BonoboObjectPOAFn fini_fn
,int epv_struct_offset
,const GTypeInfo *info
,const gchar *type_name
);
This function is the main entry point for deriving bonobo server interfaces.
|
the parent GType |
|
a POA initialization function |
|
a POA finialization function or NULL |
|
the offset into the struct that the epv commences at, or 0 if we are inheriting a plain GObject from a BonoboObject, adding no new CORBA interfaces |
|
the standard GTypeInfo. |
|
the name of the type being registered. |
Returns : |
the constructed GType. |
bonobo_type_setup ()
gboolean bonobo_type_setup (GType type
,BonoboObjectPOAFn init_fn
,BonoboObjectPOAFn fini_fn
,int epv_struct_offset
);
This function initializes a type derived from BonoboObject, such that when you instantiate a new object of this type with g_type_new the CORBA object will be correctly created and embedded.
|
The type to initialize |
|
the POA_init function for the CORBA interface or NULL |
|
NULL or a custom POA free fn. |
|
the offset in the class structure where the epv is or 0 |
Returns : |
TRUE on success, FALSE on error. |
BONOBO_TYPE_FUNC_FULL()
#define BONOBO_TYPE_FUNC_FULL(class_name, corba_name, parent, prefix)
Macro that includes all the boilerplate code need to register a
new BonoboObject-derived class. The programmer has to define two
functions only: prefix_init
and prefix_class_init
. As a result
of the macro expansion, a function named @prefix_get_type()
is
defined.
|
Name of the GObject class, LikeThis |
|
Name of the CORBA interface, with IDL-to-C mapping, Like_This |
|
GType of the parent class, LIKE_TYPE_THIS |
|
prefix of the implementation functions |
BONOBO_TYPE_FUNC()
#define BONOBO_TYPE_FUNC(class_name, parent, prefix)
Like BONOBO_TYPE_FUNC, but doesn't set POA ini and fini functions.
|
|
|
|
|
Property Details
The "poa"
property
"poa" gpointer : Read / Write / Construct Only
Pass this property during construction to specify a custom POA for a BonoboObject. Example:
1 2 3 4 5 6 7 |
BonoboObject * my_bonobo_object_new (void) { BonoboObject *object; object = g_object_new (MY_TYPE_BONOBO_OBJECT, "poa", bonobo_poa_get_threaded (BONOBO_POA_ALL_AT_IDLE), NULL); return object; } |
Signal Details
The "destroy"
signal
void user_function (BonoboObject *bonoboobject, gpointer user_data) : Run Last
Signal emitted when the last reference of a BonoboObject has been lost and the object is being destroyed / finalized / deactivated.
|
the object which received the signal. |
|
user data set when the signal handler was connected. |
The "system-exception"
signal
void user_function (BonoboObject *bonoboobject, CorbaObject *arg1, BonoboCorbaException *arg2, gpointer user_data) : Run Last
Signal emitted from bonobo_object_check_env if a system exception is identified.
|
the BonoboObject which received the signal. |
|
the CORBA_Object contained in bonoboobject .
|
|
the exception that has just occurred. |
|
user data set when the signal handler was connected. |